Skip to content

Commit

Permalink
Apparently the Safari tech preview has a different browser name
Browse files Browse the repository at this point in the history
Who knew? Also, we need to find how to set capabilities in a w3c
compliant way.
  • Loading branch information
shs96c committed Jul 13, 2018
1 parent 4c93795 commit 0efc0be
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.openqa.selenium.safari;

import static org.openqa.selenium.remote.CapabilityType.BROWSER_NAME;

import com.google.common.collect.ImmutableSortedMap;

import org.openqa.selenium.Capabilities;
Expand Down Expand Up @@ -60,7 +62,7 @@ private interface Option {

public SafariOptions() {
setUseTechnologyPreview(false);
setCapability(CapabilityType.BROWSER_NAME, "safari");
setCapability(BROWSER_NAME, "safari");
}

public SafariOptions(Capabilities source) {
Expand Down Expand Up @@ -118,6 +120,7 @@ public static SafariOptions fromCapabilities(Capabilities capabilities)
*/
public SafariOptions setUseTechnologyPreview(boolean useTechnologyPreview) {
options.put(Option.TECHNOLOGY_PREVIEW, useTechnologyPreview);
setCapability(BROWSER_NAME, useTechnologyPreview ? "Safari Technology Preview" : "safari");
return this;
}

Expand Down
12 changes: 12 additions & 0 deletions java/client/test/org/openqa/selenium/safari/SafariOptionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,16 @@ public void canConstructFromCapabilities() {
assertTrue(options.getUseTechnologyPreview());
}

@Test
public void settingTechnologyPreviewModeAlsoChangesBrowserName() {
SafariOptions options = new SafariOptions();
assertEquals("safari", options.getBrowserName());

options.setUseTechnologyPreview(true);
assertEquals("Safari Technology Preview", options.getBrowserName());

options.setUseTechnologyPreview(false);
assertEquals("safari", options.getBrowserName());
}
}

0 comments on commit 0efc0be

Please sign in to comment.