代码改变世界

Selenium2Library:Get Matching Xpath Count用法

2013-12-18 11:27  glre09  阅读(1635)  评论(0)    收藏  举报

Name:
Get Matching Xpath Count
Source:
Selenium2Library <test library>
Arguments:
[ xpath ]
Returns number of elements matching `xpath`
If you wish to assert the number of matching elements, use `Xpath Should Match X Times`.

 

================

 

 

${str}   Get Matching Xpath Count     //table[@class="layout layoutblod"]/tbody/tr
log ${str}
${str1} Get Matching Xpath Count    xpath=//table[@class="layout layoutblod"]/tbody/tr[1]/td
log ${str1}

注意:参数是XPATH,所以直接写就行,不要写上XPATH=***,否则会报错:

Unable to locate an element with the xpath expression xpath=//table[@class="layout layoutblod"]/tbody/tr[1]/td because of the following error:\n[Exception... "The expression cannot be converted to return the specified type." code: "0" nsresult: "0x805b0034 (TypeError)"