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

Config is read too early #37

Open
RafalSkorka opened this issue Jun 9, 2020 · 1 comment
Open

Config is read too early #37

RafalSkorka opened this issue Jun 9, 2020 · 1 comment

Comments

@RafalSkorka
Copy link

Hi, could you read the settings in the onPrepare hook and not in the constructor of ChromeDriverLauncher?
The reason is I want to set a randomly chosen port, but since getting such port is an async function I can do it only in wdio config onPrepare hook.
Such setting is ignored by chromerdriver service because it reads the config already in the constructor.
You get the config in the onPrepare hook so something like this snippet below would fix my problem: :)

in https://github.com/atti187/wdio-chromedriver-service/blob/master/src/launcher.js

    async onPrepare(config) {
        this.args.forEach(argument => {
            if (argument.includes('--port')) {
                throw new Error('Argument "--port" already exists')
            }
            if (argument.includes('--url-base')) {
                throw new Error('Argument "--url-base" already exists')
            }
        })

        this.options.port = config.port || this.options.port;
        this.args.push(`--port=${this.options.port}`)
@christian-bromann
Copy link
Contributor

@RafalSkorka feel free to provide a PR, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants