无法单击按钮org.openqa.selenium.WebDriverException:</button>在点(502,85)不可单击。其他元素将收到点击:



我正在使用Angular Js应用程序。以及使用硒和Java进行交配。每当我尝试点击按钮时,将异常作为.

Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Element <button .</button> is not clickable at point (502, 85). Other element would receive the click: <div class="col-sm-12 move-buttons">...</div>

尝试了很多选择,但都没有成功。欢迎任何解决方案。提前感谢。!!这是看起来像的div

<div class="col-sm-1">
<div class="row zhide-buttons" xpath="1"> 
<div class="col-sm-12 move-buttons"> 
class="btn btn-primary move-button ng-scope" ng-disabled=""> <i class="fa fa-plus fa-2x"></i> </button><!-- end ngIf: 
<i class="fa fa-minus fa-2x"></i> </button>
</div> 
</div>

我尝试与xpath一起使用1.//div[contains(@class,'co-sm-1'(]//button[1]2.//i[@class='fa fa加fa-2x']3.使用动作类使用x,y坐标

wait.till(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[contains(@class,'cl-sm-1'(]//button[1]"((;

这是我的示例代码

WebElement element= driver.findElement(By.xpath("//div[contains(@class,'col-sm-1')]//button[1]"));
js.executeScript("arguments[0].scrollIntoView(true);",element);
js.executeScript("arguments[0].click();", element); 

我还尝试了普通的定位元素并点击它。这也会产生同样的错误。

所以最终我无法点击此按钮

您是否尝试过使用Action class-

WebElement element = driver.findElement(By("element"));
Actions action = new Actions(driver);
action.moveToElement(element).click().perform();

WebElement elementToClick = driver.findElement(By.xpath("Your xpath"));((JavascriptExecutor)driver).executeScript("window.scrollTo("+elementToClick.getLocation().x+","+elementToClick.getLocation().y+")"); elementToClick.click();

WebDriverWait wait = new WebDriverWait(driver, TIME_IN_SECONDS);
wait.until(ExpectedConditions.elementToBeClickable(By.className("element-class-name")));

最新更新