Hi Zak,
This is more advanced solution, but you can change your Chrome preferences to download files without a prompt (it means automatically). For this purposes, I use following method instead of WebUI.openBrowser(String page)
public class CustomChromeDriver {
public static void createChromeWebDriverCustomDownload(String downloadPath) {
String projDir = RunConfiguration.getProjectDir()
// add Chrome preferences
HashMap<String, Object> chromePrefs = new HashMap<String, Object>()
chromePrefs.put("download.default_directory", downloadPath)
chromePrefs.put("download.prompt_for_download", false)
// specify path to ChromeDriver
System.setProperty("webdriver.chrome.driver", projDir + "\\Files\\chromedriver.exe")
ChromeOptions options = new ChromeOptions()
options.setExperimentalOption("prefs", chromePrefs)
// create web driver
WebDriver driver = new ChromeDriver(options)
// use your driver instead of default one
DriverFactory.changeWebDriver(driver)
}
}
You can also specify your own download path in method parameter.
Sample usage in test case:
CustomChromeDriver.createChromeWebDriverCustomDownload("C:\\test")
WebUI.navigateToUrl("www.google.com")
// the rest of your test