Skip to content

Commit

Permalink
build: avoid failing actions from old chromedriver
Browse files Browse the repository at this point in the history
When the GitHub actions chrome version is updated there is not an easy
way to update the version of Chromedriver in the package.json to match.

Remove chromedriver from dev dependencies and instead use the version
that is installed by selenium-standalone when running chromedriver tests
locally.

Ensure the correct version is installed in CI by specifying which
version of chromedriver to install in the prepare script.
  • Loading branch information
olivierwilkinson committed Jan 15, 2023
1 parent cb6993e commit 0c1d179
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/webdriverio-testing-library.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
with:
node-version: ${{ matrix.node }}
- uses: actions/checkout@v2
- run: npm install
- name: npm run validate
- name: npm install and validate
run: |
export CHROMEDRIVER_VERSION="$(chromedriver --version | awk '{print $2}')"
npm install
npm run validate
env:
CI: true
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"typecheck:async": "tsc -p ./test/async/tsconfig.json",
"typecheck:sync": "tsc -p ./test/sync/tsconfig.json",
"typecheck:build": "npm run build:cjs -- --noEmit && npm run build:esm -- --noEmit",
"typecheck": "npm-run-all typecheck:build typecheck:**"
"typecheck": "npm-run-all typecheck:build typecheck:**",
"prepare": "selenium-standalone install --drivers.chrome.version=${CHROMEDRIVER_VERSION:-latest} --drivers.gecko.version=${GECKODRIVER_VERSION:-latest}"
},
"files": [
"dist"
Expand All @@ -49,13 +50,12 @@
"@wdio/spec-reporter": "^7.19.0",
"@wdio/sync": "^7.19.0",
"eslint": "^7.6.0",
"geckodriver": "^3.2.0",
"kcd-scripts": "^11.1.0",
"npm-run-all": "^4.1.5",
"semantic-release": "^17.0.2",
"ts-node": "^9.1.1",
"typescript": "^4.4.2",
"chromedriver": "^105.0.1",
"geckodriver": "^3.0.2",
"wdio-chromedriver-service": "^7.3.2",
"wdio-geckodriver-service": "^2.0.0"
},
Expand Down
19 changes: 18 additions & 1 deletion wdio.conf.chromedriver.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
const computeFsPaths = require('selenium-standalone/lib/compute-fs-paths');
const createDefaultOps = require('selenium-standalone/lib/default-config');

const baseConfig = require('./wdio.conf')
const defaultOps = createDefaultOps()

const fsPaths = computeFsPaths({
...defaultOps,
seleniumVersion: defaultOps.version,
drivers: {
chrome: {
version: process.env.CHROMEDRIVER_VERSION || 'latest',
arch: process.arch,
},
},
})

exports.config = {
...baseConfig.config,
services: ['chromedriver'],
services: [
['chromedriver', {chromedriverCustomPath: fsPaths.chrome.installPath}],
],
}
23 changes: 20 additions & 3 deletions wdio.conf.geckodriver.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
const computeFsPaths = require('selenium-standalone/lib/compute-fs-paths')
const createDefaultOps = require('selenium-standalone/lib/default-config')

const baseConfig = require('./wdio.conf')
const defaultOps = createDefaultOps()

const fsPaths = computeFsPaths({
...defaultOps,
seleniumVersion: defaultOps.version,
drivers: {
firefox: {
version: process.env.GECKODRIVER_VERSION || 'latest',
arch: process.arch,
},
},
})

exports.config = {
...baseConfig.config,
services: ['geckodriver'],
services: [
['geckodriver', {geckodriverCustomPath: fsPaths.firefox.installPath}],
],
capabilities: [
{
maxInstances: 5,
browserName: 'firefox',
acceptInsecureCerts: true,
'moz:firefoxOptions': {
args: process.env.CI ? ['--headless'] : [],
args: process.env.CI ? ['-headless'] : [],
},
},
]
],
}
2 changes: 1 addition & 1 deletion wdio.conf.selenium-standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exports.config = {
'selenium-standalone',
{
drivers: {
firefox: true,
firefox: process.env.GECKODRIVER_VERSION || true,
chrome: process.env.CHROMEDRIVER_VERSION || true,
},
},
Expand Down

0 comments on commit 0c1d179

Please sign in to comment.