Skip to content

Commit c19a926

Browse files
Merge pull request #1 from robinGupta11392/1660-fix-for-checkStatus-url
Fix for basePath appending logic to fix Issue appium#1660
2 parents d3ede46 + 72cf29f commit c19a926

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/main/java/io/appium/java_client/service/local/AppiumDriverLocalService.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,23 @@ public static AppiumDriverLocalService buildService(AppiumServiceBuilder builder
9494
}
9595

9696
public AppiumDriverLocalService withBasePath(String basePath) {
97-
this.basePath = basePath;
97+
this.basePath = sanitizeBasePath(basePath);
9898
return this;
9999
}
100100

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+
101114
public String getBasePath() {
102115
return this.basePath;
103116
}

src/test/java/io/appium/java_client/service/local/ServerBuilderTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import static io.appium.java_client.service.local.AppiumServiceBuilder.APPIUM_PATH;
77
import static io.appium.java_client.service.local.flags.GeneralServerFlag.CALLBACK_ADDRESS;
88
import static io.appium.java_client.service.local.flags.GeneralServerFlag.SESSION_OVERRIDE;
9+
import static io.appium.java_client.service.local.flags.GeneralServerFlag.BASEPATH;
910
import static io.github.bonigarcia.wdm.WebDriverManager.chromedriver;
1011
import static java.lang.System.getProperty;
1112
import static java.lang.System.setProperty;
@@ -312,4 +313,11 @@ public void checkAbilityToStartServiceWithLogFileUsingShortFlag() {
312313
service.start();
313314
assertTrue(testLogFile.exists());
314315
}
316+
317+
@Test
318+
public void checkAbilityToStartServiceUsingBasePath() {
319+
service = new AppiumServiceBuilder().withArgument(BASEPATH, "/wd/hub").build();
320+
service.start();
321+
assertTrue(service.isRunning());
322+
}
315323
}

0 commit comments

Comments
 (0)