Skip to content

Commit

Permalink
Added chromeoptions for auto download.
Browse files Browse the repository at this point in the history
  • Loading branch information
AutomatedOwl committed Nov 15, 2019
1 parent 62782bf commit cb267dd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,6 @@ The method would act exactly the same as described above, just with a custom dow
<dependency>
<groupId>com.github.automatedowl</groupId>
<artifactId>selenium-download-kpi</artifactId>
<version>1.0.2</version>
<version>1.0.3</version>
</dependency>
```
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.automatedowl</groupId>
<artifactId>selenium-download-kpi</artifactId>
<version>1.0.2</version>
<version>1.0.3</version>
<name>${project.groupId}:${project.artifactId}</name>
<description>Selenium extension for Java which provides KPIs of file downloads.</description>
<url>https://github.com/AutomatedOwl</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,35 @@ private static String attachDownloadBandwidth(String message) {

/** @return ChromeOptions object that contained default download folder. */
public ChromeOptions generateDownloadFolderCapability() {
HashMap<String, Object> chromeAdditionalOptions =
new HashMap<>();
chromeAdditionalOptions.put("download.default_directory", downloadFolder);
chromeAdditionalOptions.put("download.prompt_for_download", false);
chromeAdditionalOptions.put("download.directory_upgrade", true);
HashMap<String, Object> CHROME_ADDITIONAL_OPTIONS = new HashMap<String, Object>() {{
put("plugins.plugins_disabled", new String[] {"Chrome PDF Viewer"});
put("download.default_directory", downloadFolder);
put("profile.default_content_setting_values.automatic_downloads", 1);
put("profile.default_content_settings.popups", 0);
}};
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", chromeAdditionalOptions);
options.setExperimentalOption("prefs", CHROME_ADDITIONAL_OPTIONS);
return options;
}

/** @return ChromeOptions object that contained default download folder. */
public static ChromeOptions generateDownloadFolderCapability(String downloadFolder) {
HashMap<String, Object> CHROME_ADDITIONAL_OPTIONS = new HashMap<String, Object>() {{
put("plugins.plugins_disabled", new String[] {"Chrome PDF Viewer"});
put("download.default_directory", downloadFolder);
put("profile.default_content_setting_values.automatic_downloads", 1);
put("profile.default_content_settings.popups", 0);
}};

// Add chromedriver arguments.
ChromeOptions chromeOptions = new ChromeOptions();

// Add chrome additional options.
chromeOptions.setExperimentalOption("prefs", CHROME_ADDITIONAL_OPTIONS);
return chromeOptions;
}


/** Calculate Mbps value from elapsed time and file size. */
private double calculateMbps(long fileSize, long startTime) {
return (double)
Expand Down

0 comments on commit cb267dd

Please sign in to comment.