[英]Fastest way to kill NoSuchElementException or any Exception when element is not found in Selenium WebDriver
[英]NoSuchElementException thrown eventhough webdriver found and clicked the element
硒wedriver(eclipse java)找到並單擊了預期的元素,但是測試失敗並拋出NoSuchElementException
。 單擊后,預期頁面正確顯示,為什么測試失敗? 為什么會引發此異常? 有人早些時候經歷過這種異常嗎?
有時,加載html頁面需要花費更長的時間,因為硒無法找到元素,並且會引發NoSuchElementException
。 嘗試將主線程置於睡眠狀態5-10毫秒,然后檢查其是否正常工作。
使用顯式等待,它有助於等待可見元素。 示例:WebDriverWait等待=新的WebDriverWait(webDriver,timeoutInSeconds); wait.until(ExpectedConditions.visibilityOfElementLocated(element)); element.click;
Hope it will works.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.