How to find specific lines in a table using Selenium?
you can try following
int index = 0;WebElement baseTable = driver.findElement(By.className("table gradient myPage"));List<WebElement> tableRows = baseTable.findElements(By.tagName("tr"));tableRows.get(index).getText();
You can also iterate over tablerows to perform any function you want.
You want:
int rowNumber=...;string value = driver.findElement(By.xpath("//div[@id='productOrderContainer']/table/tbody/tr[" + rowNumber +"]/div[id='something']")).getText();
In other words, locate <DIV>
with the id "something" contained within the rowNumber
th <TR>
of the <TABLE>
contained within the <DIV>
with the id "productOrderContainer", and then get its text value (which is what I believe you mean by "get me the value in <div id='something'>
"
if you want to access table cell
WebElement thirdCell = driver.findElement(By.Xpath("//table/tbody/tr[2]/td[1]"));
If you want to access nested table cell -
WebElement thirdCell = driver.findElement(By.Xpath("//table/tbody/tr[2]/td[2]"+//table/tbody/tr[1]/td[2]));
For more details visit this Tutorial