Open NidhiBawankule24 opened 2 years ago
i assume you mean you are downloading with the web browser. you basically have to set some webdriver properties, like shown here https://stackoverflow.com/a/34530160/1359903
String downloadFilepath = "/path/to/download";
HashMap<String, Object> chromePrefs = new HashMap<String, Object>();
chromePrefs.put("profile.default_content_settings.popups", 0);
chromePrefs.put("download.default_directory", downloadFilepath);
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", chromePrefs);
DesiredCapabilities cap = DesiredCapabilities.chrome();
cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
cap.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new ChromeDriver(cap);
in serenity you can set some chrome options in your serenity.properties file, but i unfortunately have no example how that would look like
hi @globalworming, I'm wondering how to verify if file has been downloaded by click on the button if there is no href attribute present. Any tips?
when your browser is running locally (so no grid, browser stack, etc) you can just use the java file api to check
see Files.list(Paths.get("/path/to/download"))
there is probably a reliable file name to look for?
when your browser is running remotely... then you can maybe use selenium4 network interception features to check if a request to download a file has been sent
thanks @globalworming , I'm using grid & unfortunately in my situation ONLY file content is returned by some api but file is created and returned by JS script. Any ideas?
no
I want ,if I am downloading file it should be downloaded in specific folder.