How to get text from each cell of an HTML table?

前端 未结 6 1862
渐次进展
渐次进展 2020-12-13 03:15

In Selenium 2.0, I have no idea how to traverse through a HTML table in a webpage. In selenium2.0 javadoc, I found two classes \"TableFinder\" and \"TableCellFinder\", but

6条回答
  •  醉话见心
    2020-12-13 03:33

    Another C# example. I just made an extension method for it.

    public static string GetCellFromTable(this IWebElement table, int rowIndex, int columnIndex)
        {
            return table.FindElements(By.XPath("./tbody/tr"))[rowIndex].FindElements(By.XPath("./td"))[columnIndex].Text;
        }
    

提交回复
热议问题