20
20
import java .io .File ;
21
21
import java .util .logging .Logger ;
22
22
import org .openqa .selenium .Capabilities ;
23
- import org .openqa .selenium .WebDriverException ;
24
23
import org .openqa .selenium .internal .Require ;
25
24
import org .openqa .selenium .manager .SeleniumManager ;
26
25
import org .openqa .selenium .manager .SeleniumManagerOutput .Result ;
@@ -36,41 +35,40 @@ public static Result getPath(DriverService service, Capabilities options) {
36
35
37
36
public static Result getPath (DriverService service , Capabilities options , boolean offline ) {
38
37
Require .nonNull ("Browser options" , options );
39
- Result result = new Result (service .getExecutable ());
40
- if (result .getDriverPath () != null ) {
41
- LOG .fine (
42
- String .format (
43
- "Skipping Selenium Manager, path to %s specified in Service class: %s" ,
44
- service .getDriverName (), result .getDriverPath ()));
45
- }
38
+ String driverName = service .getDriverName ();
46
39
47
- result = new Result (System . getProperty ( service .getDriverProperty () ));
40
+ Result result = new Result (service .getExecutable ( ));
48
41
if (result .getDriverPath () == null ) {
49
- try {
50
- result = SeleniumManager .getInstance ().getDriverPath (options , offline );
51
- } catch (RuntimeException e ) {
52
- throw new WebDriverException (
53
- String .format ("Unable to obtain: %s, error %s" , options , e .getMessage ()), e );
42
+ result = new Result (System .getProperty (service .getDriverProperty ()));
43
+ if (result .getDriverPath () == null ) {
44
+ try {
45
+ result = SeleniumManager .getInstance ().getDriverPath (options , offline );
46
+ } catch (RuntimeException e ) {
47
+ throw new NoSuchDriverException (
48
+ String .format ("Unable to obtain: %s, error %s" , options , e .getMessage ()), e );
49
+ }
50
+ } else {
51
+ LOG .fine (
52
+ String .format (
53
+ "Skipping Selenium Manager, path to %s found in system property: %s" ,
54
+ driverName , result .getDriverPath ()));
54
55
}
55
56
} else {
56
57
LOG .fine (
57
58
String .format (
58
- "Skipping Selenium Manager, path to %s found in system property : %s" ,
59
- service . getDriverName () , result .getDriverPath ()));
59
+ "Skipping Selenium Manager, path to %s specified in Service class : %s" ,
60
+ driverName , result .getDriverPath ()));
60
61
}
61
62
62
63
String message ;
63
64
if (result .getDriverPath () == null ) {
64
- message = String .format ("Unable to locate or obtain %s" , service . getDriverName () );
65
+ message = String .format ("Unable to locate or obtain %s" , driverName );
65
66
} else if (!new File (result .getDriverPath ()).exists ()) {
66
67
message =
67
- String .format (
68
- "%s at location %s, does not exist" , service .getDriverName (), result .getDriverPath ());
68
+ String .format ("%s at location %s, does not exist" , driverName , result .getDriverPath ());
69
69
} else if (!new File (result .getDriverPath ()).canExecute ()) {
70
70
message =
71
- String .format (
72
- "%s located at %s, cannot be executed" ,
73
- service .getDriverName (), result .getDriverPath ());
71
+ String .format ("%s located at %s, cannot be executed" , driverName , result .getDriverPath ());
74
72
} else {
75
73
return result ;
76
74
}
0 commit comments