java - Selenium WebDriver - how to get elements of tables and iterate through rows -
i want iterate tables per row, in test scenario data each rows. done using absolute xpath. there better/alternative way other using absolute xpath iterating through these rows?
this logic of code before:
private static int irow;
webelement sworkunitrows = null;
for (irow = 1; irow <= 10; irow++) {
sworkunitquery = driver.findelement(by.xpath("html/body/div[2]/div[4]/div/div/div[3]/div[1]/table/tbody/tr["+ irow + "]/td[5]/div"));
// actions here, click , verify data each rows until finds specific data
break;
}
any ideas this? highly appreciate inputs thanks!
you can use findelements(...)
instead of findelement(...)
.
here example:
list<webelement> elements = driver.findelements(by.xpath(".//*/tr/td[5]/div")); for(webelement element:elements){ ... }
this return list of div
s located in 5th column of each row.
Comments
Post a Comment