Installation of Selenium in node

You need to follow below steps to set up the environment for running Selenium tests using Node.js
  • Download and install Node.js
  • Install Selenium Webdriver package for Node.js
  • Download the drivers for various browsers like IE, Chrome, Firefox etc
  • Write the tests in Java Script and Execute it.

Downloading and Installing Node.js

Just visit official Node.js website and download the Node.js installer for windows. Double click on that installer file and follow on-screen instructions to install the Node.js. After installation is completed, update the system path to include the location of Node.js installation directory. Node.js in System Path Node.js in System Path To ensure that Node.js is installed correctly, open the command prompt and execute below command. Checking Node.js Version Checking Node.js Version As you can see, I have got v4.4.7 installed on my system.

Installing Selenium Webdriver Package for Node.js

Next you have to install the Selenium Webdriver package for Node.js. For that, just execute below command in a command prompt.
npm install selenium-webdriver

Downloading driver files for browsers

After that download the driver applications for each browsers and update the system path to point to the location where you have placed the drivers.
I have put the chromedriver.exe and IEDriverServer.exe files in Downloads directory so I have updated the path variable as shown in below image. Driver files included in System Path Driver files included in System Path

Writing and running the first script using Node.js

Then write the sample selenium code as shown in below example and save the file as launchChrome.js
var webdriver = require('selenium-webdriver');
var driver = new webdriver.Builder()

To execute the above file, you need to fire below command in a command prompt.
node launchChrome.js

There are many Node.js packages out there for browser automation using Selenium. But we we would be using selenium-webdriver official package. Here is the list of other node.js packages for selenium automation. Synchronized Selenium Webdriver – Another way is by using node-fibers and wd-synch libraries as explained at

Web development and Automation testing

solutions delivered!!