diff --git a/README.md b/README.md index 71b8438..8f31940 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Connect [Jest][1] tests to [Selenium WebDriver][2]. ## Limitations -The project is in progress. It only supports running [preinstalled][3] WebDrivers (Chrome, Safari, Firefox, Edge, IE) without additional options. Capabilities configuration will be added soon. Pull requests welcomed. +The project is in progress. It only supports running [preinstalled][3] WebDrivers (Chrome, Safari, Firefox, Edge, IE) without additional options. It accepts [webdriver1 capabilities](https://www.w3.org/TR/webdriver1/#capabilities). Pull requests welcomed. ## Usage diff --git a/packages/jest-environment-webdriver/README.md b/packages/jest-environment-webdriver/README.md index da6601f..481340c 100644 --- a/packages/jest-environment-webdriver/README.md +++ b/packages/jest-environment-webdriver/README.md @@ -13,6 +13,18 @@ Set [`testEnvironment`](https://facebook.github.io/jest/docs/en/configuration.ht "browser": "safari" } +You can pass [capabilities](https://www.w3.org/TR/webdriver1/#capabilities) as options too: + + "testEnvironment": "jest-environment-webdriver", + "testEnvironmentOptions": { + browser: 'firefox', + capabilities: { + browserName: 'Some user agent', + acceptInsecureCerts: true + } + } + + ## Environment API Next global objects and functions are available in testing code. diff --git a/packages/jest-environment-webdriver/modules/WebDriverEnvironment.js b/packages/jest-environment-webdriver/modules/WebDriverEnvironment.js index 42d8103..273d7ba 100644 --- a/packages/jest-environment-webdriver/modules/WebDriverEnvironment.js +++ b/packages/jest-environment-webdriver/modules/WebDriverEnvironment.js @@ -7,15 +7,19 @@ class WebDriverEnvironment extends NodeEnvironment { const options = config.testEnvironmentOptions || {}; this.browserName = options.browser || 'chrome'; this.seleniumAddress = options.seleniumAddress || null; + this.capabilities = options.capabilities || null; } async setup() { await super.setup(); - + let driver = new Builder(); if (this.seleniumAddress) { driver = driver.usingServer(this.seleniumAddress); } + if (this.capabilities) { + driver = driver.withCapabilities(this.capabilities); + } driver = await driver.forBrowser(this.browserName).build(); this.driver = driver;