- Как обрабатывать Excel загрузить всплывающее окно с помощью Selenium WebDriver
Как обрабатывать Excel загрузить всплывающее окно с помощью Selenium WebDriver
Как обрабатывать Excel загрузить всплывающее окно с помощью Selenium WebDriver
Вы должны создать/изменить профиль браузера для автоматической загрузки/сохранения файла первенствовать который появляется при всплытии (или), может использовать класс Robot для обработки всплывающих окон окна.
См How to download any file and save it to the desired location using Selenium Webdriver
Я думаю, что вы ищете что-то вроде этого
//common to all the cases
FirefoxProfile prof = new FirefoxProfile();
//Case:1 - Use this case to set download this code to your browser's default location
//prof.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/zip");
//prof.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;");
//Case:2 - Download file to Desktop
//prof.setPreference("browser.download.folderList", 0);
//prof.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/zip");
//prof.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;");
//Case:3 - Download to custom folder path. Replace d:\\selenium with your Download Location
prof.setPreference("browser.download.dir","D:\\selenium\\");
prof.setPreference("browser.download.folderList", 2);
prof.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/zip");
//Set Preference to not show file download confirmation dialogue using MIME types Of different file extension types.
prof.setPreference("browser.helperApps.neverAsk.saveToDisk",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;"//MIME types Of MS Excel File.
+ "application/pdf;" //MIME types Of PDF File.
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document;" //MIME types Of MS doc File.
+ "text/plain;" //MIME types Of text File.
+ "text/csv"); //MIME types Of CSV File.
//This will work for all cases mentioned above
WebDriver driver = new FirefoxDriver(prof);
driver.get("http://docs.seleniumhq.org/download/");
driver.findElement(By.xpath("//tr[1]/td[4]/a[text()='Download']")).click();