I get the number of pages from an element that the table can display. I then create a loop that will click the next button until the current page element reads the last page.
The problem each time I click the next button selenium is unable realise that I am referring to the new elements that have been loaded. I have tried everything.
string NumberOfPages = driver.FindElement(By.XPath("//*[@id=\"maxCA\"]")).Text;
for (int i=0; i< Int32.Parse(NumberOfPages); i++)
{
driver.FindElement(By.XPath("//*[@id=\"BID_WINDOW_CONTAINER\"]/div[4]/div[3]/span[3]")).Click();
WebDriverWait wait2 = new WebDriverWait(driver, System.TimeSpan.FromSeconds(3));
var ready2 = wait.Until(ExpectedConditions.ElementExists(By.CssSelector(".AUCTION_ITEM")));
Head_W = driver.FindElement(By.CssSelector(".Head_C"));
ScrapeProperties(Head_W);
}
I know what is going on. I am just not sure how to make Selenium realise that I am referring to the new element that has been created rather than the previous element. You can see in my loop I start from the root document so I presume this will capture the new elements instead. The error happens in ScrapeProperties(Head_W);
when I do something like;
IList<IWebElement> AuctionItems = Head_W.FindElements(By.CssSelector(".AUCTION_ITEM")).ToList();
//In a loop I do this;
property.AuctionStatus = AuctionItemElement.FindElement(By.CssSelector("div.AUCTION_STATS > div.ASTAT_MSGB.Astat_DATA")).Text;