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

Be able to customize WebdriverIO capabilities #4335

Closed
4 tasks done
thomasjm opened this issue Oct 19, 2023 · 3 comments
Closed
4 tasks done

Be able to customize WebdriverIO capabilities #4335

thomasjm opened this issue Oct 19, 2023 · 3 comments

Comments

@thomasjm
Copy link

Clear and concise description of the problem

At the moment, the WebdriverIO capabilities are hardcoded here:

capabilities: {
'browserName': this.browser,
'wdio:devtoolsOptions': { headless: options.headless },
},

This prevents me from customizing them. For example, I'd like to be able to change the Chrome and chromedriver binaries, as described here, since I want to provide them myself.

Suggested solution

I'd like to be able to configure things in the Vite test options, in the same place where I select the webdriverio provider. Perhaps a function that allows me to transform the default capabilities:

  test: {
    browser: {
      enabled: true,
      name: "chrome",
      provider: "webdriverio",

      // New option
      transformWebdriverIOCapabilities: (caps) => {
        caps['goog:chromeOptions'] = {
          binary: "/my/chrome/binary",
          args: ['headless', 'disable-gpu']
        };
      }
    },
    ...
  },

One could also extend the provider attribute, perhaps

  test: {
    browser: {
      enabled: true,
      name: "chrome",

      // Modified provider field
      provider: {
        name: "webdriverio",
        transformCapabilities: (caps) => ...,
      }
  }

Alternative

I tried putting options in the wdio.conf.ts file as described in the WebDriverIO docs, but these options seem to be ignored.

Additional context

No response

Validations

@sheremet-va
Copy link
Member

There is an open PR for this, but the author stopped working on it seems like: #3758

@sheremet-va
Copy link
Member

This is supported since #4364.

@FL33TW00D
Copy link

To anyone that may be running headless tests with configuration from a file, you can do the following:

//vite.config.js
import config from "./webdriver.json";
export default defineConfig({
  test: {
    browser: {
      enabled: true,
      headless: true,
      name: "chrome",
      providerOptions: {
        capabilities: config, 
      }
    },
    testTimeout: 30000,
  },
});

//webdriver.json
{
  "goog:chromeOptions": {
    "args": [
        "--no-sandbox",
    ]
  }
}

It should just work!

Thanks for implementing @sheremet-va ❤️

@github-actions github-actions bot locked and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants