File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
main/java/io/appium/java_client/service/local
test/java/io/appium/java_client/service/local Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -94,10 +94,23 @@ public static AppiumDriverLocalService buildService(AppiumServiceBuilder builder
94
94
}
95
95
96
96
public AppiumDriverLocalService withBasePath (String basePath ) {
97
- this .basePath = basePath ;
97
+ this .basePath = sanitizeBasePath ( basePath ) ;
98
98
return this ;
99
99
}
100
100
101
+ @ SneakyThrows private static String sanitizeBasePath (String basePath ) {
102
+ if (null == basePath ) {
103
+ LOG .warn ("Base Path cannot be NULL -- ignoring the basepath configuration" );
104
+ return null ;
105
+ }
106
+ basePath = basePath .trim ();
107
+ if (basePath .isBlank () || basePath .isEmpty ()) {
108
+ LOG .warn ("Base Path cannot be Empty or Blank -- ignoring the basepath configuration" );
109
+ return null ;
110
+ }
111
+ return (basePath .endsWith ("/" ) ? basePath : basePath + "/" );
112
+ }
113
+
101
114
public String getBasePath () {
102
115
return this .basePath ;
103
116
}
Original file line number Diff line number Diff line change 6
6
import static io .appium .java_client .service .local .AppiumServiceBuilder .APPIUM_PATH ;
7
7
import static io .appium .java_client .service .local .flags .GeneralServerFlag .CALLBACK_ADDRESS ;
8
8
import static io .appium .java_client .service .local .flags .GeneralServerFlag .SESSION_OVERRIDE ;
9
+ import static io .appium .java_client .service .local .flags .GeneralServerFlag .BASEPATH ;
9
10
import static io .github .bonigarcia .wdm .WebDriverManager .chromedriver ;
10
11
import static java .lang .System .getProperty ;
11
12
import static java .lang .System .setProperty ;
@@ -312,4 +313,11 @@ public void checkAbilityToStartServiceWithLogFileUsingShortFlag() {
312
313
service .start ();
313
314
assertTrue (testLogFile .exists ());
314
315
}
316
+
317
+ @ Test
318
+ public void checkAbilityToStartServiceUsingBasePath () {
319
+ service = new AppiumServiceBuilder ().withArgument (BASEPATH , "/wd/hub" ).build ();
320
+ service .start ();
321
+ assertTrue (service .isRunning ());
322
+ }
315
323
}
You can’t perform that action at this time.
0 commit comments