Skip to content

Commit e4ff363

Browse files
authored
Fix Mac process launch issues (#315)
1 parent 0819a8c commit e4ff363

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/selenium3/java/com/nordstrom/automation/selenium/plugins/AbstractAppiumPlugin.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,19 +204,26 @@ public LocalGridServer create(SeleniumConfig config, String launcherClassName, S
204204
argsList.add(0, address);
205205
argsList.add(0, "--address");
206206

207+
// UiAutomator2: enable ChromeDriver auto-download
208+
if (getBrowserName().equalsIgnoreCase("uiautomator2")) {
209+
argsList.add(0, "*:chromedriver_autodownload,*:adb_shell");
210+
argsList.add(0, "--allow-insecure");
211+
}
212+
207213
CommandLine cmdLine;
208214
String appiumBinaryPath = findMainScript().getAbsolutePath();
209215

210216
// if running with 'pm2'
211217
if (config.appiumWithPM2()) {
212218
File pm2Binary = findPM2Binary().getAbsoluteFile();
213-
219+
String winQuote = (SystemUtils.IS_OS_WINDOWS) ? "\"" : "";
220+
214221
argsList.add(0, "--");
215222

216223
// if capturing output
217224
if (outputPath != null) {
218225
// specify 'pm2' log output path
219-
argsList.add(0, "\"" + outputPath.toString() + "\"");
226+
argsList.add(0, winQuote + outputPath + winQuote);
220227
argsList.add(0, "--log");
221228
}
222229

@@ -225,7 +232,7 @@ public LocalGridServer create(SeleniumConfig config, String launcherClassName, S
225232
argsList.add(0, "--name");
226233

227234
// specify path to 'appium' main script
228-
argsList.add(0, "\"" + appiumBinaryPath + "\"");
235+
argsList.add(0, winQuote + appiumBinaryPath + winQuote);
229236
argsList.add(0, "start");
230237

231238
String executable;
@@ -248,6 +255,7 @@ public LocalGridServer create(SeleniumConfig config, String launcherClassName, S
248255
cmdLine = new CommandLine(findNodeBinary().getAbsolutePath(), argsList.toArray(new String[0]));
249256
}
250257

258+
cmdLine.setEnvironmentVariable("PATH", PathUtils.getSystemPath());
251259
return new AppiumGridServer(address, portNum, false, cmdLine, workingPath, outputPath);
252260
}
253261

src/selenium4/java/com/nordstrom/automation/selenium/plugins/AbstractAppiumPlugin.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,14 @@ public LocalGridServer create(SeleniumConfig config, String launcherClassName, S
230230
// if running with 'pm2'
231231
if (config.appiumWithPM2()) {
232232
File pm2Binary = findPM2Binary().getAbsoluteFile();
233+
String winQuote = (SystemUtils.IS_OS_WINDOWS) ? "\"" : "";
233234

234235
argsList.add(0, "--");
235236

236237
// if capturing output
237238
if (outputPath != null) {
238239
// specify 'pm2' log output path
239-
argsList.add(0, "\"" + outputPath.toString() + "\"");
240+
argsList.add(0, winQuote + outputPath.toString() + winQuote);
240241
argsList.add(0, "--log");
241242
}
242243

@@ -245,7 +246,7 @@ public LocalGridServer create(SeleniumConfig config, String launcherClassName, S
245246
argsList.add(0, "--name");
246247

247248
// specify path to 'appium' main script
248-
argsList.add(0, "\"" + appiumBinaryPath + "\"");
249+
argsList.add(0, winQuote + appiumBinaryPath + winQuote);
249250
argsList.add(0, "start");
250251

251252
String executable;
@@ -269,6 +270,7 @@ public LocalGridServer create(SeleniumConfig config, String launcherClassName, S
269270
}
270271

271272
builder = new ProcessBuilder(argsList);
273+
builder.environment().put("PATH", PathUtils.getSystemPath());
272274

273275
// store path to relay configuration in Appium process environment
274276
builder.environment().put("nodeConfigPath", nodeConfigPath.toString());

0 commit comments

Comments
 (0)