-
-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* onlyDriver feature * linter issues * fixed issue * fixed test for firefox * checking port port existence before killing * changed naming for driver-starter
- Loading branch information
Showing
13 changed files
with
343 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const ChildProcess = require('child_process'); | ||
const delay = require('./delay'); | ||
|
||
async function startDriver(pathToDriver, args) { | ||
const options = { | ||
cwd: process.cwd(), | ||
env: process.env, | ||
stdio: 'inherit', | ||
}; | ||
let driverProcess; | ||
|
||
if (process.platform === 'win32' && !pathToDriver.endsWith('.exe')) { | ||
driverProcess = ChildProcess.spawn('powershell', [ | ||
`Start-Process -FilePath "${pathToDriver}"`, | ||
'-Wait', | ||
'-NoNewWindow', | ||
]); | ||
} else { | ||
driverProcess = ChildProcess.spawn(pathToDriver, args, options); | ||
} | ||
await delay.sleep(3000); | ||
|
||
driverProcess.on('close', (code) => { | ||
if (code !== null && code !== 0 && code !== 1) { | ||
throw new Error(`Chromedriver exited with error code: ${code}`); | ||
} | ||
}); | ||
|
||
driverProcess.on('error', (error) => { | ||
throw new Error(error); | ||
}); | ||
|
||
const killChromeDriver = () => { | ||
try { | ||
driverProcess.kill(); | ||
} catch (_) { | ||
// eslint-disable-next-line no-empty | ||
} | ||
}; | ||
process.on('exit', killChromeDriver); | ||
process.on('SIGTERM', killChromeDriver); | ||
|
||
return driverProcess; | ||
} | ||
|
||
module.exports = { | ||
startDriver, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.