简体   繁体   English

如何在Visual Studio中将编程文本注入到我的编码UI测试中(而不是录制的文本)?

[英]How to I inject programmatic text into my Coded UI test (as opposed to recorded text) in Visual Studio?

The recorder works fine for quickly getting some steps thrown down, but I need to be able to store and set arbitrary text. 记录器可以很好地工作,可以快速解决一些问题,但是我需要能够存储和设置任意文本。 Let's say I generated a new admin user called Admin001. 假设我生成了一个名为Admin001的新管理员用户。 I want to be able to set the text for the control to be "Admin001", not whatever was recorded when I first used the builder. 我希望能够将控件的文本设置为“ Admin001”,而不是我初次使用构建器时记录的内容。

I know you can do data bindings to CSV and the like, but that's too burdensome. 我知道您可以将数据绑定到CSV等,但这太麻烦了。 I want to be able to write C# code to change which text is typed. 我希望能够编写C#代码来更改键入的文本。

Screenshot: 截图:

在此处输入图片说明

Code attempt: 代码尝试:

            var loginElement = new UILoginInternetExploreWindow().UILoginDocument.UIUserNameorEmailAddreEdit.Text;

So I'm able to get the property .Text (I think), but not actually set it... 因此,我能够获得.Text属性(我认为),但实际上并未进行设置...

to set the property just do: 设置属性只需执行以下操作:

new UILoginInternetExploreWindow().UILoginDocument.UIUserNameorEmailAddreEdit.Text = 
"Some Text";

or: 要么:

var loginControl = new UILoginInternetExploreWindow().UILoginDocument.UIUserNameorEmailAddreEdit;
loginControl.Text = "Some Text";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 编码的UI测试生成器导致我的Visual Studio应用崩溃 - Coded UI Test Builder Causes My Visual Studio Apps To Crash Visual Studio 2013编码的UI测试 - Visual Studio 2013 Coded UI Test Visual Studio 2013的编码的ui测试生成器无法检测控件 - Coded ui test builder of Visual studio 2013 not able to detect controls 运行测试的彩色圆圈未出现在Visual Studio编码的UI测试中 - Colourful circles that run tests not appearing on Visual Studio Coded UI Test Visual Studio 2012 - 编码的UI测试不会运行 - Visual Studio 2012 - Coded UI Test Wont Run 如何在不安装 Visual Studio 2010 的情况下使用 MSTest.ese 运行编码的 UI 测试 - How to run coded UI test with MSTest.ese without installing Visual Studio 2010 Visual Studio 一种显示运算符而不是文本的方法 示例:≠ 而不是 != - Visual Studio a way to show operators as opposed to text Example: ≠ instead of != 编码的UI测试生成器:验证文本框中的Text属性 - Coded UI Test Builder: Verification of Text property in Textboxes 编码的UI测试生成器无法为记录的操作生成代码 - Coded UI Test Builder fails to generate code for recorded action Visual Studio 2013编码的UI,测试实验室,远程测试,测试代理配置 - Visual Studio 2013 Coded UI, Test Lab, remote testing, Test agent configuration
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM