CodedUITest属性根据PC语言的不同而不同 [英] CodedUITest property generated different depending of Pc's language

查看:74
本文介绍了CodedUITest属性根据PC语言的不同而不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试通过一个非常简单的WPF应用程序记录CodedUI测试时,我遇到了麻烦:

I'm encoutering an issue while trying to record a CodedUI Test over a very simple WPF application which looks like this :

< Window

<Window

       xmlns =" http://schemas.microsoft.com/winfx/2006/xaml/presentation " ;

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

       xmlns:x =" http://schemas.microsoft.com/winfx/2006/xaml "

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

       xmlns:telerik =" http://schemas.telerik.com/2008/xaml/presentation "x:Class ="WpfApplication2.MainWindow"

        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" x:Class="WpfApplication2.MainWindow"

      标题="MainWindow".高度="350".宽度="525">

        Title="MainWindow" Height="350" Width="525">

  < Grid Margin =" 0,0,2,0">

  <Grid Margin="0,0,2,0">

   < telerik:RadTabControl Horizo​​ntalAlignment ="Stretch"保证金="14,27,0,10" VerticalAlignment =拉伸"

    <telerik:RadTabControl HorizontalAlignment="Stretch" Margin="14,27,0,10" VerticalAlignment="Stretch">

     < telerik:RadTabItem Header ="Tab1"内容="abc"/

      <telerik:RadTabItem Header="Tab1" Content="abc"/>

     < telerik:RadTabItem Header ="Tab2"内容="abc"/

      <telerik:RadTabItem Header="Tab2" Content="abc"/>

   </telerik:RadTabControl>

    </telerik:RadTabControl>

  </Grid>

  </Grid>

</Window>

</Window>

我正在使用Windows 8.1工作站.如果将英语(US)语言用作Windows显示语言,则当我尝试在RadTabControl上执行断言时,ItemStatus属性包含以下生成的字符串,这似乎是正确的:

I'm using a windows 8.1 Workstation. If the language English (US) is used as the Windows display language, when I try to perform an assertion on the RadTabControl, the ItemStatus property contains the following generated string, which seems correct :

...< Property Name =" SelectedValue"值="Telerik.Windows.Controls.RadTabItem标题:Tab1内容​​:abc". /> ...

... <Property Name="SelectedValue" Value="Telerik.Windows.Controls.RadTabItem Header:Tab1 Content:abc" /> ...

另一方面,如果使用语言包French(Switzerland),并且具有完全相同的应用程序和完全相同的断言,则生成的字符串如下所示:

In another hand, if the language pack French (Switzerland) is used, with the exact same application and the exact same assertion, the generated string looks like this :

...< Property Name =" SelectedValue"值="Telerik.Windows.Controls.RadTabItem标头:Tab1内容​​:abc" /> ...

... <Property Name="SelectedValue" Value="Telerik.Windows.Controls.RadTabItem Header : Tab1 Content : abc" /> ...

我们可以注意到在列字符之前和之后添加的空格.

We can notice the whitespaces added before and after the column character.

此行为的问题是,如果我们在具有英语(US)设置的计算机上记录CodedUI测试,并在具有法语(瑞士)设置的计算机上播放,则断言将失败.

The issue with this behavior is that if we record a CodedUI Test on machine with English (US) settings, and playback on a machine with French (Switzerland) settings, the assertion will fail.

有人可以调查这个问题吗?

Can someone please look into this issue ?

谢谢.

-文斯

-Vince

推荐答案

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

谢谢


这篇关于CodedUITest属性根据PC语言的不同而不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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