Selenium Architecture consists of mainly four stages to function.
Selenium client libraries such as python,Java, Java script , C# and Ruby etc. Whenever we start executing the test scripts in respective languages our test code will be converted to JSON format in the form of keys and values pairs.
JSON stands for JavaScript Object Notation.JSON helps to transfer data between client to server and vice versa by HTTP protocol.
Now the converted JSON code by client libraries will then be transferred to brower drivers over HTTP protocol.
Each browser has its own browser driver.This driver helps us to interact with the browser and execute the commands.
When JSON sends the instructions which they receive from client libraries to the browser driver. Now the browser driver will interact with the browser, then they execute those commands and send the HTTP response back.
Finally , Status of the response will show on the monitor by using JSON wire protocol.
Here , JSON wire protocol sends two types of requests to browser driver.
POST Request : When POST request is sent to the browser driver then action will trigger on the browser.
GET Request : When GET request is sent to the browser driver then action will trigger on the browser and status will be sent to the browser driver over HTTP.Now the browser driver will send the response to monitor by using JSON wire protocol.
In this example, We launch the webpage and get the text which we entered in the edit box and print on the monitor.
SeleniumExample.py
rom selenium import webdriver import time from selenium.webdriver.common.by import By driver = webdriver.Chrome("/Users/admin/Documents/Skill2Lead/Others/drivers/chromedriver.exe") driver.get("http://www.dummypoint.com/seleniumtemplate.html") time.sleep(2) element = driver.find_element(By.ID,"user_input") element.send_keys("Skill2Lead") time.sleep(2) print("text :",element.get_attribute('value')) time.sleep(5) driver.quit()