Skip to content

Commit

Permalink
Add android options to FirefoxOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Sep 30, 2021
1 parent cb0e615 commit 73807b6
Showing 1 changed file with 54 additions and 1 deletion.
55 changes: 54 additions & 1 deletion java/src/org/openqa/selenium/firefox/FirefoxOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ private void mirror(FirefoxOptions that) {
this.legacy = that.legacy;
}

/**
* Configures the following:
* <dl>
* <dt>Binary</dt>
* <dd>{@code webdriver.firefox.bin} - the path to the firefox binary</dd>
*
* <dt>Firefox profile</dt>
* <dd>{@code webdriver.firefox.profile} - a named firefox profile</dd>
* </dl>
*/
public FirefoxOptions configureFromEnv() {
// Read system properties and use those if they are set, allowing users to override them later
// should they want to.
Expand Down Expand Up @@ -280,6 +290,31 @@ public FirefoxOptions setHeadless(boolean headless) {
return setFirefoxOption(Keys.ARGS, Collections.unmodifiableList(newArgs));
}

public FirefoxOptions setAndroidPackage(String androidPackage) {
Require.nonNull("Android package", androidPackage);
return setFirefoxOption("androidPackage", androidPackage);
}

public FirefoxOptions setAndroidActivity(String activity) {
Require.nonNull("Android activity", activity);
return setFirefoxOption("androidActivity", activity);
}

public FirefoxOptions setAndroidDeviceSerialNumber(String serial) {
Require.nonNull("Android device serial number", serial);
return setFirefoxOption("androidDeviceSerial", serial);
}

public FirefoxOptions setAndroidIntentArguments(String[] args) {
Require.nonNull("Android intent arguments", args);
return setAndroidIntentArguments(Arrays.asList(args));
}

public FirefoxOptions setAndroidIntentArguments(List<String> args) {
Require.nonNull("Android intent arguments", args);
return setFirefoxOption("androidIntentArguments", args);
}

@Override
public void setCapability(String key, Object value) {
Require.nonNull("Capability name", key);
Expand Down Expand Up @@ -326,8 +361,15 @@ public void setCapability(String key, Object value) {
}

private FirefoxOptions setFirefoxOption(Keys key, Object value) {
return setFirefoxOption(key.key(), value);
}

private FirefoxOptions setFirefoxOption(String key, Object value) {
Require.nonNull("Key", key);
Require.nonNull("Value", value);

Map<String, Object> newOptions = new TreeMap<>(firefoxOptions);
newOptions.put(key.key(), value);
newOptions.put(key, value);
firefoxOptions = Collections.unmodifiableMap(newOptions);
return this;
}
Expand Down Expand Up @@ -374,6 +416,17 @@ public FirefoxOptions merge(Capabilities capabilities) {
}

private enum Keys {
ANDROID_PACKAGE("androidPackage") {
@Override
public void amend(Map<String, Object> sourceOptions, Map<String, Object> toAmend) {

}

@Override
public Object mirror(Map<String, Object> first, Map<String, Object> second) {
return null;
}
},
ARGS("args") {
@Override
public void amend(Map<String, Object> sourceOptions, Map<String, Object> toAmend) {
Expand Down

0 comments on commit 73807b6

Please sign in to comment.