Skip to content

Commit 5457e21

Browse files
committed
Fix some of the broken tests
1 parent 27ef14f commit 5457e21

File tree

3 files changed

+13
-22
lines changed

3 files changed

+13
-22
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
import java.io.File;
4343
import java.io.IOException;
44+
import java.nio.file.Files;
4445
import java.nio.file.Path;
4546
import java.nio.file.Paths;
4647
import java.util.ArrayList;
@@ -170,7 +171,9 @@ public FirefoxOptions setBinary(Path path) {
170171
// Default to UNIX-style paths, even on Windows.
171172
this.binaryPath = asUnixPath(path);
172173
this.actualBinary = null;
173-
desiredCapabilities.setCapability(BINARY, new FirefoxBinary(path.toFile()));
174+
if (Files.exists(path)) {
175+
desiredCapabilities.setCapability(BINARY, new FirefoxBinary(path.toFile()));
176+
}
174177
return this;
175178
}
176179

@@ -448,7 +451,9 @@ private Capabilities toCapabilities(Capabilities source) {
448451
if (actualBinary != null && binaryPath == null) {
449452
capabilities.setCapability(BINARY, actualBinary);
450453
} else if (binaryPath != null && actualBinary == null) {
451-
capabilities.setCapability(BINARY, new FirefoxBinary(new File(binaryPath)));
454+
if (Files.exists(Paths.get(binaryPath))) {
455+
capabilities.setCapability(BINARY, new FirefoxBinary(new File(binaryPath)));
456+
}
452457
}
453458

454459
Object priorProfile = capabilities.getCapability(PROFILE);

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import static org.junit.Assert.assertThat;
2727
import static org.junit.Assert.assertTrue;
2828
import static org.junit.Assert.fail;
29+
import static org.junit.Assume.assumeNotNull;
2930
import static org.mockito.Matchers.any;
3031
import static org.mockito.Mockito.doThrow;
3132
import static org.mockito.Mockito.mock;
@@ -39,6 +40,7 @@
3940
import com.google.common.base.Throwables;
4041

4142
import org.junit.After;
43+
import org.junit.Assume;
4244
import org.junit.Test;
4345
import org.mockito.Mockito;
4446
import org.openqa.selenium.By;
@@ -343,13 +345,10 @@ public void shouldBeAbleToStartFromProfileWithLogFileSetToStdout() throws IOExce
343345
@Test
344346
public void shouldBeAbleToStartANamedProfile() {
345347
FirefoxProfile profile = new ProfilesIni().getProfile("default");
348+
assumeNotNull(profile);
346349

347-
if (profile != null) {
348-
WebDriver firefox = new FirefoxDriver(profile);
349-
firefox.quit();
350-
} else {
351-
System.out.println("Not running start with named profile test: no default profile found");
352-
}
350+
WebDriver firefox = new FirefoxDriver(profile);
351+
firefox.quit();
353352
}
354353

355354
@Test(timeout = 60000)

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -167,20 +167,7 @@ public void canUseSameProfileInCapabilitiesAndDirectly() {
167167

168168
verifyItIsMarionette(localDriver);
169169
}
170-
171-
@Test
172-
public void cannotUseDifferentProfilesInCapabilitiesAndDirectly() {
173-
DesiredCapabilities caps = new DesiredCapabilities();
174-
caps.setCapability(FirefoxDriver.PROFILE, new FirefoxProfile());
175-
176-
try {
177-
localDriver = new FirefoxDriver(new FirefoxBinary(), new FirefoxProfile(), caps);
178-
fail("Exception expected");
179-
} catch (IllegalStateException ex) {
180-
// expected
181-
}
182-
}
183-
170+
184171
@Test
185172
public void canPassCapabilitiesBinaryAndProfileSeparately() throws IOException {
186173
FirefoxBinary binary = spy(new FirefoxBinary());

0 commit comments

Comments
 (0)