How do I use XPath to find the values of cells in a table
The structure of the Html I need to work with is shown in the screenshots below.
I need to get the values of the first and third column of each data row in the table. There is nothing unique about the rows or cells.
//String CPONEW="//table[@id='GridView1']/tbody/tr['@id!= or @class=!"+j+"']/td";
When I try to use this xpath I only get the first
tr/tdval but I need to get each
tr / tdand
Try the below code:
List tableRows = table.findElements(By.xpath("tr")); List tableCells= table.findElements(By.xpath("tr/td")); tableCells.get(1); tableCells.get(3); //you can assign to String String FirstColumn=tableCells.get(1); System.out.println(FirstColumn); ```