您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

selenium:元素不可点击

selenium:元素不可点击

请仔细阅读此堆栈溢出答案以更好地理解。@H_404_1@

我们也可以尝试@H_404_1@

There are many Conditions that we can use withing Webdriver tests.

1. visibilityOf(WebElement element) : An expectation for checking that an element, kNown 
to be present on the DOM of a page, is visible.
2. visibilityOfElementLocated(By locator) : An expectation for checking that an element 
is present on the DOM of a page and visible.

In the above two conditions we are waiting for an element to be present on the DOM 
of a page and also visible. These works fine only when the element is loaded completely.

也请尝试如下@H_404_1@

尝试使用Y坐标单击@H_404_1@

WebElement elementToClick = driver.findElement(By.xpath("Your xpath"));
// Scroll the browser to the element's Y position
((JavascriptExecutor)driver).executeScript("window.scrollTo(0,"+elementToClick.getLocation().y+")");
// Click the element
elementToClick.click();

尝试使用X坐标单击@H_404_1@

WebElement elementToClick = driver.findElement(By.xpath("Your xpath"));
// Scroll the browser to the element's X position
((JavascriptExecutor)driver).executeScript("window.scrollTo(0,"+elementToClick.getLocation().x+")");
// Click the element
elementToClick.click();

希望这对您有帮助@H_404_1@

其他 2022/1/1 18:15:53 有430人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶