Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug when specifying customGeckoDriverPath #222

Merged
merged 1 commit into from Sep 11, 2023
Merged

Fix bug when specifying customGeckoDriverPath #222

merged 1 commit into from Sep 11, 2023

Conversation

marcogrcr
Copy link
Contributor

WHAT?

Destructured customGeckoDriverPath out of params in function start().

Additionally, updated test.e2e.js to test the three webdriver usage modes: 1/ automatically download and start, 2/ automatically start, 3/ manually start.

Finally, added a self-referencing devDependency to geckodriver since webdriverio transitively depends on it.

WHY?

Before this change, running the following code:

import { start } from 'geckodriver'

await start({ customGeckoDriverPath: '/some/path/geckodriver' })

Would fail to start the geckodriver because it would execute:

geckodriver --custom-gecko-driver-path=/some/path/geckodriver --port=43083 --host=0.0.0.0 --websocket-port=0

Which results in exit code 64 and the following output:

/some/path/geckodriver: error: Found argument '--custom-gecko-driver-path' which wasn't expected, or isn't valid in this context

If you tried to supply `--custom-gecko-driver-path` as a value rather than a flag, use `-- --custom-gecko-driver-path`

USAGE:
    geckodriver [OPTIONS]

For more information try --help

By destructuring customGeckoDriverPath, the extraneous --custom-gecko-driver-path argument is no longer specified and the webdriver starts successfully.

HOW?

Successfully ran:

npm run build && npm test

const browser = await remote({
automationProtocol: 'webdriver',
hostname: '0.0.0.0',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this is no longer necessary as the default value has changed from localhost to 0.0.0.0. See: webdriverio/webdriverio@c6d81b5#diff-b5fe71260eef292213595160b7583dabd5475f9775eee92b92d00d0c5fb1fa7f

const browser = await remote({
automationProtocol: 'webdriver',
hostname: '0.0.0.0',
port, // must set port or wdio will automatically start geckodriver
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent PR 👌 nice work!

@christian-bromann
Copy link
Contributor

Can we update the branch?

@marcogrcr marcogrcr closed this Sep 11, 2023
WHAT?

Destructured `customGeckoDriverPath` out of `params` in
`function start()`.

Additionally, updated `test.e2e.js` to test the three `webdriver` usage
modes: 1/ automatically download and start, 2/ automatically start, 3/
manually start.

Finally, added a self-referencing `devDependency` to `geckodriver`
since `webdriverio` transitively depends on it.

WHY?

Before this change, running the following code:

```ts
import { start } from 'geckodriver'

await start({ customGeckoDriverPath: '/some/path/geckodriver' })
```

Would fail to start the `geckodriver` because it would execute:

```shell
geckodriver --custom-gecko-driver-path=/some/path/geckodriver --port=43083 --host=0.0.0.0 --websocket-port=0
```

Which results in exit code `64` and the following output:

```log
/some/path/geckodriver: error: Found argument '--custom-gecko-driver-path' which wasn't expected, or isn't valid in this context

If you tried to supply `--custom-gecko-driver-path` as a value rather than a flag, use `-- --custom-gecko-driver-path`

USAGE:
    geckodriver [OPTIONS]

For more information try --help
```

By destructuring `customGeckoDriverPath`, the extraneous
`--custom-gecko-driver-path` argument is no longer specified and the
webdriver starts successfully.

HOW?

Successfully ran:

```shell
npm run build && npm test
```
@marcogrcr marcogrcr reopened this Sep 11, 2023
@marcogrcr
Copy link
Contributor Author

Can we update the branch?

Done!

@christian-bromann
Copy link
Contributor

Thank you!

@christian-bromann christian-bromann merged commit 345f3f9 into webdriverio-community:main Sep 11, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants