[英]Could not click on anchor href element using Selenium Java webdriver
下面是 html 代碼:
<a href="javascript:void(0)">
STK10000251
VESUVIUS29
Vesuvius India Ltd
</a>
我寫了以下 xpath:
driver.findElement(By.xpath("//a[contains(text(), 'STK10000251')]")).click();
執行上述語句后,我收到以下錯誤:
線程“主”org.openqa.selenium.StaleElementReferenceException 中的異常:過時元素引用:元素未附加到頁面文檔
我在哪里弄錯了
誘導WebDriverWait
() 並等待elementToBeClickable
()
WebDriverWait wait = new WebDriverWait(driver, 20);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//a[contains(text(), 'STK10000251')]")));
element.click();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.