Skip to content
This repository was archived by the owner on Sep 21, 2021. It is now read-only.

Commit 78a05aa

Browse files
sukrosononchevobbe
authored andcommitted
Fix launching chrome on windows
related issue #749
1 parent d27edc0 commit 78a05aa

File tree

1 file changed

+14
-2
lines changed
  • packages/devtools-launchpad/src/server

1 file changed

+14
-2
lines changed

packages/devtools-launchpad/src/server/launch.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const ps = require("child_process");
66
const path = require("path");
77
const { isFirefoxRunning } = require("./utils/firefox");
88
const firefoxDriver = require("../../bin/firefox-driver");
9+
const isWindows = /^win/.test(process.platform);
910
const {
1011
getValue
1112
} = require("devtools-config");
@@ -23,6 +24,13 @@ function handleLaunchRequest(req, res) {
2324
tcpPort: getValue("firefox.tcpPort")
2425
};
2526
if (!isRunning) {
27+
process.on('unhandledRejection', (err)=> {
28+
if (err.message.indexOf('Could not locate Firefox on the current system')>-1) {
29+
console.error('selenium-webdriver could not locate Firefox, please launch it manually.');
30+
} else {
31+
throw err;
32+
}
33+
});
2634
firefoxDriver.start(location, options);
2735
res.end("launched firefox");
2836
} else {
@@ -32,8 +40,12 @@ function handleLaunchRequest(req, res) {
3240
}
3341

3442
if (browser == "Chrome") {
35-
ps.spawn(path.resolve(__dirname, "../../bin/chrome-driver.js"),
36-
["--location", location]);
43+
const chromeDriver= path.resolve(__dirname, "../../bin/chrome-driver.js");
44+
if (isWindows) {
45+
ps.spawn('node', [chromeDriver, "--location", location]);
46+
} else {
47+
ps.spawn(chromeDriver, ["--location", location]);
48+
}
3749
res.end("launched chrome");
3850
}
3951
}

0 commit comments

Comments
 (0)