Skip to content

Commit 914207e

Browse files
committed
Refactoring constructor that accepts FirefoxProfile
1 parent 418d591 commit 914207e

File tree

3 files changed

+36
-16
lines changed

3 files changed

+36
-16
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public FirefoxDriver(FirefoxBinary binary) {
148148
}
149149

150150
public FirefoxDriver(FirefoxProfile profile) {
151-
this(new FirefoxBinary(), profile);
151+
this(new FirefoxOptions().setProfile(profile));
152152
}
153153

154154
public FirefoxDriver(Capabilities desiredCapabilities) {

java/client/test/org/openqa/selenium/firefox/FirefoxDriverTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ public void canStartDriverWithSpecifiedBinary() throws IOException {
9696
verify(binary).startFirefoxProcess(any());
9797
}
9898

99+
@Test
100+
public void canStartDriverWithSpecifiedProfile() throws IOException {
101+
FirefoxProfile profile = new FirefoxProfile();
102+
profile.setPreference("browser.startup.page", 1);
103+
profile.setPreference("browser.startup.homepage", pages.xhtmlTestPage);
104+
localDriver = new FirefoxDriver(profile);
105+
wait.until($ -> "XHTML Test Page".equals(localDriver.getTitle()));
106+
verifyItIsLegacy(localDriver);
107+
}
108+
99109
private static class ConnectionCapturingDriver extends FirefoxDriver {
100110
public ExtensionConnection keptConnection;
101111

java/client/test/org/openqa/selenium/firefox/MarionetteTest.java

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,46 +37,56 @@
3737
@Ignore(FIREFOX)
3838
public class MarionetteTest extends JUnit4TestBase {
3939

40-
private FirefoxDriver driver;
40+
private FirefoxDriver localDriver;
4141

4242
@After
4343
public void quitDriver() {
44-
if (driver != null) {
45-
driver.quit();
44+
if (localDriver != null) {
45+
localDriver.quit();
4646
}
4747
}
4848

4949
@Test
5050
public void canStartDriverWithEmptyOptions() {
51-
driver = new FirefoxDriver(new FirefoxOptions());
52-
verifyItIsMarionette(driver);
51+
localDriver = new FirefoxDriver(new FirefoxOptions());
52+
verifyItIsMarionette(localDriver);
5353
}
5454

5555
@Test
5656
public void canStartDriverWithNoParameters() {
57-
driver = new FirefoxDriver();
58-
verifyItIsMarionette(driver);
57+
localDriver = new FirefoxDriver();
58+
verifyItIsMarionette(localDriver);
5959
}
6060

6161
@Test
6262
public void canStartDriverWithSpecifiedBinary() throws IOException {
6363
FirefoxBinary binary = spy(new FirefoxBinary());
64-
driver = new FirefoxDriver(binary);
65-
verifyItIsMarionette(driver);
64+
localDriver = new FirefoxDriver(binary);
65+
verifyItIsMarionette(localDriver);
6666
verify(binary, atLeastOnce()).getPath();
6767
verify(binary, never()).startFirefoxProcess(any());
6868
}
6969

70+
@Test
71+
public void canStartDriverWithSpecifiedProfile() throws IOException {
72+
FirefoxProfile profile = new FirefoxProfile();
73+
profile.setPreference("browser.startup.page", 1);
74+
profile.setPreference("browser.startup.homepage", pages.xhtmlTestPage);
75+
localDriver = new FirefoxDriver(profile);
76+
wait.until($ -> "XHTML Test Page".equals(localDriver.getTitle()));
77+
verifyItIsMarionette(localDriver);
78+
}
79+
7080
@Test
7181
public void shouldUseFirefoxOptions() throws InterruptedException {
7282
DesiredCapabilities caps = new FirefoxOptions()
7383
.addPreference("browser.startup.page", 1)
7484
.addPreference("browser.startup.homepage", pages.xhtmlTestPage)
7585
.addTo(DesiredCapabilities.firefox());
7686

77-
driver = new FirefoxDriver(caps);
87+
localDriver = new FirefoxDriver(caps);
7888

79-
wait.until($ -> "XHTML Test Page".equals(driver.getTitle()));
89+
wait.until($ -> "XHTML Test Page".equals(localDriver.getTitle()));
8090
}
8191

8292
@Test
@@ -88,9 +98,9 @@ public void canSetProfileInFirefoxOptions() throws InterruptedException {
8898
DesiredCapabilities caps = new FirefoxOptions().setProfile(profile)
8999
.addTo(DesiredCapabilities.firefox());
90100

91-
driver = new FirefoxDriver(caps);
101+
localDriver = new FirefoxDriver(caps);
92102

93-
wait.until($ -> "XHTML Test Page".equals(driver.getTitle()));
103+
wait.until($ -> "XHTML Test Page".equals(localDriver.getTitle()));
94104
}
95105

96106
@Test
@@ -102,9 +112,9 @@ public void canSetProfileInCapabilities() throws InterruptedException {
102112
DesiredCapabilities caps = new DesiredCapabilities();
103113
caps.setCapability(FirefoxDriver.PROFILE, profile);
104114

105-
driver = new FirefoxDriver(caps);
115+
localDriver = new FirefoxDriver(caps);
106116

107-
wait.until($ -> "XHTML Test Page".equals(driver.getTitle()));
117+
wait.until($ -> "XHTML Test Page".equals(localDriver.getTitle()));
108118
}
109119

110120
private void verifyItIsMarionette(FirefoxDriver driver) {

0 commit comments

Comments
 (0)