Selenium Automation on LINUX Machine

Shiksha Engineering
4 min readAug 5, 2020

Author : Vinay Gupta

LINUX OS

LINUX is a family of Operating Systems, which are mostly open source. Which comes with a Distributions which are also called as Disto some of the popular distro are Ubuntu, CentOS, Mintos, etc. Distro includes Linux Kernel and some supporting software.

All of which has a common Command User Interface (CUI). CUI in Linux is known as Terminal, Where users can perform its commands.

Why LINUX?

  • Linux is open Source and less hardware intensive.
  • Linux comes with less bloatware than other operating systems, so it consumes less Storage.
  • It also consumes less memory out of the box, so provides the extra memory to initiate more browsers at once as browsers are memory hungry applications.
  • Linux requires less down-time than other OS, so it requires less effort in maintenance.

Selenium Architecture

Selenium is an open source Web Site Automation tool. It is an intermittent layer between the programming language and Browser. So users can control the browser with coding.

Selenium Client Libraries

WebDriver is a tool for automating testing web applications, and in particular to verify that they work as expected. It aims to provide a friendly API that’s easy to explore and understand, which will help make your tests easier to read and maintain.

JSON Wire Protocol conversion

Selenium converts the user command to a JSON format and transfers it to Browser Driver.

JSON format is used in selenium because JSON can easily be converted into an Object. When it is transferred to a different layer as String and will be converted into layers native Object so, it can be parsed and used effectively.

Browser Driver

Browser Driver is a controller provide to control the browser activities, some of the browser driver are as follow:

  • Google chrome uses chromedriver
  • Firefox uses geckodriver

Browsers

A web browser (commonly referred to as a browser) is a software application for accessing information on the World Wide Web. When a user requests a web page from a particular website, the web browser retrieves the necessary content from a web server and then displays the page on the screen.

Step to initiate WebDriver on Linux Machine

Step 1: Browser Installation (Chrome)

Run Following commands to install latest version of Google Chrome

Step 2: Install Java

  • sudo apt-get install default-jre

Step 3: Install GIT

  • apt-get install git

Step 4: Install Maven

Run Following Commands

Open File /etc/environment in vim

  • Insert new Line => M2_HOME=”/opt/apache-maven-3.6.3"
  • Edit Path Variable and add => /data/apache-maven-3.6.3/bin

Run Following commands to apply changes

  • sudo update-alternatives — install “/usr/bin/mvn” “mvn” “/data/apache-maven-3.6.3/bin/mvn” 0
  • sudo update-alternatives — set mvn /data/apache-maven-3.6.3/bin/mvn

Step 5: Download chromedriver

Download latest chromedriver of specific version for install browser

Step 6: Code to initiate WebDriver in Linux Machine

Challenges with Selenium Automation on LINUX

  • Not much of integrated information is available on this topic
  • Browsers are GUI tools so the functionality of the browser is not fully accessible on a CUI based Operating System such as LINUX.
  • Software installation process is quite different on LINUX Machine.
  • It don’t have all the supported software as in Windows
  • Directories in Windows can be used as “\\” but for Linux we have to use “/”.

References

--

--