如何处理使用selenium webdriver(JAVA)在chrome中弹出“下载多个文件”确认?

时间:2016-12-28 06:57:13

标签: selenium selenium-webdriver selenium-chromedriver

View image of description...

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.)单击链接(弹出“下载多个文件”确认弹出。)

文件无法下载。

1 个答案:

答案 0 :(得分:0)

尝试https://stackoverflow.com/a/36821119/8731685解决方案。它为我工作。 chrome偏好设置下面的行删除了“多个下载”对话框,并下载了所有文件。

chromePrefs.put("profile.content_settings.exceptions.automatic_downloads.*.setting", 1 );