Skip to content

Commit

Permalink
ReflectionBackendDriverSupplier: two arguments Capabilities
Browse files Browse the repository at this point in the history
This allows ReflectionBackendDriverSupplier to check
if the driver class has a constructor with two
Capabilities, and if so it is called, otherwise
the single Capabilities constructor is used.

Signed-off-by: Luke Inman-Semerau <[email protected]>
  • Loading branch information
asashour authored and lukeis committed Aug 22, 2015
1 parent 409699b commit 4d94ba0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ public HtmlUnitDriver(Capabilities capabilities) {
setProxySettings(Proxy.extractFrom(capabilities));
}

public HtmlUnitDriver(Capabilities desiredCapabilities, Capabilities requiredCapabilities) {
this(new DesiredCapabilities(desiredCapabilities, requiredCapabilities));
}

// Package visibility for testing
static BrowserVersion determineBrowserVersion(Capabilities capabilities) {
String browserName = null;
Expand Down
2 changes: 0 additions & 2 deletions java/client/test/org/openqa/selenium/ProxySettingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ public void canUsePACThatOnlyProxiesCertainHosts() throws Exception {
}

@Ignore({CHROME, IE, PHANTOMJS, REMOTE, SAFARI})
@NotYetImplemented(HTMLUNIT)
@NeedsLocalEnvironment
@Test
public void canConfigureProxyWithRequiredCapability() {
Expand All @@ -179,7 +178,6 @@ public void canConfigureProxyWithRequiredCapability() {
}

@Ignore({CHROME, IE, PHANTOMJS, REMOTE, SAFARI})
@NotYetImplemented(HTMLUNIT)
@NeedsLocalEnvironment
@Test
public void requiredProxyCapabilityShouldHavePriority() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public HtmlUnitDriverForTest(Capabilities capabilities) {
super(tweak(capabilities));
}

public HtmlUnitDriverForTest(Capabilities desiredCapabilities, Capabilities requiredCapabilities) {
super(tweak(desiredCapabilities), tweak(requiredCapabilities));
}

private static Capabilities tweak(Capabilities capabilities) {
DesiredCapabilities caps = new DesiredCapabilities(capabilities);
caps.setJavascriptEnabled(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,14 @@ public WebDriver get() {
Capabilities.class).newInstance(desiredCapsToUse, requiredCapabilities);
}

//TODO: Call constructor with two Capabilities arguments for all driver classes
try {
return driverClass.getConstructor(Capabilities.class,
Capabilities.class).newInstance(desiredCapsToUse, requiredCapabilities);
} catch (NoSuchMethodException e) {
// ignore
}

//TODO: All driver classes to have two Capabilities arguments
return driverClass.getConstructor(Capabilities.class).newInstance(desiredCapsToUse);
} catch (InvocationTargetException e) {
throw Throwables.propagate(e.getTargetException());
Expand Down

0 comments on commit 4d94ba0

Please sign in to comment.