开发者

How to achieve target Field with regex in selenium

开发者 https://www.devze.com 2023-04-11 04:34 出处:网络
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.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号