【发布时间】:2017-04-28 17:18:39
【问题描述】:
在滚动到相关 Web 元素之前,我需要等待页面“弹出叠加”加载。
-
以下代码在定位和滚动到 web 元素时是成功的,但我想避免使用 Thread.sleep。
public void scrollToElementByLocator(WebElement element) throws InterruptedException { Thread.sleep(4000); ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView();", element); ((JavascriptExecutor) driver).executeScript("window.scrollBy(0, -400)");
3.谁能建议另一种方法来等待页面加载,然后在不使用 thread.sleep 的情况下滚动到预期的 web 元素?
非常感谢您的帮助
【问题讨论】:
-
在页面加载时尝试在任何元素上
click()。你应该得到异常,比如element is not clickable at the point ... other element received the click...Show the part of exception withHTMLof element that 实际上收到点击(覆盖目标元素的模态窗口) -
以下链接将满足您的需求stackoverflow.com/questions/15122864/…
标签: java selenium selenium-webdriver webdriver