Handling dynamic div's in selenium

匆匆过客 提交于 2019-12-11 07:57:27

问题


I am using a IWebDriver object.

The Webpage contains dynamic div's. I have used to access the div's(elements) by using Xpath/Id or anything.

So i have tried something like this

List<IWebElement> webElement = chromeDriver.FindElements(By.XPath("//*[@id='dp_widgets_simplegrid_Grid_8']/div/div[1]/div/div[1]/div"));

int rowsSize = webElement.Size();

It gave type casting error.

Cannot convert system.Collections.ObjectModel.ReadOnlyCollection to System.Collections.Generic.List

Then I have tried like below:

IWebElement webElement = chromeDriver.FindElement(By.XPath("//*[@id='dp_widgets_simplegrid_Grid_8']/div/div[1]/div/div[1]/div"));

int rows = webElement.FindElements(By.TagName("div")).Count;

But Still i could not find the list of elements in the dynamic grid.

I want to get the list of div elements . Could anyone give me a little idea about that?

来源:https://stackoverflow.com/questions/51593447/handling-dynamic-divs-in-selenium

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!