zoukankan      html  css  js  c++  java
  • element is not clickable at point解决办法

    使用selenium控制chrome点击某一按钮时,总是报错:Element is not clickable at point ,使用下面的方法解决,主要用了方法2和方法6.

    原文链接:https://www.cnblogs.com/onlyblog/p/10522849.html

    错误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);
  • 相关阅读:
    DRY原则和Shy原则
    GEO LBS服务
    Intellij IDEA转换类图、时序图
    使用HttpMessageConverter实现HTTP的序列化和反序列化
    通过@Valid注解对请求主体中的参数进行校验
    Java-Enumeration ( 枚举类)
    SPI的实现原理
    python批量获取gitlab里面所有项目的代码
    浙江省高等学校教师教育理论培训上机考试小程序设计架构
    springboot~使用freemaker模版进行部署
  • 原文地址:https://www.cnblogs.com/djlbolgs/p/12506252.html
Copyright © 2011-2022 走看看