Skip to content

[java] allow configurations to be used with a browser string value #268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,51 @@ public class SauceOptions extends BaseOptions {
"strictFileInteractability",
"unhandledPromptBehavior");

/**
*
* @param browserName the name of the browser
* @return instance of VDCConfigurations
*/
public static VDCConfigurations buildOptionsFromBrowser(String browserName) {
switch(browserName) {
case "chrome":
return buildOptionsFromBrowser(browserName, new ChromeOptions());
case "edge":
return buildOptionsFromBrowser(browserName, new EdgeOptions());
case "firefox":
return buildOptionsFromBrowser(browserName, new FirefoxOptions());
case "ie":
return buildOptionsFromBrowser(browserName, new InternetExplorerOptions());
case "safari":
return buildOptionsFromBrowser(browserName, new SafariOptions());
default:
throw new IllegalArgumentException("Browser not supported: " + browserName);
}
}

/**
*
* @param browserName the name of the browser
* @param capabilities instance of BrowerOptions corresponding to browser name
* @return instance of VDCConfigurations
*/
public static VDCConfigurations buildOptionsFromBrowser(String browserName, MutableCapabilities capabilities) {
switch(browserName) {
case "chrome":
return SauceOptions.chrome((ChromeOptions) capabilities);
case "edge":
return SauceOptions.edge((EdgeOptions) capabilities);
case "firefox":
return SauceOptions.firefox((FirefoxOptions) capabilities);
case "ie":
return SauceOptions.ie((InternetExplorerOptions) capabilities);
case "safari":
return SauceOptions.safari((SafariOptions) capabilities);
default:
throw new IllegalArgumentException("Browser not supported: " + browserName);
}
}

/**
* This method allows building a default Sauce Options instance for Chrome
* Call build() method on return value rather than using directly
Expand Down