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

Commit

Permalink
Fix launching chrome on windows
Browse files Browse the repository at this point in the history
  related issue #749
  • Loading branch information
sukrosono authored and nchevobbe committed Feb 19, 2018
1 parent d27edc0 commit 78a05aa
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions packages/devtools-launchpad/src/server/launch.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const ps = require("child_process");
const path = require("path");
const { isFirefoxRunning } = require("./utils/firefox");
const firefoxDriver = require("../../bin/firefox-driver");
const isWindows = /^win/.test(process.platform);
const {
getValue
} = require("devtools-config");
Expand All @@ -23,6 +24,13 @@ function handleLaunchRequest(req, res) {
tcpPort: getValue("firefox.tcpPort")
};
if (!isRunning) {
process.on('unhandledRejection', (err)=> {
if (err.message.indexOf('Could not locate Firefox on the current system')>-1) {
console.error('selenium-webdriver could not locate Firefox, please launch it manually.');
} else {
throw err;
}
});
firefoxDriver.start(location, options);
res.end("launched firefox");
} else {
Expand All @@ -32,8 +40,12 @@ function handleLaunchRequest(req, res) {
}

if (browser == "Chrome") {
ps.spawn(path.resolve(__dirname, "../../bin/chrome-driver.js"),
["--location", location]);
const chromeDriver= path.resolve(__dirname, "../../bin/chrome-driver.js");
if (isWindows) {
ps.spawn('node', [chromeDriver, "--location", location]);
} else {
ps.spawn(chromeDriver, ["--location", location]);
}
res.end("launched chrome");
}
}
Expand Down

0 comments on commit 78a05aa

Please sign in to comment.