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 测试(而不是录制的文本)?
基础教程推荐
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
