I am trying to download a file from a web app ( using chrome and chromedriver )
I need to verify the file has been downloaded or not in the test.
So I customize chrome driver to automatically download the file in a particular location , programatically , so that code can go there and check.
I know we can do Project > Desired Capabilities > Web UI > Chrome > and add capabilities
and add prefs download.default_directory
but this will be a fixed location in the system
as the code can run in any other machine , i set this programatically as below to always consider a relative path to the project directory
ChromeDriver driver ;
HashMap<String, Object> chromePrefs = new HashMap<String, Object>(); chromePrefs.put("download.default_directory", "local_directory/downloadPath"); ChromeOptions options = new ChromeOptions(); options.setExperimentalOption("prefs", chromePrefs); DesiredCapabilities cap = DesiredCapabilities.chrome(); cap.setCapability(ChromeOptions.CAPABILITY, options); driver = new ChromeDriver(cap); driver.manage().timeouts().implicitlyWait(GlobalVariable.globalWaitTime, TimeUnit.SECONDS); DriverFactory.changeWebDriver(driver);
Here am creating new driver instance and passing that to Katalone webdriver.
but when a file download action happens, by clicking on a link or a button … the file download is always getting errored out
as in the attached picture
Katalone version : 6.2.1 build 2
Google Chrome : 75.0.3770.100
I think this was working in the earlier versions of Katalon