• <bdo id='NNkXK'></bdo><ul id='NNkXK'></ul>
    <i id='NNkXK'><tr id='NNkXK'><dt id='NNkXK'><q id='NNkXK'><span id='NNkXK'><b id='NNkXK'><form id='NNkXK'><ins id='NNkXK'></ins><ul id='NNkXK'></ul><sub id='NNkXK'></sub></form><legend id='NNkXK'></legend><bdo id='NNkXK'><pre id='NNkXK'><center id='NNkXK'></center></pre></bdo></b><th id='NNkXK'></th></span></q></dt></tr></i><div id='NNkXK'><tfoot id='NNkXK'></tfoot><dl id='NNkXK'><fieldset id='NNkXK'></fieldset></dl></div>

      <legend id='NNkXK'><style id='NNkXK'><dir id='NNkXK'><q id='NNkXK'></q></dir></style></legend>

        <small id='NNkXK'></small><noframes id='NNkXK'>

        <tfoot id='NNkXK'></tfoot>
      1. Selenium Web 驱动程序爪哇.元素在点 (x, y) 处不可点击.其他元素会收到点击

        时间:2023-07-13

          <i id='kAGy7'><tr id='kAGy7'><dt id='kAGy7'><q id='kAGy7'><span id='kAGy7'><b id='kAGy7'><form id='kAGy7'><ins id='kAGy7'></ins><ul id='kAGy7'></ul><sub id='kAGy7'></sub></form><legend id='kAGy7'></legend><bdo id='kAGy7'><pre id='kAGy7'><center id='kAGy7'></center></pre></bdo></b><th id='kAGy7'></th></span></q></dt></tr></i><div id='kAGy7'><tfoot id='kAGy7'></tfoot><dl id='kAGy7'><fieldset id='kAGy7'></fieldset></dl></div>
            <tbody id='kAGy7'></tbody>
            • <bdo id='kAGy7'></bdo><ul id='kAGy7'></ul>

              • <legend id='kAGy7'><style id='kAGy7'><dir id='kAGy7'><q id='kAGy7'></q></dir></style></legend>

                <tfoot id='kAGy7'></tfoot>

                  <small id='kAGy7'></small><noframes id='kAGy7'>

                  本文介绍了Selenium Web 驱动程序爪哇.元素在点 (x, y) 处不可点击.其他元素会收到点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我使用了显式等待,但我收到了警告:

                  I used explicit waits and I have the warning:

                  org.openqa.selenium.WebDriverException:元素在点 (36, 72) 处不可点击.其他元素将收到点击:...命令持续时间或超时:393 毫秒

                  org.openqa.selenium.WebDriverException: Element is not clickable at point (36, 72). Other element would receive the click: ... Command duration or timeout: 393 milliseconds

                  如果我使用 Thread.sleep(2000) 我不会收到任何警告.

                  If I use Thread.sleep(2000) I don't receive any warnings.

                  @Test(dataProvider = "menuData")
                  public void Main(String btnMenu, String TitleResultPage, String Text) throws InterruptedException {
                      WebDriverWait wait = new WebDriverWait(driver, 10);
                      driver.findElement(By.id("navigationPageButton")).click();
                  
                      try {
                         wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector(btnMenu)));
                      } catch (Exception e) {
                          System.out.println("Oh");
                      }
                      driver.findElement(By.cssSelector(btnMenu)).click();
                      Assert.assertEquals(driver.findElement(By.cssSelector(TitleResultPage)).getText(), Text);
                  }
                  

                  推荐答案

                  WebDriverException: Element is not clickable at point (x, y)

                  这是一个典型的 org.openqa.selenium.WebDriverException 扩展了 java.lang.RuntimeException.

                  这个异常的字段是:

                  • BASE_SUPPORT_URL :受保护的静态最终 java.lang.String BASE_SUPPORT_URL
                  • DRIVER_INFO :public static final java.lang.String DRIVER_INFO
                  • SESSION_ID :public static final java.lang.String SESSION_ID
                  • BASE_SUPPORT_URL : protected static final java.lang.String BASE_SUPPORT_URL
                  • DRIVER_INFO : public static final java.lang.String DRIVER_INFO
                  • SESSION_ID : public static final java.lang.String SESSION_ID

                  关于您的个人用例,错误说明了一切:

                  About your individual usecase, the error tells it all :

                  WebDriverException: Element is not clickable at point (x, y). Other element would receive the click 
                  

                  从您的代码块中可以清楚地看出,您已将 wait 定义为 WebDriverWait wait = new WebDriverWait(driver, 10); 但您正在调用 ExplicitWait 起作用之前元素上的 click() 方法,如 until(ExpectedConditions.elementToBeClickable) 中所示.

                  It is clear from your code block that you have defined the wait as WebDriverWait wait = new WebDriverWait(driver, 10); but you are calling the click() method on the element before the ExplicitWait comes into play as in until(ExpectedConditions.elementToBeClickable).

                  Element is not clickable at point (x, y) 错误可能由不同的因素引起.您可以通过以下任一程序解决它们:

                  The error Element is not clickable at point (x, y) can arise from different factors. You can address them by either of the following procedures:

                  1.由于存在 JavaScript 或 AJAX 调用,元素没有被点击

                  尝试使用 Actions 类:

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

                  <强>2.元素没有被点击,因为它不在 视口

                  尝试使用 JavascriptExecutor 将元素带入 Viewport:

                  Try to use JavascriptExecutor to bring the element within the Viewport:

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

                  3.页面在元素可点击之前被刷新.

                  在这种情况下,诱导 ExplicitWait,即第 4 点中提到的 WebDriverWait.

                  In this case induce ExplicitWait i.e WebDriverWait as mentioned in point 4.

                  4.元素存在于 DOM 中但不可点击.

                  在这种情况下,ExplicitWaitExpectedConditions 设置为 elementToBeClickable 以使元素可点击:

                  In this case induce ExplicitWait with ExpectedConditions set to elementToBeClickable for the element to be clickable:

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

                  5.元素存在但具有临时叠加层.

                  在这种情况下,诱导 ExplicitWait 并将 ExpectedConditions 设置为 invisibilityOfElementLocated 使叠加层不可见.

                  In this case, induce ExplicitWait with ExpectedConditions set to invisibilityOfElementLocated for the Overlay to be invisible.

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

                  6.元素存在但具有永久叠加层.

                  使用 JavascriptExecutor 直接在元素上发送点击.

                  Use JavascriptExecutor to send the click directly on the element.

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

                  这篇关于Selenium Web 驱动程序爪哇.元素在点 (x, y) 处不可点击.其他元素会收到点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                    <tfoot id='kPN4O'></tfoot>

                    <i id='kPN4O'><tr id='kPN4O'><dt id='kPN4O'><q id='kPN4O'><span id='kPN4O'><b id='kPN4O'><form id='kPN4O'><ins id='kPN4O'></ins><ul id='kPN4O'></ul><sub id='kPN4O'></sub></form><legend id='kPN4O'></legend><bdo id='kPN4O'><pre id='kPN4O'><center id='kPN4O'></center></pre></bdo></b><th id='kPN4O'></th></span></q></dt></tr></i><div id='kPN4O'><tfoot id='kPN4O'></tfoot><dl id='kPN4O'><fieldset id='kPN4O'></fieldset></dl></div>
                  1. <legend id='kPN4O'><style id='kPN4O'><dir id='kPN4O'><q id='kPN4O'></q></dir></style></legend>

                    <small id='kPN4O'></small><noframes id='kPN4O'>

                    • <bdo id='kPN4O'></bdo><ul id='kPN4O'></ul>
                            <tbody id='kPN4O'></tbody>