清单 2.通过页面元素属性识别字符串识别待测应用程序元素
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
//根据属性对查找唯一符合条件的元素,并且记录查找结果到日志模块当中 public TestObject findObjectByProperties(String properties) { TestObject to = null; try { Property[] propGroup = setPropertyGroup(properties); TestObject[] tos = getRootTestObject() .find(atDescendant(propGroup)); to = tos[0]; TestLogger.logPassInfo("Pass- Object( " + properties + " ) is not found by ObjFinder); return to; } catch (Exception e) { TestLogger.logErrorInfo("Fail- Object( " + properties + " ) is not found by ObjFinder", e); return null; } } //解析元素识别字符串,将字符串映射为属性对 public Property[] setPropertyGroup(String properties) { String[] strGroup = properties.split("split symbol"); Property[] propGroup = new Property[strGroup.length]; for (int i = 0; i < strGroup.length; i++) { String[] propertyPair = strGroup[i].split("="); String key = propertyPair[0]; String value = propertyPair[1]; propGroup[i] = new Property(key, value); } return propGroup; } |
原文转自:http://www.ibm.com/developerworks/cn/rational/1611_xux_rft/index.html