Skip to content

Commit

Permalink
Merge pull request #24 from gristlabs/no_banner
Browse files Browse the repository at this point in the history
add MOCHA_WEBDRIVER_NO_CONTROL_BANNER
  • Loading branch information
paulfitz authored Jan 16, 2020
2 parents 7baa0c9 + ae756a1 commit 2fc2f06
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ to enable, for `driver.fetchLogs()` and for `enableDebugCapture()`. Defaults to
- `MOCHA_WEBDRIVER_STACKTRACES`: Enhance stack traces with async frames, if set to a non-empty
value.
- `MOCHA_WEBDRIVER_IGNORE_CHROME_VERSION`: Disable chromedriver's check that it supports the installed version of Chrome. Normally the installed chromedriver (controlled by the version in `yarn.lock`) must [match Chrome's version](https://chromedriver.chromium.org/downloads/version-selection). When tests are run by different developers and test environments, that can cause difficulties. On the other hand, incompatible behavior is rare, so this option offers a practical workaround.
- `MOCHA_WEBDRIVER_NO_CONTROL_BANNER`: suppress the "Chrome is being controlled by automated test software" banner.

## Useful methods

Expand Down
7 changes: 7 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ export async function createDriver(options: {extraArgs?: string[]} = {}): Promis
// Typings for Firefox options are incomplete, so supplement them with Chrome's typings.
const firefoxOpts = new firefox.Options() as firefox.Options & chrome.Options;

// Optionally suppress the "Chrome is being controlled by automated test software" banner.
// At the time of writing, on page reloads this can result on early clicks being missed,
// so it can be helpful to just suppress it entirely.
if (process.env.MOCHA_WEBDRIVER_NO_CONTROL_BANNER) {
chromeOpts.excludeSwitches("enable-automation");
}

// Pay attention to the environment variables (documented in README).
if (process.env.MOCHA_WEBDRIVER_HEADLESS) {
chromeOpts.headless();
Expand Down

0 comments on commit 2fc2f06

Please sign in to comment.