Skip to main content

Selenium - Architecture

Selenium Architecture:

Here, we will learn about the overall selenium architecture. How communication happens from client library to browser and which are all the components involved between them.


Architecture compromises of major four components namely
  1. Selenium Language Binding
  2. JSON Wire Protocol
  3. Browser Drivers
  4. Real Browsers

1. Selenium Language Binding:

Various programming languages provide their own Rest API support for communicating to their respective browser drivers via JSON Wire protocol.
python provides 'selenium' as a client library which has all the rest API implementation for communicating with browser drivers.
Selenium is a third party library which does not come in python basic installation. 
You need to install it via PIP command :
pip install selenium

driver = selenium.webdriver.Chrome('location of the chrome driver executable') 

Above line returns one chrome browser session , where rest all browser related automation can be performed using on that instance using selenium library API calls.


2. JSON Wire Protocol:

JSON Wire Protocol is common protocol using across all the client libraries to bring uniformity among all the libraries. 
This Protocol converts everything to JSON format for each GET and POST request from the client libraries Rest API calls.

It sends client library data to browser drivers in the form of JSON and receives result from browsers via driver and converts JSON to user readable format.

eg : 

Python Code:
driver.get('http://facebook.com')   // Client Library 


JSON format:
{
"url" : 'sessionid/http://facebook.com'    //JSON Wire protocol interpretation.
}


Browser Driver :
Will explain in the below section , how Selenium is platform agnostic!?


Refer following link for JSON Wire protocol Documentation : 

3. Browser Drivers:

Rest API calls from client will not hit directly to real browsers instead it hits their respective browser drivers and in turn those drivers call their respective browsers.


How Selenium is platform agnostic?
JSON Wire protocol converts every single line of code from the client library to a meaningful JSON format where driver can able to understand and can perform same operation on the real browser.

Browser Driver doesn't bother/depend about which language client library user is using  because JSON-wire protocol made his job much easier by converting every single line of code to JSON format.



My Recommendation: Go through these steps , which will help you while debugging.

If you're curious to know , why JSON-Wire and driver works together. follow following steps:

Step 1 : Download selenium server standalone  Note : Selenium RC is deprecated in upcoming releases.
Step 2 : Download chrome Driver and geckodriver and place it in the same location where selenium standalone server jar is placed.
Step 3 : Run the server using : java -jar selenium-standalone-server.jar

Console output:
13:47:03.442 INFO [GridLauncherV3.lambda$buildLaunchers$3] - Launching a standalone Selenium Server on port 4444
2019-01-28 13:47:03.592:INFO::main: Logging initialized @848ms to org.seleniumhq.jetty9.util.log.StdErrLog
13:47:04.060 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
13:47:04.654 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444


Step 4 : Open the browser and enter http://localhost:4444 
It redirects a selenium page

Step 5 : Click on Console output
It opens up the console which will lists all the active sessions of the browsers.

Step 6 : Click on the new session -> select the browser of your choice ( I recommend you to choose google chrome because firefox will fail if you haven't install geckoDriver)

Step 7 : Use post man to GET or POST something on that created session.

 http://localhost:4444/wd/hub/sessions - > retrieves all the active sessions



 Thank You!
Happy Learning

Comments

Popular posts from this blog

Ansible

 What is Ansible Ansible is a configuration management, deployment and orchestration tool. Features of Ansible Simple: Simple to install and setup Built on top of Python: Provides lot of python functionality. SSH for Secure Connection  Agentless Platform independent  Push Based unlike Puppet and Chef Install and Setup: Install Ansible via pip install ansible   Generate SSH-Key on Master node using ssh-keygen -t rsa Goto /root/.ssh and copy id_rsa.pub key to all other nodes and  Run ssh-copy-id <Destination IP Address> By default, Ansible configuration file is located under  /etc/ansible/ansible.cfg and inventory file is pointed to  /etc/ansible/hosts ansible --version shows the version of ansible is using and the configuration file it is pointing to. We can create our own inventory file filename - inventory.ini [web_servers]  web01 web02 [db_servers] db01 db02 Create a ansible.cfg file under working directory or edit the default confi...

Selenium - Basics

Selenium: Selenium is an open source automated testing Suite for web applications across different browsers and platforms. Selenium has 4 major components: Selenium Integrated Development Environment(IDE) Selenium Remote Control(RC) Web Driver Selenium Grid 1. Selenium Integrated Development Environment: Selenium IDE is the simplest framework in the Selenium Suite and very easiest to learn. It has got record playback and saving tests and inbuilt reporting tool.  2. Selenium Remote Control: Selenium RC was the flagship testing framework of the whole Selenium project for a long time. This is the first automated web testing tool where it allows users to use their programming language they prefer. RC comes in 2 forms: 2.1 Selenium Server:      Selenium Server receives selenium commands from your program, interprets them and reports  back the results of those running tests. Selenium Core is a Java Script program which execute...

Selenium Xpath

XPath  XPath is abbreviated as XML Path.  Xpath is used to find the location of any element on the web page using HTML DOM structure. Basic format of XPath is : Xpath = //tagnanme[@attribute='value'] //  : Select current node. Tagname  : Tagname of the particular node. eg : input, img, div etc @   : Select attribute. Value   : Value of the attribute. Different locators are used to find the element on web pages accurately. ID  ClassName Name LinkText XPath CSSPath Types of XPath: Absolute XPath Relative XPath Absolute xpath: It is direct way to find the element right from the root element of the webpage. The disadvantage of the absolute xpath is that if there are any changes made in the path of the element then xpath gets failed. It begins with the single forward slash(/), which means you can select the element from the root node. example : html/body/div[1]/section/div[1]/div/div/div/div[1]/div/di...