元素 MyElement 在 (x, y) 点不可点击...其他元素会收到点击 [英] Element MyElement is not clickable at point (x, y)... Other element would receive the click

查看:31
本文介绍了元素 MyElement 在 (x, y) 点不可点击...其他元素会收到点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用基于硒的 Katalon Studio 进行一些测试.在我的一项测试中,我必须在 textarea 中写入.问题是我收到以下错误:

I am trying to make some tests using selenium based Katalon Studio. In one of my tests I have to write inside a textarea. The problem is that I get the following error:

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

事实上,我的元素被放置在其他一些可能隐藏它的 Diva 中,但我怎样才能让点击事件命中我的 textarea?

In fact my element is place inside some other diva that might hide it but how can I make the click event hit my textarea?

推荐答案

Element ... is notable at point (x, y).其他元素会收到点击" 可能是由不同的因素引起的.您可以通过以下任一程序来解决这些问题:

Element ... is not clickable at point (x, y). Other element would receive the click" can be caused for different factors. You can address them by either of the following procedures:

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

尝试使用 Actions 类:

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

  1. 元素没有被点击,因为它不在 视口

尝试使用 JavascriptExecutor 将元素带入视口:

Try to use JavascriptExecutor to bring the element within Viewport:

JavascriptExecutor jse1 = (JavascriptExecutor)driver;
jse1.executeScript("scroll(250, 0)"); // if the element is on top.
jse1.executeScript("scroll(0, 250)"); // if the element is at bottom.

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

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

在这种情况下会引起一些wait.

In this case induce some wait.

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

在这种情况下,添加一些 ExplicitWait 以使元素可点击.

In this case add some ExplicitWait for the element to be clickable.

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

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

在这种情况下,将 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")));

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

使用 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);

这篇关于元素 MyElement 在 (x, y) 点不可点击...其他元素会收到点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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