如何在 Visual Studio 中将编程文本注入我的编码 UI 测试(而不是录制的文本)? [英] How to I inject programmatic text into my Coded UI test (as opposed to recorded text) in Visual Studio?

查看:17
本文介绍了如何在 Visual Studio 中将编程文本注入我的编码 UI 测试(而不是录制的文本)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

记录器可以很好地快速完成一些步骤,但我需要能够存储和设置任意文本.假设我生成了一个名为 Admin001 的新管理员用户.我希望能够将控件的文本设置为Admin001",而不是我第一次使用构建器时记录的任何内容.

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.

我知道您可以将数据绑定到 CSV 等,但这太繁琐了.我希望能够编写 C# 代码来更改键入的文本.

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.

截图:

代码尝试:

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

所以我可以获得属性 .Text(我认为),但实际上并没有设置它......

So I'm able to get the property .Text (I think), but not actually set it...

推荐答案

设置属性就行了:

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

或:

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

这篇关于如何在 Visual Studio 中将编程文本注入我的编码 UI 测试(而不是录制的文本)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆