[英]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.