skip to Main Content

I’m trying to run axe-core/cli as a Github Action on my pipeline, however I keep getting this error:

"Error: session not created: This version of ChromeDriver only supports Chrome version 121
Current browser version is 120.0.6099.224 with binary path /opt/google/chrome/chrome

Please install a matching version of ChromeDriver and run axe with the –chromedriver-path option"

I’m not sure what to do here, and struggling to find any useful information. Anyone know how I can get this to work?

name: CI Tests
on:
  pull_request:
    branches: [main]
jobs:
  axe:
    runs-on: ubuntu-latest
    env:
      WORDPRESS_API_URL: XYZ
      GITHUB_API_SECRET: ABC
    steps:
      - uses: actions/checkout@v3
      - name: Use Node.js 18.x
        uses: actions/setup-node@v1
        with:
          node-version: 18.x
      - run: yarn install
      - run: yarn run build
      - run: yarn dev & npx wait-on http://localhost:3000
      - name: Run axe
        run: |
          yarn add @axe-core/cli
          npx axe http://localhost:3000  --exit

2

Answers


  1. Chosen as BEST ANSWER

    Thanks to Steven Lambert for pointing me in the right direction. With a bit of trial and error, I ended up with this, which is working:

    name: CI Tests
    on:
      pull_request:
        branches: [main]
    jobs:
      axe:
        runs-on: ubuntu-latest
        env:
          WORDPRESS_API_URL: MY_WORDPRESS_API_URL
          GITHUB_API_SECRET: MY_GITHUB_API_SECRET
        steps:
          - uses: actions/checkout@v3
          - name: Use Node.js 18.x
            uses: actions/setup-node@v1
            with:
              node-version: 18.x
          - run: yarn install
          - name: Get Chromium version 🌐
            run: |
              CHROMIUM_VERSION=$(wget -qO- https://googlechromelabs.github.io/chrome-for-testing/LATEST_RELEASE_STABLE | cut -d. -f1)
              echo "Chromium version: $CHROMIUM_VERSION"
              echo "CHROMIUM_VERSION=$CHROMIUM_VERSION" >> $GITHUB_ENV
          - name: Setup Chrome 🌐
            id: setup-chrome
            uses: browser-actions/setup-chrome@v1
            with:
              chrome-version: ${{ env.CHROMIUM_VERSION }}
          - name: Install chromedriver 🚗
            run: |
              echo "Installing chromedriver version: $CHROMIUM_VERSION"
              yarn add chromedriver@$CHROMIUM_VERSION
              echo "chromedriver version: $(chromedriver --version)"
          - run: yarn run build
          - run: yarn dev & npx wait-on http://localhost:3000
          - name: Run axe
            run: |
              yarn add @axe-core/cli
              CHROMIUM_VERSION=$(google-chrome --version | cut -d' ' -f3 | cut -d'.' -f1)
              yarn add chromedriver@$CHROMIUM_VERSION
              npx axe --chromedriver-path $(yarn bin)/chromedriver http://localhost:3000/ --load-delay=1500 --exit
    

  2. @axe-core/cli uses chromedriver under the hood to open the desired page and run axe. Using chromedriver requires that it uses a version of Chrome that is the same or close to the same with it’s own version. When it’s not it throws that error.

    There’s a few different ways to fix the issue. You could install a chrome and chromedriver version in the action that are the same version and location as @axe-core/cli. Alternatively you could install chromedriver at any location and pass the location to @axe-core/cli using the --chromedriver-path option (as the error message suggests).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search