How to define Selenium Webdriver architecture-Selenium Tutorial – comprehensive Blackbook 1

We going to start with Selenium tutorial Blackbook in exhaustive and different approach , In this first segment of the Selenium tutorial, we will discuss aboutSelenium Webdriver Architecture, what is Selenium Webdriver , Selenium Webdriver overview, Brief History of Selenium,Advantages of Selenium,limitations of Selenium, Selenium components and some frequently asked questions .

Selenium Tutorial Blackbook
Selenium Tutorial -Module One

What is Selenium Webdriver

Selenium is an open source technology or framework through which we can automate Web based Applications. Selenium Supports Multi browser Testing, Multiple languages like Java, Ruby, Perl, Python is also supported. It supports different multiple platforms like Windows, Linux, macOS etc. as part of the platform.

Brief History About Selenium :

Selenium was initially evolved from an internal tool by Jason Huggins in 2004 at ThoughtWorks.

Later in the year of 2007, Huggins joined the organization Google, and with others like Jennifer Bevan, he continued with the design and development of one of the initial variations of Selenium called Selenium RC. During a similar time period, another person named as Simon Stewart from ThoughtWorks developed an advance web browser automation tools as WebDriver. 

In 2008, a person named as Philippe Hanrigou from ThoughtWorks came up with remote Automation concepts known as “Selenium Grid”.

In 2009, at Google Test Automation Conference, it was decided to merge the two projects, and given the name as Selenium WebDriver, or Selenium 2.0.

Advantages of Selenium Webdriver :

A. Open Source :

Selenium is an open source technology/framework, hence huge community support is available where the development and improvement scope is rapid and vast, also as its open source you can implement any specific feature that you require as part of your work and contribute to the Open source community. 

B. Multi Programming Language supported :

Selenium is supported by widely used languages; it comes up with different programming language bindings, so you can choose your favourable language to work with selenium as per your need and expertise.

Selenium provides support for the below programming languages : 

Java 

C#

Perl

python

Ruby  

Javascript

C. Platform independent :

Selenium is platform-independent, so you can automate your web applications over any platform and any of the Operating System i.e. Windows, Linux, macOS etc.

D. Cross Browser Testing capability

Selenium supports cross browser Testing capability for your web applications; you can run your test suite written with Selenium in multiple browsers such as Firefox, Chrome, IE, Safari etc.

E. Cross Device Testing capability

Selenium Test Automation is used for mobile web application testing automation on various devices such as Android, IOS. 

F. Remote or cloud execution :

Selenium GRID provides you with the feature to run and control your web application’s automation test script in the cloud by making one system as the master node and other system as the slave node, slave nodes connect to one master node, and master node monitors the slave nodes, so your tests are in different slave nodes with the different operating system and different browsers such as Chrome, Firefox, Internet Explorer etc.

G. Parallel Testing capability:

With Selenium, you can achieve Automated Parallel testing capabilities, i.e. you can run your test script or automation Test cases into the different or same browser and different or same operating system in parallel. This feature helps you achieve lesser execution time for the whole Automation Test suite that you have, and also you can test your web application’s feasibility and compatibility with multiple operating system and multiple browsers in parallel.   

H. Compatibility with multiple Framework and third-party tools and technology

Selenium framework can be easily integrated with multiple various third party technologies and frameworks such as different Unit Test framework, i.e. TestNg, JUnit, MbUnit, Nunit etc. etc., different build Tools such as Ant, Maven, Gradle etc., continuous integration tools, i.e. Jenkins, different Test management tools such Jira, testlink etc., various reporting tools such as Allure, Extent Report etc.

I. Headless Browser execution : 

Selenium Webdriver supports headless browser driver for automated test case execution, where all your automation test cases run in headless browser mode, i.e. no browser gets opened and the execution becomes lightning fast so you can complete you Test scripts and the functionality quickly in case of urgent release and validations.

You can basically use htmlUnitdriver or ghost driver for the headless execution with Selenium.  

Disadvantages of Selenium :

A. Native/Window based App Support, not present : 

Selenium is used for Automating Web Bade application, but it does not provide support for native applications or windows based applications.

B. Exhaustive Image-based Automation: 

Selenium does not provide exhaustive support for automating image-based problems or applications, though we can use some third-party tools such as Sikuli, tesseract ocr based solutions which can be integrated with Selenium to do the job related to the Image validations/operations or image data extractions and validations, they are also having some limitations like you may face issues with Parallel testing, identifying handwritten document and validating those in the process of automating your application if there are such use cases.

C. Integration with third-party tools : 

One downside of the integration with multiple third-party tools with selenium is that your automation script might become slower at times.

D. Selenium framework Development :

Designing and developing an advance Test Automation framework with Selenium requires a lot of expertise on selenium and its not too straight forward to build an Automation framework with multiple tools along with Selenium.

E. Browser Specific issues: 

You may face some browser-specific issues while working with Selenium, especially with IE, sometimes you may not be able to handle Web actions like click, sendkeys etc., and the browser may become dead. Hence you need to have advance knowledge to handle those areas while automating Application built on Bootstrap JS and executing it on IE browser.

Also, you might face browser compatibility issues with the Selenium Webdriver versions; you need to make sure you are using the compatible Firefox, Chrome or any other browser you are working with Selenium Webdriver’s version.

F. No official support : 

Like any other Open Source tools selenium is also an open-source tool, which means you will not have official support for your problems like any Paid Tools, even though there is very large community support available, you can work with them with you problem statement, but that can be heavily time-consuming.

Selenium Components : 

Selenium as a tool has the below-mentioned components, which are : 

1. Selenium IDE :

Selenium IDE or Selenium Integrated Development environment is the most initial version of Selenium for Web Application Automation.

Selenium IDE is a kind of record and playback tool, which you can use as a plugin of the browser and record you web action your you applications and that can be saved as a script and later you can run the same recorded script to execute and do validations.

But it has few limitations such as :

A. you need to run the recorded script, modifying the script is not that flexible or neither you can deign you use case and scripts in you own independent approach.

B. Execution is very slow in nature.

C. Majorly supports Firefox, though there are some tweaks you can do to run the recorded script in other browsers such as Google Chrome.

D. parallel execution is not supported.

E. Mobile testing is not supported.

F. Report generation is quite not good.

Its actually very preliminary version of Selenium, by using this you can do very limited Test Automation for your Web Applications.

2. Selenium RC 

Selenium Remote Control is the next version of Selenium and very often its referred to as Selenium 1.0.

How Selenium RC works internally :

Selenium RC consists of two major components, such as Selenium Server, Selenium Client.

The Selenium Server launches the browsers and runs the selenium commands that you have written as a test automation script by using Selenium client libraries available in different languages.

Selenium Server converts the commands/test scripts into something called Selenese commands, and it acts as an HTTP proxy.

Selenium Server interacts with Web Browser engine and performs the Web operation that you are trying to Automate as part of Test cases for the Application Under the Test.

Steps to use Selenium RC : 

A. Install the Selenium-RC Server.

Create a project using your choice of programming language and language specific to the browser driver.

B. Install selenium server

You can set up Selenium Server by simply just download the selenium-server.jar file and run it in your system by using the below command : 

java -jar selenium-server.jar

C. Write the Script by using Selenium client libraries and the same using the Selenium Server.

Limitations of Selenium RC :

  • In Selenium Remote control, automation driver and browser becomes a bit slower reason being browser engine is not directly interacted, rather Selenium RC injects javascript to the browser engine, it also referred to as Selenium Core.
  • The Server which has to be up and running before and during the test script execution.
  • Advance Web actions can not be automated and handled using Selenium RC such as mouse Movement, double click, taking input from Keyboard etc. etc. unlike Selenium Webdriver.
  • Selenium RC does not support Mobile app testing.
  • Selenium RC is dependent on the real browser to run the Automation testing script, and it does not support the headless browser such as HTMLUnitDriver or GHostDriver etc. unlike Selenium Webdriver.

3. Selenium WebDriver:

Selenium Webdriver is the advance version among the Selenium components which is very robust and also supports the advance version of Web interactions and also it does not interact with Browser via Javascript unlike Selenium RC and has the Mobile Application testing support as well. It’s very often referred to as part of Selenium 2.0.

WebDriver can handle dynamic elements and also supports parallel execution with multiple different browsers.

We will have a detailed discussion in the upcoming segments.

4. Selenium GRID : 

Selenium GRID is another component of Selenium through which you can have the remote execution of your automation testing script by creating master-slave nodes. Selenium GRID supports parallel Testing on the same browser as well as multiple browsers. 

We will have further discussion on Selenium GRID in the upcoming sections.

D. WebDriver 3.0: Selenium 3.0 is the latest version of Selenium components which is basically the combination of WebDriver 2.0 and evolution of GRID 3.

In this next segment, we are about to discuss the Selenium WebDriver Architecture in detail, and eventually, it depicts how Selenium works internally,.

Selenium Webdriver Architecture  :

There five major attributes or components as part of Selenium Webdriver architecture : 

    

  • Selenium Client Library or Selenium-Programming language bindings
  • WebDriver protocol or JSON Wire Protocol over HTTP
  • Browser’s Drivers
  • Browsers Engine
  • Browser’s rendering Engine
Selenium Webdriver architecture
Selenium Tutorial-Selenium Webdriver architecture

Selenium Client Libraries or Programming Language Bindings: 

Selenium provides different language binding, i.e. the client libraries to support multiple different languages as part of your Automation Development and Automation test script. For example, Selenium with C#, Selenium with Java, Selenium with Python etc.

WebDriver Protocol or JSON WIRE PROTOCOL :

JSON which basically stands for JavaScript Object Notation. This protocol is also referred to as WebDriver protocol, used for server-client data transfer over the web. Each Browser Driver (e.g. FirefoxDriver, ChromeDriver etc.) has its own HTTP server and uses this protocol to transfer data via Rest Webservices in the form of the HTTP request and HTTP response.

 Browser Drivers:

Each browser has its own browser driver. The Browser drivers establish communication with the respective browser via browser engine. 

When the Automation script gets executed, it directly communicates to browser drivers and eventually with the respective browser. The request and response are transferred via HTTP request and HTTP response.

Browsers Engine :

Every Browser has its own browser engine; The browser engine basically works as an intermediary layer between UI and the rendering engine.

Browser Rendering engine : 

The Browser rendering engine is responsible for displaying the requested document by rendering the specific elements required for the request-response and data.

Selenium Webdriver Architecture and working functionality in a nutshell :

Selenium-WebDriver invokes the browser directly using each browser’s native support for automation and its JavaScript engine. How these calls are being made and the features that they support depend on the browser you are using.

It does not inject JavaScript like Selenium-RC when the browser loads.

The following incidence occurs while running the Webdriver script:

     1. We do the automation scripting using any language binding (Java / C # etc.), and it triggers the WebDriver API while the script is in execution.

     2. The script and eventually commands (eg driver.findElement (By.id (“idName”))) are being converted to JavaScript internally.

     3. Using Browser Engine, it is again converted back to JSON, which is kind of a key-value pair.

     4. After getting the respective value of the respective key, it identifies the respective WebElements and performs the respective user actions (like click, send keys, etc.).

    5. All communication is done using a JSON-Wire or Webdriver Protocol call, and the communications happen over HTTP in the form of Rest API as an HTTP request and HTTP response.

Selenium frequently asked Questions : 

1. What are the types of WebDriver APIs available in Selenium?

Selenium Webdriver is an interface and has different language bindings for different programming languages such as Java, C#, python etc., 

Selenium Webdriver is majorly having two different variants such as : 

A. Selenium Web driver local.

B. Selenium Web driver Remote. 

The Selenium Web driver Local uses the API to work with the specific language binding, and you can work with these with you local execution, while on the other hand if you want to execute you automation testing scripts in Remote, then you need to use the remote Selenium Web driver APIs.

2. Explain What are the scenarios we cannot automate using Selenium?

Selenium does not provide a way to Automate the below areas of aspects of the application, which are : 

A. Performance testing of the Application

B. Security Testing of the Applications.

C. Image-based processing and automation

D. Captcha based automation.

E. Video streaming Scenarios.

F. Native application or window-based applications.

G. Streaming Applications

3. Difference between Selenium 2.0 and Selenium 3.0?

A. For Selenium 2.0 minimum requirement is Java 1.7, on the other hand for Selenium 3.0, the minimum required Java version is 1.8

B. Selenium 3.0 requires GeckOdriver for Firefox version above 47, but this is not the case for Selenium 2.0 

C. Selenium 3.0 supports modern browser such as Edge, Safari etc. but on the other hand for Selenium 2.0, browser driver for Mozilla, Chromedriver, IE which is developed by Selenium developers.

D. In Selenium 3, the support for mobile automation testing got removed, i.e. AndroidDriver and iPhoneDriver, and you have to use tools like Appium for mobile automation testing, which is not the case for Selenium 2.0.

E. Selenium 3.0 doesn’t support the Headless driver, i.e. HTMLUnitWebDriver, but Selenium 2.0 has the support for Headless execution, i.e. with HTMLUnitDriver or ghostdriver.

F. Within Selenium 3, the Selenium WebDriver has become W3C standard; on the other hand, Selenium Webdriver in Selenium 2.0 does not belong to W3C standard.

Conclusion : With this we complete the first segment of Selenium tutorial blackbook covering What is Selenium , Selenium Webdriver Architecture,Selenium overview, Pros and cons of Selenium, In the upcoming segment of Selenium tutorial module 2 we will be discussing about Selenium Installation ie setup , Selenium commands and other basic,intermediate and advance topics of Selenium

About Debarghya

Myself Debarghya Roy, I am an Engineering ARCHITECT working with fortune 5 company and an open source contributor, having around 12 years of experience/expertise in various Technology stack.
I have worked with various technologies such as Java,C#,Python,Groovy, UI Automation(Selenium), Mobile Automation(Appium), API/Backend Automation,Performance Engineering(JMeter, Locust), Security Automation(MobSF,OwAsp,Kali Linux, Astra,ZAP etc), RPA,Process Engineering Automation,Mainframe Automation,Back End Development with SpringBoot,Kafka,Redis,RabitMQ,ELK stack, GrayLog, Jenkins and also having experience in Cloud Technologies, DevOps etc.
I live in Bangalore ,India with my wife and have passion towards Blogging , music , playing guitar and my Philosophy of life is Education for All which gave the birth of LambdaGeeks. Lets connect over linked-in - https://www.linkedin.com/in/debarghya-roy/

1 thought on “How to define Selenium Webdriver architecture-Selenium Tutorial – comprehensive Blackbook 1”

Leave a Comment

Your email address will not be published. Required fields are marked *