日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

How does “Coded UI test” finds a control ?

發布時間:2025/3/21 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 How does “Coded UI test” finds a control ? 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
轉自:http://blogs.msdn.com/b/balagans/archive/2009/12/28/9941582.aspx Coded UI tests allows user to capture actions and generates property validations on the controls in the application. In order to do functional testing on the application, Coded UI test needs to playback all the actions that are captured and perform validations on the UI objects in the application interface. So, Search for controls forms the base for all the actions and validations done by Coded UI tests.

In order to find the control in test execution phase, Coded UI test captures some set of properties on the control and name them as “Search Properties” and “Filter Properties”. Each instance of these is a? Name-value pair, with Name being the Property-Name and Value being the actual value of the property during the time of the capture.

Search for a control always starts from desktop. Lets take an example of a control whose search properties and filter properties are captured

Code

??????????????????? HtmlEdit? mUIEmailEdit = new HtmlEdit(someAncestorControl);
??????????????????? mUIEmailEdit.SearchProperties[HtmlEdit.PropertyNames.Id] = "email";
??????????????????? mUIEmailEdit.SearchProperties[HtmlEdit.PropertyNames.Name] = "email";
??????????????????? mUIEmailEdit.FilterProperties[HtmlEdit.PropertyNames.LabeledBy] = null;
??????????????????? mUIEmailEdit.FilterProperties[HtmlEdit.PropertyNames.Type] = "SINGLELINE";
??????????????????? mUIEmailEdit.FilterProperties[HtmlEdit.PropertyNames.Title] = null;
??????????????????? mUIEmailEdit.FilterProperties[HtmlEdit.PropertyNames.Class] = null;
??????????????????? mUIEmailEdit.FilterProperties[HtmlEdit.PropertyNames.ControlDefinition] = "id=email size=25 name=email";
??????????????????? mUIEmailEdit.FilterProperties[HtmlEdit.PropertyNames.TagInstance] = "7";

????????? mUIEmailEdit.Find();

Description

From the code, we will be able to get all the properties that are associated with the control under test from the control object ( mUIEmailEdit ). When the search for the control starts ( explicit by Find() or implicit by any usage of the control in actions or property validations ), it starts finding the controls under the Container element of the control ( someAncestorControl ).

Search in Coded UI test is a Breadth-First which compares each of the controls in the traversal for the match of the properties given in the code.

First pass of the Search is done for the match of All properties given in SearchProperties list. Basically this can be referred as AND Condition of search properties. In cases, where the results of the search using SearchProperties finds exactly one control or doesn’t find any control, Coded UI test skips using the Filter Properties (even if is defined in the code) because of the 2 cases,

??? 1. There is exactly one control, so there is no need to apply filters.

??? 2. There are no controls to apply filters.

But, in cases where the list of SearchProperties is not good enough to find the exact control, Coded UI tests uses the filter properties (one by one) till it finds One exact match. Basically this can be referred as Ordered Match.

In remote cases where Search using FilterProperties also results in more than one control, the First match is returned as the resultant control.

Example

Lets take the instance of search for the code written above

1. Search starts at the “someAncestorControl” control as it is specified as the ancestor for the control to be found.

2. At every traversal, we match the properties of the current control “X” with the search properties mentioned in the code. Let say we have a list of controls (X1, X2 and X3) under the container’s hierarchy that matches the properties.

3. Now we need to nail down the search to one control. From the list (X1, X2 and X3) , we check for the match of 1st Filter property ( HtmlEdit.PropertyNames.LabeledBy ). Let say the list now trims to (X2 and X3). In case of no match , we skip this filter property and keep using the next filter property for search.

4. We continue #Step3 with the following filter properties (one-by-one) till the list of resultant controls trims to 1 or till all the filter properties compared.

Workflow of Search

Technology specific data

1. Search for Web controls????????????????????? : Both SearchProperties and Filter Properties are supported.

2. Search for Winforms, Wpf controls????? : Only SearchProperties are supported.

Choice of SearchProperties

Each technology has a limited set of properties that can be used for search via Coded UI tests. So, Coded UI tests chooses only the properties exposed by the technology as SearchProperties. These are chosen by targeting a good trade-off between robustness and performance.

For instance, the Web technology exposes many properties including all the attributes of the controls rendered in the page, whereas .Net controls’ accessibility exposes only a sub-set of the properties via accessibility.

總結

以上是生活随笔為你收集整理的How does “Coded UI test” finds a control ?的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。