Selenium“元素在点”不可点击“错误在Firefox [英] Selenium "Element is not clickable at point" error in Firefox

查看:179
本文介绍了Selenium“元素在点”不可点击“错误在Firefox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于Webdriver错误

 元素在点(X,Y)不可点击。另一个元素会接受点击。 

对于ChromeDriver,在调试元素在点上不可点击错误,然而这个问题也可能发生在Firefox中。



在FirefoxDriver中发生这种情况的最好方法是什么?

解决方案

在以下情况下会发生这种情况 -
$ b


  • 当元素被加载到DOM中,但是在UI上的位置不是
    。可以有一些其他的div或者图片不是
    完全加载的。
  • 页面在点击元素前被刷新。




  • 解决方法


    • 使用线程.sleep在用户界面中的每个Web元素的操作之前,但它是
      不是一个好主意。
    • 使用WebDriverWait ExpectedConditions。


    我面临同样的问题,页面加载时间更多,加载图标在整个网页上重叠。



    为了解决这个问题,我实现了WebDriverWait ExpectedConditions,它在执行一个元素的点击动作之前等待加载图标消失。



    在执行一个动作之前调用这个函数使用数据驱动框架)

    pre $ public $ waitForLoader()抛出异常{
    try {
    String ObjectArray [ ] = ObjectReader.getObjectArray( LoadingIcon);
    if(checkElementDisplayed(ObjectArray [3],ObjectArray [2]))
    {
    WebDriverWait wait = new WebDriverWait(remotewebdriver,10);
    wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath(ObjectArray [3])));

    } catch(NoSuchElementException e){
    System.out.println(The page is loaded successfully);
    }
    }


    In regards to the Webdriver error

    Element is not clickable at point (X, Y). Another element would recieve the click instead.
    

    For ChromeDriver, this is addressed at Debugging "Element is not clickable at point" error, however the issue can occur in Firefox as well.

    What are the best ways to resolve this when it occurs in FirefoxDriver?

    解决方案

    This happens in the below cases-

    • When the element is loaded into the DOM, but the position is not fixed on the UI. There can be some other div or images that are not loaded completely.

    • The page is getting refreshed before it is clicking the element.

    Workaround

    • Use Thread.sleep before actions on each web element in UI, but it is not a good idea.
    • Use WebDriverWait ExpectedConditions.

    I was facing the same issue, the page load time was more and a loading icon was overlapping on entire web page.

    To fix it, I have implemented WebDriverWait ExpectedConditions, which waits for the loading icon to disappear before performing click action on an element

    Call this function before performing an action (I am using data driven framework)

    public void waitForLoader () throws Exception  {
      try {
       String ObjectArray[]=ObjectReader.getObjectArray("LoadingIcon"); 
        if(checkElementDisplayed(ObjectArray[3],ObjectArray[2]))
        {
         WebDriverWait wait = new WebDriverWait(remotewebdriver,10); 
         wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath(ObjectArray[3])));
        }
       } catch (NoSuchElementException e) {
       System.out.println("The page is loaded successfully");
       }
      }
    

    这篇关于Selenium“元素在点”不可点击“错误在Firefox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆