Download File In Headless Mode

Hello there, I am unable to download file with headless mode. Please help me with the capabilities I can use.

1 Like

Hello Alex, you will need to use the chrome option and to declare the path of directory where user needs to save the file. In LambdaTest machine you need to declare the path of our machines as declare in above capabilities then you can download the file in headless mode. System path need to be change this in mac- '//Users//ltuser//Downloads".

Map<String, Object> prefs = new HashMap<String, Object>(); prefs.put(“download.default_directory”, “C:\Users\ltuser\Downloads”); \for Mac system path should be–> //Users//ltuser//Downloads ChromeOptions caps = new ChromeOptions(); caps.setCapability(“build”, "Your Build Name "); caps.setCapability(“name”, “:your test name”); caps.setCapability(“platform”, “windows 10”); caps.setCapability(“browserName”, “chrome”); caps.setCapability(“version”, “90.0”); caps.setCapability(“headless”, true); caps.setExperimentalOption(“prefs”,prefs);

1 Like