browser-webdriverio makes it impossible to set --enable-gpu when using headless Chrome (original) (raw)

Describe the bug

Right now enabling headless mode in Chrome also sets the --disable-gpu flag. There is no way to configure Chrome like this:

{ browser: 'chrome', headless: true, name: 'Chrome', provider: webdriverio({ capabilities: { 'goog:chromeOptions': { args: ['--enable-gpu'] } } }) }

Since the --disable-gpu will be added automatically when setting headless to true it will override the --enable-gpu flag.

https://github.com/vitest-dev/vitest/blame/d77e93659d1703f9d96b58373b38738bf190289e/packages/browser-webdriverio/src/webdriverio.ts#L185

https://github.com/vitest-dev/vitest/blame/d77e93659d1703f9d96b58373b38738bf190289e/packages/browser-webdriverio/src/webdriverio.ts#L195

It is of course possible to achieve the desired result when doing all the config via 'goog:chromeOptions'. The following works:

{ browser: 'chrome', name: 'Chrome', provider: webdriverio({ capabilities: { 'goog:chromeOptions': { args: ['--headless', '--enable-gpu'] } } }) }

However I think this is not really obvious without knowing the source code. I can't find it anymore but I believe using the --headless flag directly was also discouraged somewhere in the docs.

Do you remember why --disable-gpu was hard-coded in the first place? Maybe it's possible to just drop it.

Reproduction

As mentioned above configuring Chrome like this is impossible:

{ browser: 'chrome', headless: true, name: 'Chrome', provider: webdriverio({ capabilities: { 'goog:chromeOptions': { args: ['--enable-gpu'] } } }) }

It will not enable GPU rendering.

System Info

npmPackages: @vitest/browser-webdriverio: ^4.1.5 => 4.1.5 vitest: ^4.1.5 => 4.1.5

Used Package Manager

npm

Validations