Skip to content
Draft
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 54 additions & 17 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,15 @@ jobs:
node-version: ${{ matrix.node}}
cache: 'npm'
- run: npm ci
# HACK: Force a TTY to enable browser-driver-manager to manipulate stdout.
- shell: 'script -q -e -c "bash {0}"'
run: npx browser-driver-manager install chrome@145
working-directory: packages/puppeteer
- uses: browser-actions/setup-chrome@2e1d749697dd1612b833dba4a722266286fbefcd # v2.1.2
id: setup-chrome
with:
chrome-version: ${{ vars.CHROME_VERSION || 'stable' }}
install-chromedriver: true
Comment thread
Garbee marked this conversation as resolved.
install-dependencies: true
- run: |
echo "CHROME_TEST_PATH=${{ steps.setup-chrome.outputs.chrome-path }}" >> "$GITHUB_ENV"
echo "CHROMEDRIVER_TEST_PATH=${{ steps.setup-chrome.outputs.chromedriver-path }}" >> "$GITHUB_ENV"
- run: npm run build --workspace=packages/puppeteer
- run: npm run coverage --workspace=packages/puppeteer
- run: npm run test:export --workspace=packages/puppeteer
Expand All @@ -56,10 +61,15 @@ jobs:
node-version: ${{ matrix.node }}
cache: 'npm'
- run: npm ci
# HACK: Force a TTY to enable browser-driver-manager to manipulate stdout.
- shell: 'script -q -e -c "bash {0}"'
run: npx browser-driver-manager install chrome@145
working-directory: packages/cli
- uses: browser-actions/setup-chrome@2e1d749697dd1612b833dba4a722266286fbefcd # v2.1.2
id: setup-chrome
with:
chrome-version: ${{ vars.CHROME_VERSION || 'stable' }}
install-chromedriver: true
install-dependencies: true
- run: |
echo "CHROME_TEST_PATH=${{ steps.setup-chrome.outputs.chrome-path }}" >> "$GITHUB_ENV"
echo "CHROMEDRIVER_TEST_PATH=${{ steps.setup-chrome.outputs.chromedriver-path }}" >> "$GITHUB_ENV"
- run: npm run coverage --workspace=packages/cli

webdriverjs:
Expand All @@ -74,10 +84,15 @@ jobs:
node-version: ${{ matrix.node }}
cache: 'npm'
- run: npm ci
# HACK: Force a TTY to enable browser-driver-manager to manipulate stdout.
- shell: 'script -q -e -c "bash {0}"'
run: npx browser-driver-manager install chrome@145
working-directory: packages/webdriverjs
- uses: browser-actions/setup-chrome@2e1d749697dd1612b833dba4a722266286fbefcd # v2.1.2
id: setup-chrome
with:
chrome-version: ${{ vars.CHROME_VERSION || 'stable' }}
install-chromedriver: true
install-dependencies: true
- run: |
echo "CHROME_TEST_PATH=${{ steps.setup-chrome.outputs.chrome-path }}" >> "$GITHUB_ENV"
echo "CHROMEDRIVER_TEST_PATH=${{ steps.setup-chrome.outputs.chromedriver-path }}" >> "$GITHUB_ENV"
- run: npm run build --workspace=packages/webdriverjs
- run: npm run coverage --workspace=packages/webdriverjs
- run: npm run test:export --workspace=packages/webdriverjs
Expand All @@ -94,10 +109,15 @@ jobs:
node-version: ${{ matrix.node }}
cache: 'npm'
- run: npm ci
# HACK: Force a TTY to enable browser-driver-manager to manipulate stdout.
- shell: 'script -q -e -c "bash {0}"'
run: npx browser-driver-manager install chrome@145
working-directory: packages/webdriverio
- uses: browser-actions/setup-chrome@2e1d749697dd1612b833dba4a722266286fbefcd # v2.1.2
id: setup-chrome
with:
chrome-version: ${{ vars.CHROME_VERSION || 'stable' }}
install-chromedriver: true
install-dependencies: true
- run: |
echo "CHROME_TEST_PATH=${{ steps.setup-chrome.outputs.chrome-path }}" >> "$GITHUB_ENV"
echo "CHROMEDRIVER_TEST_PATH=${{ steps.setup-chrome.outputs.chromedriver-path }}" >> "$GITHUB_ENV"
- run: npm run build --workspace=packages/webdriverio
- run: npm run coverage --workspace=packages/webdriverio
- run: npm run test:export --workspace=packages/webdriverio
Expand Down Expand Up @@ -149,7 +169,15 @@ jobs:
node-version: ${{ matrix.node }}
cache: 'npm'
- run: npm ci
- run: npx playwright install --with-deps
- uses: browser-actions/setup-chrome@2e1d749697dd1612b833dba4a722266286fbefcd # v2.1.2
id: setup-chrome
with:
chrome-version: ${{ vars.CHROME_VERSION || 'stable' }}
install-chromedriver: true
install-dependencies: true
- run: |
echo "CHROME_TEST_PATH=${{ steps.setup-chrome.outputs.chrome-path }}" >> "$GITHUB_ENV"
echo "CHROMEDRIVER_TEST_PATH=${{ steps.setup-chrome.outputs.chromedriver-path }}" >> "$GITHUB_ENV"
- run: npm run build --workspace=packages/playwright
- run: npm run coverage --workspace=packages/playwright
- run: npm run test:export --workspace=packages/playwright
Expand All @@ -166,6 +194,15 @@ jobs:
node-version: ${{ matrix.node }}
cache: 'npm'
- run: npm ci
- uses: browser-actions/setup-chrome@2e1d749697dd1612b833dba4a722266286fbefcd # v2.1.2
id: setup-chrome
with:
chrome-version: ${{ vars.CHROME_VERSION || 'stable' }}
install-chromedriver: true
install-dependencies: true
- run: |
echo "CHROME_TEST_PATH=${{ steps.setup-chrome.outputs.chrome-path }}" >> "$GITHUB_ENV"
echo "CHROMEDRIVER_TEST_PATH=${{ steps.setup-chrome.outputs.chromedriver-path }}" >> "$GITHUB_ENV"
- run: npm run test --workspace=test/wdio

axe_core_test:
Expand Down
99 changes: 0 additions & 99 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,5 @@
"*.{json,css,md,html}": [
"prettier --write"
]
},
"dependencies": {
"browser-driver-manager": "^2.0.0"
}
}
9 changes: 8 additions & 1 deletion packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ Install axe CLI globally: `npm install @axe-core/cli -g`

Lastly, install the webdrivers of the browsers you wish to use. A webdriver is a driver for your web browsers. It allows other programs on your machine to open a browser and operate it.

To install the latest version of Chromedriver globally, install browser-driver-manager: `npm install -g browser-driver-manager`. Then run `npx browser-driver-manager install chrome`.
To install matched Chrome and ChromeDriver versions, use [`@puppeteer/browsers`](https://pptr.dev/browsers-api):

```
npx @puppeteer/browsers install chrome@stable
npx @puppeteer/browsers install chromedriver@stable
```

Each command prints the resolved binary path. Pass the ChromeDriver path to axe via `--chromedriver-path <path>`.

Current information about other available webdrivers can be found at [selenium-webdriver project](https://www.npmjs.com/package/selenium-webdriver). Alternatively, you could use [Webdriver manager](https://www.npmjs.com/package/webdriver-manager)

Expand Down
1 change: 0 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"chromedriver": "latest",
"colors": "^1.4.0",
"commander": "^9.4.1",
"dotenv": "^17.2.2",
"selenium-webdriver": "~4.41.0"
},
"devDependencies": {
Expand Down
17 changes: 7 additions & 10 deletions packages/cli/src/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,16 @@ const cli = async (
)
) {
console.error(error('Error: %s'), e.message);
console.log(`\nPlease use browser-driver-manager to install matching versions of Chrome and ChromeDriver:

$ npx browser-driver-manager install chrome

This will install the latest synced versions. You may install specific synced versions using

$ npx browser-driver-manager install chrome@<version>
console.log(`\nPlease install matched Chrome and ChromeDriver versions with @puppeteer/browsers:

where <version> is a specific version, e.g. 123.45.67, or a channel, e.g. canary.
$ npx @puppeteer/browsers install chrome@stable
$ npx @puppeteer/browsers install chromedriver@stable

You may also pass the \`--chromedriver-path\` option to axe:
Pin a specific version with @<version>, e.g. chrome@123.0.6312.86 or chrome@canary.

$ axe --chromedriver-path <path/to/chromedriver-executable>`);
Each command prints the resolved binary path. Pass them to axe via:

$ axe --chrome-path <path/to/chrome> --chromedriver-path <path/to/chromedriver>`);
process.exit(2);
} else {
throw e;
Expand Down
7 changes: 0 additions & 7 deletions packages/cli/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@ import fs from 'fs';
import path from 'path';
import colors from 'colors';
import type { AxeResults, UnlabelledFrameSelector } from 'axe-core';
import { config } from 'dotenv';
import os from 'os';

const HOME_DIR = os.homedir();
const BDM_CACHE_DIR = path.resolve(HOME_DIR, '.browser-driver-manager');

config({ path: path.resolve(BDM_CACHE_DIR, '.env'), quiet: true });

export const { CHROME_TEST_PATH, CHROMEDRIVER_TEST_PATH } = process.env;

Expand Down
14 changes: 12 additions & 2 deletions packages/cli/src/lib/webdriver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,21 @@ describe('startDriver', () => {
before(() => {
assert(
process.env.CHROME_TEST_PATH,
'CHROME_TEST_PATH is not set. Run `npx browser-driver-manager install chrome`'
[
'CHROME_TEST_PATH is not set.',
'Install Chrome: npx @puppeteer/browsers install chrome@stable',
'The command prints the resolved binary path; export it as CHROME_TEST_PATH.',
'e.g. export CHROME_TEST_PATH="$(npx @puppeteer/browsers install chrome@stable | awk \'{print $2}\')"'
].join('\n')
);
assert(
process.env.CHROMEDRIVER_TEST_PATH,
'CHROMEDRIVER_TEST_PATH is not set. Run `npx browser-driver-manager install chrome`'
[
'CHROMEDRIVER_TEST_PATH is not set.',
'Install ChromeDriver: npx @puppeteer/browsers install chromedriver@stable',
'The command prints the resolved binary path; export it as CHROMEDRIVER_TEST_PATH.',
'e.g. export CHROMEDRIVER_TEST_PATH="$(npx @puppeteer/browsers install chromedriver@stable | awk \'{print $2}\')"'
].join('\n')
);
});
beforeEach(() => {
Expand Down
5 changes: 4 additions & 1 deletion packages/playwright/test/axe-playwright.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ describe('@axe-core/playwright', () => {

beforeEach(async () => {
browser = await chromium.launch({
args: ['--disable-dev-shm-usage']
args: ['--disable-dev-shm-usage'],
...(process.env.CHROME_TEST_PATH
? { executablePath: process.env.CHROME_TEST_PATH }
: {})
});
const context = await browser.newContext();
page = await context.newPage();
Expand Down
5 changes: 4 additions & 1 deletion packages/puppeteer/test/esmTest.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ const options = {};
if (process.env.CI) {
options.args = [];
options.args.push('--no-sandbox', '--disable-setuid-sandbox');
options.executablePath = '/usr/bin/google-chrome-stable';
}

if (process.env.CHROME_TEST_PATH) {
options.executablePath = process.env.CHROME_TEST_PATH;
}

async function integrationTest() {
Expand Down
4 changes: 4 additions & 0 deletions packages/puppeteer/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,9 @@ export function puppeteerOpts(): LaunchOptions {
options.args.push('--no-sandbox', '--disable-setuid-sandbox');
}

if (process.env.CHROME_TEST_PATH) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Same fallback pattern as the playwright and wdio configs: when CI set CHROME_TEST_PATH, use that binary; otherwise let Puppeteer launch its bundled Chromium. The previous /usr/bin/google-chrome-stable hardcode in the sibling esmTest.mjs is gone for the same reason — system Chrome paths aren't portable across runner images, and now we don't need to guess.

options.executablePath = process.env.CHROME_TEST_PATH;
}

return options;
}
7 changes: 6 additions & 1 deletion packages/webdriverio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ Install [Node.js](https://docs.npmjs.com/getting-started/installing-node) if you

> Download and install any necessary browser drivers on your machine's PATH. [More on WebdriverIO setup](https://v6.webdriver.io/docs/gettingstarted.html#taking-the-first-step).

To install the latest version of Chromedriver globally, install browser-driver-manager: `npm install -g browser-driver-manager`. Then run `npx browser-driver-manager install chrome`.
To install matched Chrome and ChromeDriver versions, use [`@puppeteer/browsers`](https://pptr.dev/browsers-api):

```
npx @puppeteer/browsers install chrome@stable
npx @puppeteer/browsers install chromedriver@stable
```

Install WebdriverIO: `npm install webdriverio`

Expand Down
Loading
Loading