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

风流意气都作罢 提交于 2019-12-02 04:46:35

问题


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. 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.

I know you can do data bindings to CSV and the like, but that's too burdensome. I want to be able to write C# code to change which text is typed.

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...


回答1:


to set the property just do:

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

or:

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


来源:https://stackoverflow.com/questions/30991370/how-to-i-inject-programmatic-text-into-my-coded-ui-test-as-opposed-to-recorded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!