Skip to content

Commit

Permalink
Fixing ability to construct SafariOptions from capabilities object
Browse files Browse the repository at this point in the history
  • Loading branch information
barancev committed Dec 1, 2017
1 parent a977b8e commit a67f880
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
26 changes: 22 additions & 4 deletions java/client/src/org/openqa/selenium/safari/SafariOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ SafariOptions setPort(int port) {
*/
public SafariOptions useCleanSession(boolean useCleanSession) {
options.put(Option.CLEAN_SESSION, useCleanSession);
setCapability(Option.CLEAN_SESSION, useCleanSession);
return this;
}

Expand All @@ -165,15 +164,34 @@ public SafariOptions setUseCleanSession(boolean useCleanSession) {
*
* @param useTechnologyPreview If true, the SafariDriver will use the Safari Technology Preview,
* otherwise will use the release version of Safari.
* @deprecated Create a {@link SafariDriverService} to specify what Safari flavour should be used
* and pass the service instance to a {@link SafariDriver} constructor.
*/
@Deprecated
public SafariOptions setUseTechnologyPreview(boolean useTechnologyPreview) {
options.put(Option.TECHNOLOGY_PREVIEW, useTechnologyPreview);
return this;
}

@Override
public void setCapability(String key, Object value) {
if (Option.TECHNOLOGY_PREVIEW.equals(key)) {
setUseTechnologyPreview(Boolean.valueOf(value.toString()));
} else if (Option.CLEAN_SESSION.equals(key)) {
useCleanSession(Boolean.valueOf(value.toString()));
} else {
super.setCapability(key, value);
}
}

@Override
public void setCapability(String key, boolean value) {
if (Option.TECHNOLOGY_PREVIEW.equals(key)) {
setUseTechnologyPreview(value);
} else if (Option.CLEAN_SESSION.equals(key)) {
useCleanSession(value);
} else {
super.setCapability(key, value);
}
}

public SafariOptions setProxy(Proxy proxy) {
setCapability(CapabilityType.PROXY, proxy);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,13 @@ public void roundTrippingToCapabilitiesAndBackWorks() {
assertEquals(expected, seen);
}

@Test
public void canConstructFromCapabilities() {
SafariOptions options = new SafariOptions(
new ImmutableCapabilities("cleanSession", true, "technologyPreview", true));

assertTrue(options.getUseCleanSession());
assertTrue(options.getUseTechnologyPreview());
}

}

0 comments on commit a67f880

Please sign in to comment.