Hi Guys, I’m looking for help, element in this page not found (another page in same web it can)
Test Case Code
table: for (int i = 0; i < Rows.size(); i++) {
List Cols = Rows.get(i).findElements(By.tagName(‘td’))
for (int j = 0; j < Cols.size(); j++) {
println(Cols.get(j).getText())
}
}
Test Case
HTML
--------------------------- another page in the same web it can -------------------
It looks like the text is under the span tag and not the td tag. Perhaps you can try:
table:
for (int i = 0; i < Rows.size(); i++) {
List<WebElement> Cols = Rows.get(i).findElements(By.xpath('//td/span'))
for (int j = 0; j < Cols.size(); j++) {
println(Cols.get(j).getText())
}
}
Hi @grylion54 Thanks for response, sorry maybe my questions is confusing,
I have two example page html that can get element and can’t, html with a span is an example that can (green highlight), another one (yellow highlight) for compare it is html having the problem.
But I got the clue for your suggestion, I should check and read again the html code and it turns out any 2 (Two) table in one page so I change the code from this
WebElement Table = driver.findElement(By.xpath(‘//table/tbody’))
**To this **
WebElement Table = driver.findElement(By.xpath(‘//*[@id=“grid”]’))
and the element of the web table can be obtained (highlight blue)