且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

CodedUITest属性根据PC语言的不同而不同

更新时间:2023-01-24 14:54:29

Hi Vince ,

我假设您在RadTabControl的ItemStatus属性上添加了断言,但是ItemStatus属性的值根据您所用语言的不同而有所不同计算机,这将导致测试失败.

为了避免此类问题,建议您在编码的UI测试方法中编写自己的代码,以使用正确的ItemStatus属性值进行此断言.您可以使用环境变量来区分测试 环境.请参阅:

In order to avoid such issue, I suggest writing your own code in coded UI test method to make this assertion with the correct ItemStatus property value. You can use environment variable to distinguish the test environment. Please see:How To: Get same test running under different environments

代码可能看起来像这样:

UITestControl control = xxx.yyy.zzz;//定义RabTabControl 跨度>

UITestControl control=xxx.yyy.zzz;//define the RabTabControl

Control.SearchProperties.Add…//使用搜索属性来找到控件

  字符串 testServer =

       环境 .GetEnvironmentVariable("TestServer" );

        Environment.GetEnvironmentVariable("TestServer");

如果(测试服务器是使用英语的服务器)

Assert.AreEqual(control.itemstatus," <属性名称="SelectedValue" Value ="Telerik.Windows.Controls.RadTabItem 标头:Tab1内容​​:abc" /> ")

Assert.AreEqual(control.itemstatus, "<Property Name="SelectedValue" Value="Telerik.Windows.Controls.RadTabItem Header:Tab1 Content:abc" />")

如果(测试服务器是瑞士语言的服务器)

Assert.AreEqual(control.itemstatus," <属性名称="SelectedValue" Value ="Telerik.Windows.Controls.RadTabItem 标头:Tab1内容​​:abc /> ");

Assert.AreEqual(control.itemstatus, "<Property Name="SelectedValue" Value="Telerik.Windows.Controls.RadTabItem Header : Tab1 Content : abc" />");

关于如何编写自己的编码UI测试,该博客可以帮助您:

About how to write your own coded UI test, this blog can help you: Hand-coding a Coded UI Test

谢谢

或者您也可以在UIMap.cs文件中根据服务器语言对记录的预期itemstatus值进行逻辑处理,以便在不同的环境中使用相应的值,而无需手动编码UI测试.请参阅地图重构 控制并编辑并重新运行本文档中的编码的UI测试"部分:

Or you can make a logic in the UIMap.cs file for the recorded expected itemstatus value based on the server language to use corresponding value in different environment instead of hand coding your coded UI test. Please see ‘Map Refactor control and edit and rerun the coded UI test’ section in this document: Walkthrough: Creating, Editing and Maintaining a Coded UI Test

谢谢