Skip to content

Commit c2a8e13

Browse files
committed
fix: remove /wd/hub on Appium 2 (except we are on Cloud provider.)
1 parent b051b85 commit c2a8e13

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

source/src/main/java/org/cerberus/core/engine/execution/impl/RobotServerService.java

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -282,29 +282,16 @@ public void startServer(TestCaseExecution execution) throws CerberusException {
282282

283283
// TODO #FIXME SELENIUM
284284

285-
// SetUp Proxy
286-
String hubUrl = StringUtil.cleanHostURL(RobotServerService.getBaseUrl(StringUtil.formatURLCredential(
287-
execution.getSession().getHostUser(),
288-
execution.getSession().getHostPassword(),
289-
session.getHost()),
290-
session.getPort()));
291-
292-
//Even if /wd/hub is not the standard anymore with Selenium 4, BS still continue to use it.
293-
if (execution.getRobotProvider().equals(TestCaseExecution.ROBOTPROVIDER_BROWSERSTACK)) {
294-
hubUrl += "/wd/hub";
295-
}
296-
297-
LOG.debug("Hub URL :{}", hubUrl);
285+
// SetUp HubURL
286+
String hubUrl = generateHubUrl(execution, session);
298287
URL url = new URL(hubUrl);
299288

300-
boolean isProxy = proxyService.useProxy(hubUrl, system);
301-
302289
// Timeout Management
303290
int robotTimeout = parameterService.getParameterIntegerByKey("cerberus_robot_timeout", system, 60000);
304291

305-
ClientConfig clientConfig;
306-
307292
// Proxy Management
293+
boolean isProxy = proxyService.useProxy(hubUrl, system);
294+
ClientConfig clientConfig;
308295
if (isProxy) {
309296
String proxyHost = parameterService.getParameterStringByKey("cerberus_proxy_host", system, DEFAULT_PROXY_HOST);
310297
int proxyPort = parameterService.getParameterIntegerByKey("cerberus_proxy_port", system, DEFAULT_PROXY_PORT);
@@ -1468,4 +1455,22 @@ public void setOptionsToDefault(Session session) {
14681455
}
14691456
}
14701457

1458+
private String generateHubUrl(TestCaseExecution execution, Session session) {
1459+
String hubUrl = StringUtil.cleanHostURL(RobotServerService.getBaseUrl(StringUtil.formatURLCredential(
1460+
execution.getSession().getHostUser(),
1461+
execution.getSession().getHostPassword(),
1462+
session.getHost()),
1463+
session.getPort())+"/wd/hub");
1464+
1465+
//Only remove /wd/hub on app because not supported anymore on Appium 2.
1466+
if ((execution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK) || execution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA))) {
1467+
//Cloud robot provider supports only /wd/hub even on Appium 2. So we remove only if we are on prem.
1468+
if (guessRobotProvider(session.getHost()).equals(TestCaseExecution.ROBOTPROVIDER_NONE)) {
1469+
hubUrl = hubUrl.replace("/wd/hub", "");
1470+
}
1471+
}
1472+
1473+
LOG.debug("Hub URL :{}", hubUrl);
1474+
return hubUrl;
1475+
}
14711476
}

0 commit comments

Comments
 (0)