我正試圖瀏覽頁面上有多個標籤頁的系統,每個標籤頁上都有多個頁面鏈接。我知道這與DOM中刪除的元素有關,但我不確定如何解決這個問題。陳舊的元素引用:元素沒有附加到帶有循環的頁面文檔
//Get all the elements in the top tab section
IList<IWebElement> tabIndex = driver.FindElements(By.XPath("//*[@class='TabList ClearFix']//a[@tabindex=-1]"));
//The first page of the frist tab is already accessed
//Get all the page links that are in the left navigation bar, click on the page and then move onto the next one
//Once the last page is accessed, move to the next tab and repeat.
foreach (IWebElement element in tabIndex)
{
Console.WriteLine(element.Text.ToString());
IList<IWebElement> leftIndex = driver.FindElements(By.XPath("//*[@id='LeftMenu']//a[@tabindex=-1]"));
foreach (IWebElement lElement in leftIndex)
{
Console.WriteLine(lElement.Text.ToString());
}
element.Click();
}
,我發現了例外的:Console.WriteLine(element.Text.ToString());
任何幫助將不勝感激。
什麼是例外? – FortyTwo
@Forty Two:OpenQA.Selenium.StaleElementReferenceException:陳舊的元素引用:元素沒有附加到頁面文檔 – Derpafox