How to find specific lines in a table using Selenium?

前端 未结 6 420
伪装坚强ぢ
伪装坚强ぢ 2021-01-02 09:52

Here is an example code:

So this table being in prod

6条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-02 10:34

    Well previously, I used the approach that you can find inside the WebElement:

    WebElement baseTable = driver.findElement(By.tagName("table"));
    WebElement tableRow = baseTable.findElement(By.xpath("//tr[2]")); //should be the third row
    webElement cellIneed = tableRow.findElement(By.xpath("//td[2]"));
    String valueIneed = cellIneed.getText();
    

    Please note that I find inside the found WebElement instance.

    The above is Java code, assuming that driver variable is healthy instance of WebDriver

提交回复
热议问题