How to I inject programmatic text into my Coded UI test (as opposed to recorded text) in Visual Studio?(如何在 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 测试(而不是录制的文本)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Visual Studio 中将编程文本注入我的编码 UI 测试(而不是录制的文本)?


- CanBeNull和ReSharper-将其用于异步任务? 2022-01-01
- Windows 喜欢在 LINUX 中使用 MONO 进行服务开发? 2022-01-01
- C# 通过连接字符串检索正确的 DbConnection 对象 2022-01-01
- 为什么 C# 中的堆栈大小正好是 1 MB? 2022-01-01
- Azure Active Directory 与 MVC,客户端和资源标识同一 2022-01-01
- 使用 rss + c# 2022-01-01
- 在 C# 中异步处理项目队列 2022-01-01
- 是否可以在 .Net 3.5 中进行通用控件? 2022-01-01
- 带问号的 nvarchar 列结果 2022-01-01
- 在 LINQ to SQL 中使用 contains() 2022-01-01