I am using selenium and I am using xpath in target value .
I have a table and I need to count the number of rows.
For example I have an X path starting from //tr[2]/td/span/input
to //tr[10]/t开发者_StackOverflow中文版d/span/input
. Now I want to count the number of X path count by VerifyXpathCount
.
I need to supply a regex in the Target field of Selenium like //tr[(*)]/td/span/input
I am not able to apply such regex so I need to add some regex.
How do I do this?
int cnt = selenium.getXpathCount("//tr[/td/span/input]");
//to deal with all element
for(int i=0;i<cnt;i++){
String loc = "//tr["+i+"]/td/span/input";
//use loc
}
in case if you want to find unique element than you can use other conditions with //tr[/td/span/input] instead of looping
try //tr[./td/span/input]
or //tr[//td/span/input]
to get/verify xpath count
精彩评论