Selenium Webdriver - Fetching Table Data

后端 未结 7 1978
执笔经年
执笔经年 2021-02-04 08:03

I want to fetch data from tables in UI. I know about looping through rows and columns using \"tr\" and \"td\". But the one the table I have is something like this:



        
7条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-04 08:53

    IWebElement table = driver.FindElement(By.Id("id"));
    List allRows = new List (table.FindElements(By.TagName("tr")));
    
    foreach (var Row in allRows)
    {
        List cells = new List( Row.FindElements(By.TagName("td")));
        foreach (var cel in cells)
        {
            string test = cel.Text;
        }
    }
    

提交回复
热议问题