【发布时间】:2019-07-02 20:03:17
【问题描述】:
for (int i = 0; i < getOptions.size(); i++) {
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
Thread.sleep(2000);
System.out.println("Select Options Name: " + getOptions.get(i).getText());
Select selctValue = new Select(
driver.findElement(By.xpath("//ul/li[1]/div[@class='input-slect-fix-w']/select")));
selctValue.selectByIndex(i); // Size Drop down
Thread.sleep(5000);
log.info("Click on download templates link.");
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("swtemplates")));
wf.clickOnLink(By.id("swtemplates")); // Download link
Thread.sleep(5000);
String getTitleOnPage = new String(driver.getTitle());
Assert.assertFalse(getTitleOnPage.matches("(.*)404(.*)"), "Failed download templates...");
}
步骤:
1.) 在大小下拉列表中选择选项 1 2.) 点击链接(点击从服务器下载文件后) 3.) 在大小下拉列表中选择选项 2 4.) 点击链接(打开“下载多个文件”确认弹出。)
文件无法下载。
【问题讨论】:
-
你可以尝试用同样的方式在 chrome 中接受警报吗?
-
try { // 检查是否存在警报 Alert alert = driver.SwitchTo().Alert(); // 如果存在,则使用警报 alert.Accept(); } catch (NoAlertPresentException ex) { //如果不存在则执行的代码。 }
-
代码能用吗?
-
我已尝试使用 alert.accept 并设置 chrome 选项,但我无法获得解决方案。
-
你能给出其他解决方案吗?
标签: selenium selenium-webdriver selenium-chromedriver