Cyberithub

Step By Step to Install Selenium WebDriver for JavaScript

Advertisements

In this article, I will take you through the steps to install selenium webdriver for JavaScript. Selenium is a free and open source umbrella project for a range of tools and libraries aimed at supporting browser automation. It is the most famous and most used open source automation framework due to its wide range of features. But the use of selenium automation framework with multiple environments and suites to perform browser-based regression testing is only possible through a webdriver.

To make it simple, a webdriver is nothing but a language specific bindings to drive a browser. Usually, different browsers requires different webdriver to be installed. Here we will see the installation of chrome browser webdriver for JavaScript environment. You can find the link of all the browsers webdriver on Selenium official website.

Advertisements

Step By Step to Install Selenium WebDriver for JavaScript

Step By Step to Install Selenium WebDriver for JavaScript

Also Read: 10 Most Popular Javascript Function Examples

Step 1: Prerequisites

a) You should have a running Windows or Linux System.

Advertisements

b) You should have JavaScript installed in your System.

c) You should have access to install a package or software in your System.

Advertisements

 

Step 2: Install NPM

Since npm tool is required to install Selenium libraries for JavaScript so you need to first install the npm utility itself. If you are using Debian/Ubuntu based system, you can install npm utility by using sudo apt install npm command as shown below. Similarly, you can go to npm official website and download and install npm for Windows and other Linux distributions as well.

cyberithub@ubuntu:~$ sudo apt install npm
[sudo] password for cyberithub:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libjs-jquery-ui pypy-lib python-matplotlib-data python3-cycler python3-kiwisolver
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
gyp libjs-inherits libjs-is-typedarray libjs-psl libjs-typedarray-to-buffer libnode-dev libpython2-stdlib libpython2.7-minimal libpython2.7-stdlib
libuv1-dev node-abbrev node-ajv node-ansi node-ansi-align node-ansi-regex node-ansi-styles node-ansistyles node-aproba node-archy node-are-we-there-yet
node-asap node-asn1 node-assert-plus node-asynckit node-aws-sign2 node-aws4 node-balanced-match node-bcrypt-pbkdf node-bl node-bluebird node-boxen
node-brace-expansion node-builtin-modules node-builtins node-cacache node-call-limit node-camelcase node-caseless node-chalk node-chownr node-ci-info
node-cli-boxes node-cliui node-clone node-co node-color-convert node-color-name node-colors node-columnify node-combined-stream node-concat-map
......................................................

 

Step 3: Install Selenium Library

Once npm is successfully installed, it can be used to install selenium webdriver by using npm install selenium-webdriver command as shown below.

Advertisements
cyberithub@ubuntu:~$ npm install selenium-webdriver
npm WARN saveError ENOENT: no such file or directory, open '/home/cyberithub/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN notsup Unsupported engine for selenium-webdriver@4.5.0: wanted: {"node":">= 14.20.0"} (current: {"node":"10.19.0","npm":"6.14.4"})
npm WARN notsup Not compatible with your version of node/npm: selenium-webdriver@4.5.0
npm WARN enoent ENOENT: no such file or directory, open '/home/cyberithub/package.json'
npm WARN cyberithub No description
npm WARN cyberithub No repository field.
npm WARN cyberithub No README data
npm WARN cyberithub No license field.

+ selenium-webdriver@4.5.0
added 27 packages from 26 contributors and audited 27 packages in 2.685s

2 packages are looking for funding
run `npm fund` for details

found 0 vulnerabilities

 

Step 4: Install Chrome Webdriver

If you are using Ubuntu/Debian based systems, then you install chrome webdriver from default Ubuntu repo by using sudo apt install chromium-chromedriver command as shown below.

cyberithub@ubuntu:~$ sudo apt install chromium-chromedriver
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libjs-jquery-ui pypy-lib python-matplotlib-data python3-cycler python3-kiwisolver
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
chromium-chromedriver
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 2,496 B of archives.
After this operation, 77.8 kB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu focal-updates/universe amd64 chromium-chromedriver amd64 1:85.0.4183.83-0ubuntu0.20.04.2 [2,496 B]
Fetched 2,496 B in 1s (4,833 B/s)
Selecting previously unselected package chromium-chromedriver.
(Reading database ... 266015 files and directories currently installed.)
Preparing to unpack .../chromium-chromedriver_1%3a85.0.4183.83-0ubuntu0.20.04.2_amd64.deb ...
Unpacking chromium-chromedriver (1:85.0.4183.83-0ubuntu0.20.04.2) ...
Setting up chromium-chromedriver (1:85.0.4183.83-0ubuntu0.20.04.2) ...

 

Step 5: Test Chrome Webdriver

After successful installation, you can test the chrome webdriver by using chromedriver command as shown below.

cyberithub@ubuntu:~$ chromedriver
Starting ChromeDriver 105.0.5195.125 (1e8949033cc650c8496b3b0af7cd54372f7ff62b-refs/branch-heads/5195@{#1107}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.

Leave a Comment