element is not clickable at point解決辦法


錯誤Element is not clickable at point (x, y)可能源於不同因素。您可以通過以下任一過程解決它們:

1.由於存在JavaScript或AJAX調用,元素未被點擊

嘗試使用ActionsClass:

WebElement element = driver.findElement(By.id("navigationPageButton"));
Actions actions = new Actions(driver);
actions.moveToElement(element).click().build().perform();

2.元素未被點擊,因為它不在視口

嘗試使用JavascriptExecutor該元素在視口中:

WebElement myelement = driver.findElement(By.id("navigationPageButton"));
JavascriptExecutor jse2 = (JavascriptExecutor)driver;
jse2.executeScript("arguments[0].scrollIntoView()", myelement); 

3.在元素可點擊之前,頁面將被刷新。

在這種情況下,如第4點所述誘導ExplicitWaitWebDriverWait

4.元素存在於DOM中但不可點擊。

在這種情況下, 請將ExplicitWaitExpectedConditions設置elementToBeClickable為可單擊的元素:

WebDriverWait wait2 = new WebDriverWait(driver, 10);
wait2.until(ExpectedConditions.elementToBeClickable(By.id("navigationPageButton")));

5.元素存在但具有臨時疊加。

在這種情況下,ExplicitWait使用 ExpectedConditionsset設置invisibilityOfElementLocated為Overlay是不可見的。

WebDriverWait wait3 = new WebDriverWait(driver, 10);
wait3.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("ele_to_inv")));

6.元素存在但具有永久疊加。

用於JavascriptExecutor直接在元素上發送單擊。

WebElement ele = driver.findElement(By.xpath("element_xpath"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", ele);


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM