Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
Merge branch 'aberonni-patch-1'
Browse files Browse the repository at this point in the history
  • Loading branch information
atti187 committed Feb 14, 2019
2 parents 9ec6769 + e61d083 commit f1c8368
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ By design, only Google Chrome is available (when installed on the host system).
// wdio.conf.js
export.config = {
// port to find chromedriver
port: 9515, // default
port: 9515, // default for ChromeDriver
path: '/',
// ...
services: ['chromedriver'],

// options
chromeDriverArgs: ['--port=9515'], // default
chromeDriverArgs: ['--port=9515', '--url-base=\'/\''], // default for ChromeDriver
chromeDriverLogs: './',
// ...
};
Expand All @@ -68,6 +68,8 @@ export.config = {

### chromeDriverArgs
Array of arguments to pass to the ChromeDriver executable, see [https://helpmanual.io/help/chromedriver](https://helpmanual.io/help/chromedriver).
* `--port` will use wdioConfig.port if not specified
* `--url-base` will used wdioConfig.path if not specified

Type: `string[]`
### chromeDriverLogs
Expand Down
10 changes: 9 additions & 1 deletion src/launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@ export default class ChromeDriverLauncher {
}

async onPrepare (config) {
this.chromeDriverArgs = config.chromeDriverArgs
this.chromeDriverArgs = config.chromeDriverArgs || []
this.chromeDriverLogs = config.chromeDriverLogs

if (!this.chromeDriverArgs.find(arg => arg.startsWith('--port'))) {
this.chromeDriverArgs.push(`--port=${config.port}`)
}

if (!this.chromeDriverArgs.find(arg => arg.startsWith('--url-base'))) {
this.chromeDriverArgs.push(`--url-base=${config.path}`)
}

this.process = await ChromeDriver.start(this.chromeDriverArgs, true)

Expand Down
18 changes: 16 additions & 2 deletions tests/launcher.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,27 @@ describe('ChromeDriverLauncher launcher', () => {

const config = {
chromeDriverLogs: './',
chromeDriverArgs: ['--port=9515']
chromeDriverArgs: ['--port=9515', '--url-base=\'/\'']
}

await Launcher.onPrepare(config)

expect(Launcher.chromeDriverLogs).toBe(config.chromeDriverLogs)
expect(Launcher.chromeDriverArgs).toBe(config.chromeDriverArgs)
expect(Launcher.chromeDriverArgs).toEqual(config.chromeDriverArgs)
})

test('should set correct chromeDriverArgs', async () => {
const Launcher = new ChromeDriverLauncher()
Launcher._redirectLogStream = jest.fn()

const config = {
port: 9515,
path: '/'
}

await Launcher.onPrepare(config)

expect(Launcher.chromeDriverArgs).toEqual([`--port=${config.port}`, `--url-base=${config.path}`])
})

test('should set correct config properties when empty', async () => {
Expand Down

0 comments on commit f1c8368

Please sign in to comment.