selenium - Selenuim xpath each element 5 -
i new in selenuim . use selenuim , xpath selector.i know how element.but how use xpath each element 5?
you can solve in language of choice.
python
for example, in python, extended slicing allows rather simply:
driver.find_elements_by_xpath("//table/tr")[0::5]
you can use position()
function , mod
operator:
//table/tr[position() mod 5 = 0] driver.find_elements_by_xpath("//table/tr[position() mod 5 = 0]")
java
list<webelement> elements=driver.findelements(by.xpath("//tbody/tr[position() mod 5 = 0]")); system.out.println(elements.size()); (webelement element : elements) { system.out.println(element.gettext()); }
Comments
Post a Comment