#PYTHON SELENIUM ARCHITECTURE AND THE SIGNIFICANT OF PYTHON VIRTUAL ENVIRONMENT#
krishnaveni
Posted on May 25, 2024
** python selenium architecture**:
The Python Selenium architecture allows for the automation of web browser interactions, making it a powerful tool for web testing and other automation tasks.
Selenium is an automation tool used for web application testing, and Python is a programming language. Selenium scripts can be written using only programming languages; the most commonly used programming languages are Java and Python.
Architecture of Selenium WebDriver (Selenium 3)
Selenium WebDriver Architecture is made up of four major components:
1- Selenium Client Library
The Selenium Client Library consists of various language libraries for Java, Ruby, Python, and other supported languages.
2- JSON WIRE PROTOCOL Over HTTP Client
JSON denotes Javascript Object Notation. This component of the Selenium WebDriver plays an important role in the Selenium automation process by transferring data between the server and a client on the web. JSON is an acronym for JavaScript Object Notation. It is an open standard that provides a transport mechanism for transferring data between client and server on the web.
3- Browser Drivers
Browser drivers are used to carry out the communication between the Selenium WebDriver and the respective browser. The Browser drivers ensure that no details are revealed to the browser regarding the internal logic of the functionalities of the browser.Selenium browser drivers are native to each browser, interacting with the browser by establishing a secure connection. Selenium supports different browser drivers such as Chrome Driver, Gecko Driver, Microsoft Edge WebDriver, Safari Driver, and Internet Explorer Driver.
4- Real Browsers
Selenium provides support for multiple browsers like Chrome, Firefox, Safari, Internet Explorer etc.
In selenium architecture and selenium 3 we have json protocol but in selenium 4 we dont have any intermediates like json.The architecture of Selenium 4 is similar to Selenium 3, however it uses W3C protocol instead of JSON wire protocol for communication between Client Libraries and Browser Drivers.
WebDriver in Selenium 4 is fully W3C compliant stands for the World Wide Web Consortium, an international community that develops and maintains standards and guidelines for the World Wide Web. The main aim of the W3C is to ensure the long-term growth and interoperability of the Web.
It creates open standards and specifications that promote compatibility and consistency across various web technologies and platforms. And when we say Selenium 4 is W3C compliant it states that Selenium adheres to the standards and specifications laid by the W3C for web automation.
All the browsers and the browser drivers in Selenium architecture follow W3C, except Selenium 3 WebDriver. And hence, JSON Wire Protocol is used to encode and decode the requests and responses. Selenium 4 WebDriver was made W3C compliant to make the communication easy and direct between the client libraries and the browser drivers. Improved communication led to more stability.
This has also enhanced browser compatibility, performance and efficiency as there is no overhead of HTTP requests and responses for communication between the WebDriver client and the browser driver. Instead, WebDriver now utilizes native browser communication channels and protocols.
-> what is the significance of the python virtual environment? Give some examples in support of your answer?
A virtual environment is a tool that helps to keep dependencies required by different projects separate by creating isolated Python virtual environments for them. This is one of the most important tools that most Python developers use.
Imagine a scenario where you are working on two web-based Python projects one of them uses instagram 7.0 and the other uses instagram 7.1. In such situations, we need to create virtual environment in Python that can be really useful to maintain the dependencies of both projects.
By default, every project on your system will use these same directories to store and retrieve site packages (third-party libraries). Now, in the above example of two projects, you have two versions of instagram. This is a real problem for Python since it can’t differentiate between versions in the “site-packages” directory. So both v1.7 and v1.8 would reside in the same directory with the same name. This is where virtual environments come into play. To solve this problem, we just need to create two separate virtual environments for both projects. The great thing about this is that there are no limits to the number of environments you can have since they’re just directories containing a few scripts. A virtual Environment should be used whenever you work on any Python-based project. It is generally good to have one new virtual environment for every Python-based project you work on. So the dependencies of every project are isolated from the system and each other.
We use a module named virtualenv which is a tool to create isolated Python environments. virtualenv creates a folder that contains all the necessary executable**** to use the packages that a Python project would need.Installing virtualenv = $ pip install virtualenv
Once you are done with the work, you can deactivate the virtual environment by the following command:(virtualenv_name)$ deactivate.
Posted on May 25, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 9, 2024