清單 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