Selenium with Javascript – Installation

Selenium with Javascript – Installation

We have got an introduction to Selenium and Javascript in our previous session, and we are going to see the installation part in this session. So, the softwares, we need to install or configure in order to work with Selenium with Javascript are

  1. IDE – Visual studio code.
  2. Node js installation
  3. npm installation.
  4. Selenium Webdriver installation.
  5. Drivers for Browsers

So, we are going to see, each one by one in this session.

Installation of IDE – Visual Studio code

  1. Navigate to https://code.visualstudio.com/docs/setup/windows.
  2. Download the Visual Studio Code installer for Windows.
  3. Once, it is downloaded, run the installer (VSCodeUserSetup-{version}.exe).
  4. VS Code will be installed in a minute.

Node js and npm installation

  1. Navigate to node js website.
  2. Click on the download header.
  3. Click on the Windows Installer.
  4. Once it is downloaded, just click on the downloaded file and install it.
  5. Once, Node js is isntalled, you need to check if it is installed.
  6. You need to go to command prompt, and type node -v or node –version in the command prompt. If it results a version, then node js is installed, but if you get an error, then the node js is not installed and you need to install it.
  7. You need to type npm -version, npm -v, npm –version as well in the command prompt. If it results a version, then NPM is also installed.
  8. NPM is Node Package Manager.
  9. NPM is a mechanism for downloading and installing third party packages into our project.
  10. NPM is downloaded and installed alongside with Node js, and we just need to confirm it in the command prompt.

Setting up a project

Whenever we have to create a Javascript project in our desktop, then we will have to follow some steps for that.

  1. Go to Command Prompt.
  2. Change Directory. Type a command cd DirName
  3. Create a new Folder or Directory. mkdir SeleniumDemo
  4. Change Directory. Type a command cd C:\SeleniumDemo. This is a place where we will create our Selenium Project.
  5. Type npm init in command prompt. This command is going to create package.json file for us.
  6. At the end, just click to enter to confirm. Our Package.json file is created now.

Selenium Webdriver installation

  1. Navigate to npm website.
  2. Search for selenium webdriver.
  3. We can find a command there in the Website. npm install selenium-webdriver
  4. Run this command in Command Prompt in SeleniumDemo Directory. This will install the latest version of the Selenium Webdriver.
  5. Now, Selenium is installed, So we can go to the package.json file now.
  6. Type package.json in command prompt. You get a message, Do you want to open this file.
  7. Click on Yes, and the file will be opened in VS Code.
  8. Now, You can see that selenum webdriver depencies are there in the package.json file. So this means that selenium has been installed now.

Setting up drivers for browsers

Selenium Webdriver is an automation tool, which is used to automate the testing for Web Applications. So, in order to work with Web Applications, We need to open up a Browser (Mozila Firefox, Chrome) and then open up our web application in that browser. So, when we work with Selenium, Selenium will also have to do the same thing, So In order with a browser (Mozila Firefox, Chrome), We need to user drivers for browsers. Drivers are used to

  1. launch the browser instance in our test
  2. Navigating to a URL in the browser
  3. Clicking on a button in the application
  4. Enter text in a field

In Order to set up drivers for browsers, We need to follow below steps.

  1. Navigate to npm website.
  2. Search for selenium webdriver.
  3. We can find a list of all the relavant drivers there.
  4. Click on the link of the driver, and download the version as per your Operating System.
  5. Once the driver is downloaded, Copy it to any location you want in your System.
  6. Edit the environment Variables.
  7. Go to Environment Variables.
  8. You will find an Environment Variable named Path.
  9. Click on it and Add the path of the driver you downloaded.

Summary

We have covered below topics in this session

  1. Installation of IDE – Visual Studio code
  2. Node js and npm installation
  3. Setting up a project
  4. Selenium Webdriver installation
  5. Setting up drivers for browsers

Leave a Comment