John Beasley
John Beasley

Reputation: 3073

Opening a test page in Selenium

I am starting to work with Selenium, so I created (what I thought) was a quick test script to simply open a page within my company's intranet.

I wasn't sure where exactly I was supposed to download the dependencies for Selenium, so I created a folder on my development server called "TESTING", and used the command prompt to install Selenium:

 npm install selenium-webdriver

The install appears to be successful, as it reads "added 46 packages from 79 contributors..."

Inside my TESTING directory, I can see the node_modules directory was added, as well as the package-lock.json file.

I then created an index.php file that only has the following:

<h1>hello world</h1>
<button type="submit" name="btnI">Click Me</button>

Here is sample.js, which includes the following script that is supposed to open index.php:

var webdriver = require('selenium-webdriver');

var driver = new webdriver.Builder().
        withCapabilities(webdriver.Capabilities.chrome()).
        build();

driver.get("https://development.usa.company.com/testing/index.php");

driver.findElement(webdriver.By.name('btnI')).click();

I go back to the cmd prompt and run the following command:

node sample.js

And I get the following error:

Error: The ChromeDriver could not be found on the current PATH. 
Please download the latest version of the ChromeDriver from 
http://chromedriver.storage.googleapis.com/index.html 
and ensure it can be found on your PATH.

What am I doing wrong?

Upvotes: 0

Views: 77

Answers (2)

John Beasley
John Beasley

Reputation: 3073

Using Athens Holloway suggestion, all I simply needed to do was run the following command in the terminal:

npm install chromedriver

Upvotes: 0

CEH
CEH

Reputation: 5909

Looks like you need to add the PATH to chromedriver.exe into your system Environment Variables.

  1. Install chromedriver.exe -- note the file path to the install directory
  2. Search Windows for Environment Variables and click "Environment Variables.." to edit them
  3. Edit the 'Path' variable
  4. After all the other file paths that appear, add "C:\Path\To\ChromeDriver\Directory\chromedriver.exe", separated by semicolon from the other paths.

This guide may help: https://developers.refinitiv.com/sites/default/files/How%20To%20Add%20ChromeDriver%20To%20System%20Variables_0.pdf

Upvotes: 2

Related Questions