我正在尝试使用基于selenium的Katalon Studio进行一些测试。在我的一项测试中,我必须在文本区域内编写。问题是我得到以下错误:
...Element MyElement is not clickable at point (x, y)... Other element would receive the click...
实际上,我的元素放置在其他可能隐藏它的diva里面,但是如何使click事件击中我的textarea?
Element ... is not clickable at point (x, y). Other element would receive the click"可能是由于不同的因素造成的。您可以通过以下任一过程解决它们:
Element ... is not clickable at point (x, y). Other element would receive the click"
尝试使用ActionsClass:
Actions
WebElement element = driver.findElement(By.id("id1")); Actions actions = new Actions(driver); actions.moveToElement(element).click().build().perform();
尝试用于JavascriptExecutor将元素带入视口中:
JavascriptExecutor
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);
在这种情况下诱发一些wait。
wait
在这种情况下ExplicitWait,请为元素添加一些可单击的元素。
ExplicitWait
WebDriverWait wait2 = new WebDriverWait(driver, 10); wait2.until(ExpectedConditions.elementToBeClickable(By.id("id1")));
在这种情况下, ExplicitWait 使用 ExpectedConditions 设置 invisibilityOfElementLocated 为会使叠加层不可见。
ExpectedConditions
invisibilityOfElementLocated
WebDriverWait wait3 = new WebDriverWait(driver, 10); wait3.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("ele_to_inv")));
用于JavascriptExecutor直接在元素上发送点击。
WebElement ele = driver.findElement(By.xpath("element_xpath")); JavascriptExecutor executor = (JavascriptExecutor)driver; executor.executeScript("arguments[0].click();", ele);