Skip to content

Commit 92b25ec

Browse files
committed
java: Implementing MarionetteDriver as a separate class (with @beta annotation)
1 parent 01c4f9f commit 92b25ec

File tree

3 files changed

+78
-2
lines changed

3 files changed

+78
-2
lines changed

java/client/src/org/openqa/selenium/firefox/FirefoxDriver.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,9 @@ protected ExtensionConnection connectTo(FirefoxBinary binary, FirefoxProfile pro
301301
FirefoxBinary bin = binary == null ? new FirefoxBinary() : binary;
302302

303303
if (USE_MARIONETTE) {
304-
// System.out.println("************************** Using marionette");
304+
System.out.println(String.format(
305+
"*** Use MarionetteDriver class instead of setting %s property ***",
306+
SystemProperty.DRIVER_USE_MARIONETTE));
305307
return new MarionetteConnection(lock, bin, profile, host);
306308
} else {
307309
return new NewProfileExtensionConnection(lock, bin, profile, host);
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// Licensed to the Software Freedom Conservancy (SFC) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The SFC licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package org.openqa.selenium.firefox;
19+
20+
import org.openqa.selenium.Beta;
21+
import org.openqa.selenium.Capabilities;
22+
import org.openqa.selenium.WebDriverException;
23+
import org.openqa.selenium.firefox.internal.MarionetteConnection;
24+
import org.openqa.selenium.internal.Lock;
25+
26+
/**
27+
* An implementation of the {#link WebDriver} interface that drives Firefox using Marionette interface.
28+
*/
29+
@Beta
30+
public class MarionetteDriver extends FirefoxDriver {
31+
32+
public MarionetteDriver() {
33+
this(new FirefoxBinary(), null);
34+
}
35+
36+
public MarionetteDriver(FirefoxProfile profile) {
37+
super(profile);
38+
}
39+
40+
public MarionetteDriver(Capabilities desiredCapabilities) {
41+
super(desiredCapabilities);
42+
}
43+
44+
public MarionetteDriver(Capabilities desiredCapabilities, Capabilities requiredCapabilities) {
45+
super(desiredCapabilities, requiredCapabilities);
46+
}
47+
48+
public MarionetteDriver(FirefoxBinary binary, FirefoxProfile profile) {
49+
super(binary, profile);
50+
}
51+
52+
public MarionetteDriver(FirefoxBinary binary, FirefoxProfile profile, Capabilities capabilities) {
53+
super(binary, profile, capabilities);
54+
}
55+
56+
public MarionetteDriver(FirefoxBinary binary, FirefoxProfile profile,
57+
Capabilities desiredCapabilities, Capabilities requiredCapabilities) {
58+
super(binary, profile, desiredCapabilities, requiredCapabilities);
59+
}
60+
61+
protected ExtensionConnection connectTo(FirefoxBinary binary, FirefoxProfile profile,
62+
String host) {
63+
Lock lock = obtainLock(profile);
64+
try {
65+
FirefoxBinary bin = binary == null ? new FirefoxBinary() : binary;
66+
67+
return new MarionetteConnection(lock, bin, profile, host);
68+
} catch (Exception e) {
69+
throw new WebDriverException(e);
70+
}
71+
}
72+
}

java/client/test/org/openqa/selenium/testing/drivers/ReflectionBackedDriverSupplier.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ private Class<? extends WebDriver> mapToClass(Capabilities caps) {
130130
}
131131

132132
private String getFirefoxClassName() {
133-
if (isInDevMode()) {
133+
if (Boolean.parseBoolean(System.getProperty(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE))) {
134+
return "org.openqa.selenium.firefox.MarionetteDriver";
135+
} else if (isInDevMode()) {
134136
return "org.openqa.selenium.testing.drivers.SynthesizedFirefoxDriver";
135137
} else {
136138
return "org.openqa.selenium.firefox.FirefoxDriver";

0 commit comments

Comments
 (0)