C# 使用c收集表webdriver中的所有div id#

C# 使用c收集表webdriver中的所有div id#,c#,selenium,C#,Selenium,方法是使用id=“tblRenewalAgent”在表中查找所有div元素(具有id属性),并使用GetAttribute获取id属性值 如果您想使用: IList all=driver.FindElements(By.CssSelector(“table#tblrenewalgagent div[id]”); List id=all.Select(iw=>iw.GetAttribute(“id”); 方法是使用id=“tblRenewalAgent”在表中查找所有div元素(具有id属性),并


方法是使用
id=“tblRenewalAgent”
表中查找所有
div
元素(具有
id
属性),并使用
GetAttribute
获取id属性值

如果您想使用:

IList all=driver.FindElements(By.CssSelector(“table#tblrenewalgagent div[id]”);
List id=all.Select(iw=>iw.GetAttribute(“id”);

方法是使用
id=“tblRenewalAgent”
表中查找所有
div
元素(具有
id
属性),并使用
GetAttribute
获取id属性值

如果您想使用:

IList all=driver.FindElements(By.CssSelector(“table#tblrenewalgagent div[id]”);
List id=all.Select(iw=>iw.GetAttribute(“id”);

要检索所有div id的使用,可以使用以下xpath:

By.xpath("//table[@id='tblRenewalAgent']/tr[1]/td[1]");
将所有div元素id列表存储在一个列表中。使用以下代码:

IList<IWebElement> allDivElements = driver.findElements(By.xpath("//table[@id='tblRenewalAgent']/tr[1]/td[1]"));
for(int i=0; i < allDivElements.size(); i++){
     //here the print statement will print the value of each div tag element
     print("Value of ID= "+allDivElements.get(i).getAttribute("id"));
}
IList allDivElements=driver.findElements(By.xpath(//table[@id='tblRenewalAgent']]/tr[1]/td[1]”);
对于(int i=0;i
要检索所有div id的使用,可以使用以下xpath:

By.xpath("//table[@id='tblRenewalAgent']/tr[1]/td[1]");
将所有div元素id列表存储在一个列表中。使用以下代码:

IList<IWebElement> allDivElements = driver.findElements(By.xpath("//table[@id='tblRenewalAgent']/tr[1]/td[1]"));
for(int i=0; i < allDivElements.size(); i++){
     //here the print statement will print the value of each div tag element
     print("Value of ID= "+allDivElements.get(i).getAttribute("id"));
}
IList allDivElements=driver.findElements(By.xpath(//table[@id='tblRenewalAgent']]/tr[1]/td[1]”);
对于(int i=0;i
最好的方法

IList<IWebElement> divCollection = driver.FindElement(By.Id("tblRenewalAgent")).FindElements(By.TagName("div"));
IList divCollection=driver.FindElement(按.Id(“tblRenewalAgent”)).FindElements(按.TagName(“div”));
最好的方法

IList<IWebElement> divCollection = driver.FindElement(By.Id("tblRenewalAgent")).FindElements(By.TagName("div"));
IList divCollection=driver.FindElement(按.Id(“tblRenewalAgent”)).FindElements(按.TagName(“div”));