Search...
Toggle theme

Testing with Protractor on Recent Chrome Versions

A comprehensive guide explaining how to resolve ChromeDriver compatibility issues when using Protractor with recent versions of Google Chrome, including detailed solutions and technical background.

Common Error

You might encounter this error when using Protractor with Chrome:

E/runner - Unable to start a WebDriver session.
E/launcher - Error: SessionNotCreatedError: session not created:
    This version of ChromeDriver only supports Chrome version 114
    Current browser version is <SOME_VERSION> with binary path <SOME_PATH>

Overview of Key Components

To understand this issue, let's review the key components involved in running end-to-end tests with Protractor:

  • Browser: Where the tests run
  • Protractor: Reads test files and translates them to browser operations
  • WebDriver: Intermediary driver following the W3C WebDriver Standard
  • ChromeDriver: Chrome-specific implementation of WebDriver

Communication Routes

Protractor can communicate with the browser in three ways:

  1. Direct Communication
    • Uses directConnect: true in Protractor configuration
    • Only works for Chrome and Firefox
  2. Local Selenium Server
    • Uses seleniumServerJar option
    • Or uses seleniumAddress with local instance
  3. Remote Selenium Server
    • Uses seleniumAddress with remote instance
    • Includes cloud-based platforms like BrowserStack or SauceLabs

Why Is This Error Happening?

The error occurs because:

  1. The process for identifying and downloading ChromeDriver binaries changed for Chrome/ChromeDriver versions 115+
  2. webdriver-manager can no longer locate and download ChromeDriver versions newer than v114
  3. This impacts Protractor when it relies on webdriver-manager
  4. Current stable Chrome version (at time of writing) is 126

How to Resolve the Issue

Solution Using chromedriver npm package

  1. Add chromedriver to devDependencies
    npm install --save-dev chromedriver
    
  2. Configure Auto-Detection (Optional)
    • Add to .npmrc:
      detect_chromedriver_version=true
      
  3. Run npm install
    npm install
    

Configuration Based on Your Setup

Case 1: Using directConnect or seleniumServerJar

Update your Protractor configuration:

// protractor.conf.js
exports.config = {
  chromeDriver: require('chromedriver').path,
  // ... other config options
};

Case 2: Using seleniumAddress with webdriver-manager

  1. Modify webdriver-manager update command
    npx webdriver-manager update --no-chrome
    
  2. Add npm script for Selenium Server
    {
      "scripts": {
        "start-selenium": "webdriver-manager start",
        "postinstall": "node --eval \"os.platform().startsWith('win') && fs.unlinkSync('node_modules/.bin/chromedriver')\""
      }
    }
    

    Note for Windows Users: The postinstall script removes the UNIX-based chromedriver executable to prevent Selenium Server confusion.

Key Points to Remember

  1. Ensure node_modules/.bin/ is in your PATH when starting Selenium Server
  2. Run npm install after adding new scripts
  3. The Windows-specific postinstall script is only needed for Case 2 setups

Troubleshooting Notes

If you're still experiencing issues:

  • Verify all configuration changes are applied
  • Check PATH environment variable
  • Confirm correct versions of Node.js and npm
  • Ensure proper permissions for file operations
  • Check compatibility between ChromeDriver and Chrome versions