File tree Expand file tree Collapse file tree 3 files changed +13
-22
lines changed
src/org/openqa/selenium/firefox
test/org/openqa/selenium/firefox Expand file tree Collapse file tree 3 files changed +13
-22
lines changed Original file line number Diff line number Diff line change 41
41
42
42
import java .io .File ;
43
43
import java .io .IOException ;
44
+ import java .nio .file .Files ;
44
45
import java .nio .file .Path ;
45
46
import java .nio .file .Paths ;
46
47
import java .util .ArrayList ;
@@ -170,7 +171,9 @@ public FirefoxOptions setBinary(Path path) {
170
171
// Default to UNIX-style paths, even on Windows.
171
172
this .binaryPath = asUnixPath (path );
172
173
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
+ }
174
177
return this ;
175
178
}
176
179
@@ -448,7 +451,9 @@ private Capabilities toCapabilities(Capabilities source) {
448
451
if (actualBinary != null && binaryPath == null ) {
449
452
capabilities .setCapability (BINARY , actualBinary );
450
453
} 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
+ }
452
457
}
453
458
454
459
Object priorProfile = capabilities .getCapability (PROFILE );
Original file line number Diff line number Diff line change 26
26
import static org .junit .Assert .assertThat ;
27
27
import static org .junit .Assert .assertTrue ;
28
28
import static org .junit .Assert .fail ;
29
+ import static org .junit .Assume .assumeNotNull ;
29
30
import static org .mockito .Matchers .any ;
30
31
import static org .mockito .Mockito .doThrow ;
31
32
import static org .mockito .Mockito .mock ;
39
40
import com .google .common .base .Throwables ;
40
41
41
42
import org .junit .After ;
43
+ import org .junit .Assume ;
42
44
import org .junit .Test ;
43
45
import org .mockito .Mockito ;
44
46
import org .openqa .selenium .By ;
@@ -343,13 +345,10 @@ public void shouldBeAbleToStartFromProfileWithLogFileSetToStdout() throws IOExce
343
345
@ Test
344
346
public void shouldBeAbleToStartANamedProfile () {
345
347
FirefoxProfile profile = new ProfilesIni ().getProfile ("default" );
348
+ assumeNotNull (profile );
346
349
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 ();
353
352
}
354
353
355
354
@ Test (timeout = 60000 )
Original file line number Diff line number Diff line change @@ -167,20 +167,7 @@ public void canUseSameProfileInCapabilitiesAndDirectly() {
167
167
168
168
verifyItIsMarionette (localDriver );
169
169
}
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
+
184
171
@ Test
185
172
public void canPassCapabilitiesBinaryAndProfileSeparately () throws IOException {
186
173
FirefoxBinary binary = spy (new FirefoxBinary ());
You can’t perform that action at this time.
0 commit comments