1

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?

User6667769
  • 745
  • 1
  • 7
  • 25
  • a sample of the target html would be helpful. Your current string has two indexers `[1]`, perhaps try removing one or both of those?: `"//*[@id='dp_widgets_simplegrid_Grid_8']/div/div/div/div/div"` – Thymine Jul 30 '18 at 14:25

0 Answers0