@@ -6,6 +6,7 @@ const ps = require("child_process");
66const path = require ( "path" ) ;
77const { isFirefoxRunning } = require ( "./utils/firefox" ) ;
88const firefoxDriver = require ( "../../bin/firefox-driver" ) ;
9+ const isWindows = / ^ w i n / . test ( process . platform ) ;
910const {
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