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

[🐛 Bug]: Unable to obtain browser driver. #1495

Closed
pkduongsu opened this issue Oct 9, 2023 · 9 comments
Closed

[🐛 Bug]: Unable to obtain browser driver. #1495

pkduongsu opened this issue Oct 9, 2023 · 9 comments

Comments

@pkduongsu
Copy link

What happened?

I downloaded selenium using npm install as the tutorial of installing selenium (https://www.selenium.dev/documentation/webdriver/getting_started/install_library/), then copied the javascript code in the example on GItHub https://github.com/SeleniumHQ/seleniumhq.github.io/blob/trunk/examples/javascript/test/getting_started/firstScript.spec.js#L16

However, when i try to run the test, it raises the error: Unable to obtain browser driver

How can we reproduce the issue?

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

suite(function (env) {
  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);
    });
  });
}, { browsers: [Browser.CHROME, Browser.FIREFOX]});

Relevant log output

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 C:\Users\ASUS\OneDrive\Tài liệu\GitHub\ci-cd-pipeline\front-end\node_modules\selenium-webdriver\bin\windows\selenium-manager.exe with --browser,chrome,--output,json: Driver unav vailable: Driver path:
    at getPath (C:\Users\ASUS\OneDrive\Tài liệu\GitHub\ci-cd-pipeline\front-end\node_modules\selenium-webdriver\common\driverFinder.js:35:11)
    at getAvailableBrowsers (C:\Users\ASUS\OneDrive\Tài liệu\GitHub\ci-cd-pipeline\front-end\node_modules\selenium-webdriver\testing\index.js:121:6)      
    at init (C:\Users\ASUS\OneDrive\Tài liệu\GitHub\ci-cd-pipeline\front-end\node_modules\selenium-webdriver\testing\index.js:230:59)
    at suite (C:\Users\ASUS\OneDrive\Tài liệu\GitHub\ci-cd-pipeline\front-end\node_modules\selenium-webdriver\testing\index.js:380:5)
    at Object.<anonymous> (C:\Users\ASUS\OneDrive\Tài liệu\GitHub\ci-cd-pipeline\front-end\test\test.js:5:1)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

Operating System

Windows 11

Selenium version

4.13.0

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?

"chromedriver": "^117.0.3", "geckodriver": "^4.2.1"

Are you using Selenium Grid?

No response

@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2023

@pkduongsu, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@titusfortner titusfortner transferred this issue from SeleniumHQ/selenium Oct 9, 2023
@titusfortner
Copy link
Member

I'm moving this to the docs issues, because it's not actually a problem with Selenium code.

@harsha509 is there an example for JS where users can execute something in Selenium without a test runner? Or does everything need to go through something like mocha? (One of these days we should get together so you can walk me through how all the JS code works). 😂

@harsha509
Copy link
Member

Hi @pkduongsu ,

what was the command used to run the test? Am able to run the test and I don't see any issues.

I have the above code placed in test.js and the below command to run test
mocha -t 6000 test.js

Thanks,
Sri

@pkduongsu
Copy link
Author

pkduongsu commented Oct 10, 2023

Hi @harsha509 , sorry for not providing the full context of the problem before. I was trying to pair it with React web app, modified the package.json file with "s-test": "mocha test" in the scripts object, and ran the test using the command npm run s-test and it raised the error above.

@harsha509
Copy link
Member

Hi @pkduongsu ,

Thank you for providing the complete context.
If time permits, Could you please create a sample GitHub repository that replicates the issue?

Thanks,
Sri Harsha

@pkduongsu
Copy link
Author

Hi @harsha509, I found a GitHub repository similar to my case:
https://github.com/BalasubramaniM/react-selenium/tree/master
I have also tried to use the code in this git hub repository to run the test but it still raises the above errors, although for my case compared to this repository, I have installed newer version of selenium-webdriver and chrome-driver using npm i selenium-webdriver chromedriver

@harsha509
Copy link
Member

harsha509 commented Oct 16, 2023

Hi @pkduongsu ,

The repository indicated at https://github.com/BalasubramaniM/react-selenium/tree/master is no longer up-to-date. The version of selenium-webdriver in this repository is 4.0.0-alpha.1, while the current version stands at 4.14.0.

Updating the package.json file and subsequently re-installing the node_modules to rectify the issue.

I've updated the repo deps and tested in here https://github.com/harsha509/react-selenium.

Hope this helps!

Thanks,
Sri

@anjalivaswani8614
Copy link

Hi Harsha I'm facing the similar issue where getting the error: org.openqa.selenium.WebDriverException: Unable to obtain Selenium Manager Binary at: C:\Users.cache\selenium\manager\0.4.16\selenium-manager.exe
Build info: version: '4.16.1', revision: '9b4c83354e'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.9'
Driver info: driver.version: unknown
at org.openqa.selenium.manager.SeleniumManager.getBinary(SeleniumManager.java:210)
at org.openqa.selenium.manager.SeleniumManager.getDriverPath(SeleniumManager.java:253)

Browser is not launching .
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setCapability("goog:chromeOptions", true);
chromeOptions.addArguments("--no-sandbox");
chromeOptions.addArguments("--remote-allow-origins=*");
chromeOptions.addArguments("--ignore-certificate-errors");
chromeOptions.addArguments("--proxy-server=http://",PROXY_URL_STRING);
chromeOptions.addArguments("--proxy=http://",PROXY_URL);
chromeOptions.addArguments("--start-maximized");

    ChromeOptions ChromeOpt = new ChromeOptions();
    // Pass the ChromeOpt option it takes as a type of Capability.
    String chromeDriverPath = String.valueOf(SeleniumManager.getInstance().getDriverPath(chromeOptions,false));
    System.out.println("chromeDriverPath--" + chromeDriverPath);

    return this.driver= new ChromeDriver(chromeOptions);

@diemol
Copy link
Member

diemol commented Feb 19, 2024

I will close this as we did not get more information.

@anjalivaswani8614, this issue is about JS. You seem to use Java. If you are still facing an issue, please open a new one at https://github.com/SeleniumHQ/selenium

@diemol diemol closed this as not planned Won't fix, can't repro, duplicate, stale Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants