Selenium“元素不可点击";火狐浏览器中的错误 [英] Selenium "Element is not clickable at point" error in Firefox

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

问题描述

关于 Webdriver 错误

In regards to the Webdriver error

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

对于 ChromeDriver,此问题在 Debugging "Element is not点可点击"错误,但问题也可能出现在 Firefox 中.

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

当它发生在 FirefoxDriver 中时,解决此问题的最佳方法是什么?

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

推荐答案

这发生在以下情况-

  • 当元素被加载到 DOM 中,但是位置没有固定在 UI 上.可能有一些其他 div 或图像不是完全加载.

  • 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.

解决方法

  • 在对 UI 中的每个 Web 元素执行操作之前使用 Thread.sleep,但它是不是一个好主意.
  • 使用 WebDriverWait 预期条件.

我遇到了同样的问题,页面加载时间更长,加载图标在整个网页上重叠.

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

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

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“元素不可点击";火狐浏览器中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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