selenium: [🐛 Bug]: webdriver does not obtain browser driver

What happened?

I am trying out selenium-webdriver getting-started on an AL2023 EC2 instance, and I get an error, Error: Unable to obtain browser driver.. See below for more details.

It looks like Selenium Manager and the chrome driver were found. I am just using the JS code from the Getting Started tutorial.

The docs say here to file a bug report since I have selenium-webdriver@4.11.1 (> 4.6).

How can we reproduce the issue?

On an AL2023 EC2 instance:
1. npm install selenium-webdriver
2. copy [this JS code](https://www.selenium.dev/documentation/webdriver/getting_started/first_script/#putting-everything-together) into a file first-sel-script.spec.js
3. npm install -g mocha
4. mocha first-sel-script.spec.js

Relevant log output

[INFO] Searching for WebDriver executables installed on the current system...
Selenium Manager binary found at /home/ec2-user/node_modules/selenium-webdriver/bin/linux/selenium-manager
Driver path: /home/ec2-user/.cache/selenium/chromedriver/linux64/115.0.5790.102/chromedriver
Browser path: /home/ec2-user/.cache/selenium/chrome/linux64/115.0.5790.102/chrome
The version of edge cannot be detected. Trying with latest driver version
Driver path: /home/ec2-user/.cache/selenium/msedgedriver/linux64/115.0.1901.188/msedgedriver
The version of firefox cannot be detected. Trying with latest driver version
Driver path: /home/ec2-user/.cache/selenium/geckodriver/linux64/0.33.0/geckodriver
Driver path: /home/ec2-user/.cache/selenium/IEDriverServer/win32/4.11.0/IEDriverServer.exe
The version of safari cannot be detected. Trying with latest driver version

Error: Unable to obtain browser driver.
        For more information on how to install drivers see
        https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location/. Error: Error executing command for /home/ec2-user/node_modules/selenium-webdriver/bin/linux/selenium-manager with --browser,safari,--output,json: safaridriver not available for download
    at getPath (/home/ec2-user/node_modules/selenium-webdriver/common/driverFinder.js:35:11)
    at getAvailableBrowsers (/home/ec2-user/node_modules/selenium-webdriver/testing/index.js:125:6)
    at init (/home/ec2-user/node_modules/selenium-webdriver/testing/index.js:225:59)
    at suite (/home/ec2-user/node_modules/selenium-webdriver/testing/index.js:375:5)
    at Object.<anonymous> (/home/ec2-user/selenium_scripts/first-sel-script.spec.js:5:1)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:438:15)
    at async formattedImport (/usr/local/lib/node_modules/mocha/lib/nodejs/esm-utils.js:9:14)
    at async exports.requireOrImport (/usr/local/lib/node_modules/mocha/lib/nodejs/esm-utils.js:42:28)
    at async exports.loadFilesAsync (/usr/local/lib/node_modules/mocha/lib/nodejs/esm-utils.js:100:20)
    at async singleRun (/usr/local/lib/node_modules/mocha/lib/cli/run-helpers.js:125:3)
    at async exports.handler (/usr/local/lib/node_modules/mocha/lib/cli/run.js:370:5)

Operating System

Amazon Linux 2023

Selenium version

4.11.1

What are the browser(s) and version(s) where you see this issue?

Chrome

What are the browser driver(s) and version(s) where you see this issue?

Chrome

Are you using Selenium Grid?

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 3
  • Comments: 15 (6 by maintainers)

Most upvoted comments

Hi @ivanuz , @nwongahp ,

This is problem with selenium-webdriver/testing lib trying to download other drivers by default. The issue will be fixed in next patch/minor release.

You can use below code and run with mocha to make it work (which doesn’t use testing lib)

const {By, Builder} = require('selenium-webdriver');
const assert = require("assert");

  describe('First script', function () {
    let driver;

    before(async function () {
      driver = await new Builder().forBrowser('chrome').build();
    });

    after(async () => await driver.quit());

    it('First Selenium script', async function () {
      await driver.get('https://www.selenium.dev/selenium/web/web-form.html');

      let title = await driver.getTitle();
      assert.equal("Web form", title);

      await driver.manage().setTimeouts({implicit: 500});

      let textBox = await driver.findElement(By.name('my-text'));
      let submitButton = await driver.findElement(By.css('button'));

      await textBox.sendKeys('Selenium');
      await submitButton.click();

      let message = await driver.findElement(By.id('message'));
      let value = await message.getText();
      assert.equal("Received!", value);
    });
  });

Hope this helps!

Thanks, Sri

Hi @ivanuz , @nwongahp ,

This is problem with selenium-webdriver/testing lib trying to download other drivers by default. The issue will be fixed in next patch/minor release.

You can use below code and run with mocha to make it work (which doesn’t use testing lib)

const {By, Builder} = require('selenium-webdriver');
const assert = require("assert");

  describe('First script', function () {
    let driver;

    before(async function () {
      driver = await new Builder().forBrowser('chrome').build();
    });

    after(async () => await driver.quit());

    it('First Selenium script', async function () {
      await driver.get('https://www.selenium.dev/selenium/web/web-form.html');

      let title = await driver.getTitle();
      assert.equal("Web form", title);

      await driver.manage().setTimeouts({implicit: 500});

      let textBox = await driver.findElement(By.name('my-text'));
      let submitButton = await driver.findElement(By.css('button'));

      await textBox.sendKeys('Selenium');
      await submitButton.click();

      let message = await driver.findElement(By.id('message'));
      let value = await message.getText();
      assert.equal("Received!", value);
    });
  });

Hope this helps!

Thanks, Sri

It has worked. Thank you very much!

There are so many little things we’ve done since 4.11 that I really want to get 4.12 out before trying to debug anything else. Really trying to get it done today…

You can use below code and run with mocha to make it work (which doesn’t use testing lib)

Thanks! It works without suite and import Browser

I think this is a known issue with the test tool used in JS bindings trying to get a safaridriver when it shouldn’t. I think @harsha509 is working on it.

Sri, is this what you were talking about on slack?

Yes Titus! working on a fix !

I think this is a known issue with the test tool used in JS bindings trying to get a safaridriver when it shouldn’t. I think @harsha509 is working on it.

Sri, is this what you were talking about on slack?