Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support exact matching of chromedriver version when passed in the driver option of selenium-standalone service #917

Open
mainak-basu22 opened this issue Jul 3, 2024 · 0 comments

Comments

@mainak-basu22
Copy link

mainak-basu22 commented Jul 3, 2024

## Expected Behavior

When providing a a specific version of chromedriver in the driver object of installArgs and args, selenium-standalone should attempt to find an exact match, and if no exact match is found then it should look for the latest major version with the existing logic.

## If you're suggesting a change/improvement, tell us how it should work.

The getLastChromedriverVersionFromMajor function in compute-download-urls.js does a prefix match based on the chromedriver version provided in the driver object. We can do an exact match search first and if no match is found then the current logic can be executed.

## Proposed solution:

async function getLastChromedriverVersionFromMajor(version) {
  const response = await got({
    method: 'get',
    url: 'https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json',
    responseType: 'json',
    headers: {
      'Content-Type': 'application/json',
    },
  });

  const exactMatch = response.body.versions.find(
    (f) => f.version === version && 'chromedriver' in f.downloads
  );
  // If exact match is found, return it
  if (exactMatch) {
    return exactMatch;
  }

  const versionsWithMajor = response.body.versions.filter(
    (f) =>
      validateMajorVersionPrefix(f.version) === validateMajorVersionPrefix(version) && 'chromedriver' in f.downloads
  );

  versionsWithMajor
    .sort((version1, version2) => {
      return version1.version.localeCompare(version2.version, undefined, { numeric: true, sensitivity: 'base' });
    })
    .reverse();

  return versionsWithMajor.length ? versionsWithMajor[0] : null;
}

## Current Behavior
Current behavior does a major version match on the provided chromedriver version in the driver object against the lsit of chromedrivers matching the major version. Then it sorts the matched result and returns the latest major version.

## Steps to Reproduce
Run WebdriverIO test with selenium-standalone service with an old chromedriver version to support older chrome browser installation.

const drivers = {
    "chrome": {
      "arch": "x64",
      "version": "126.0.6478.61"
    }
  }

export.config = {
    // ...
    services: [
        ['selenium-standalone', {
            logPath: 'logs',
            installArgs: { drivers }, // drivers to install
            args: { drivers } // drivers to use
        }]
    ],
    // ...
};

## Your Environment
selenium-standalone: 9.5.0
webdriverio: 7.36.0

## Is there another tool calling selenium-standalone on your behalf:
webdriverio v7

## System/platform:
Mac/Windows/Linux

## Other details that might be important:
This request is to support older browser installtions where testers are not able to upgrade the chrome version due to organizational restrictions. Updating to WebdriverIO V8 is not an immediate option due to organizational limitations and is in the roadmap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant