[英]How to scroll down in a dialog box using selenium
In this page, The form includes 2 validations regarding the Privacy Policy part: 在此页面中,该表格包括有关隐私政策部分的2个验证:
I have no problem in checking the checkbox, but i am not able scroll down in the below window: 我在检查复选框时没有问题, 但是无法在以下窗口中向下滚动 :
I have this method to wait till the elements get loaded: 我有这种方法,直到元素被加载:
public void waitForElement(String xPath) {
WebDriverWait wait = new WebDriverWait(driver, 1);
wait.until(ExpectedConditions.elementToBeClickable(By.xpath(xPath)));
}
So, how can i scroll down, and close the window? 那么,如何向下滚动并关闭窗口? I also don't know how should i use my
waitForElement
in this case? 我也不知道在这种情况下我该如何使用我的
waitForElement
?
Here is the repo , it is a very short code. 这是仓库 ,这是一个很短的代码。 You just need to run the
feature
file 您只需要运行
feature
文件
Try below code to scroll modal dialog down: 尝试下面的代码向下滚动模式对话框:
// Wait for modal
WebDriverWait(driver, 5).until(ExpectedConditions.visibilityOfElementLocated(By.id("document-content")));
// Select last child of content div
WebElement element = driver.findElement(By.xpath("//div[@id='document-content']/*[last()]"));
// Scroll to last child node
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.