Selenium Architechture and Virtual Environment
AeroSiva
Posted on October 3, 2023
Selenium architecture:
In Selenium Framework Selenium WebDriver supports overall browser-based automation tests majorly. WebDriver is the remote-control interface component that allows test programs to instruct and interact with browsers, manipulate DOM elements in a web page, and control the user agent’s behaviour.
Selenium WebDriver and Selenium RC were merged to form Selenium 2.0 and later upgraded to Selenium 3.0 now Selenium 4.0 is further developed.
Now, all companies widely use a 3X version of Selenium. Now 4x version has been introduced these two have completely two different architectures.
Selenium WebDriver 3.0 Architecture.
Selenium Client Libraries
Selenium client libraries or language bindings permit Selenium to support multiple languages to write test scripts like Ruby, C#, Python, and Java. It contains classes and methods required to write test automation scripts. It provides an application programming interface (API), i.e., a set of functions that performs the Selenium commands from the test script.
Web Driver protocol clients (They are thin wrappers around WebDriver protocol HTTP calls) and WebDriver-based tools are two major groups (These are higher-level libraries that allow us to work with WebDriver automation).
Json wire protocol
Selenium WebDriver 3.0 uses JSON to communicate between Selenium client libraries and browser drivers. The request sent by the client is converted into an HTTP request for the understanding of the server and it again returns information in the JSON format to the client. It uses Layer 5 of the OSI reference model.
Browser Driver
Browsers that support selenium have unique browser drivers like ChromeDriver for Google Chrome and GeckoDriver for Mozilla Firefox. It takes commands from the test scripts and passes them to the browser and is responsible for user actions like mouse clicks, keyboard inputs, etc.
- This HTTP request is routed through the HTTP Server which in turn directly drives the command execution on the browser.
- The browser then sends back the test status to the HTTP Server, which in turn forwards it to the test automation script.
Browser
Google Chrome, Mozilla Firefox, Microsoft Edge, and Apple’s Safari are some of the browsers Selenium supports it is also one of the components of Selenium Architecture. When these browsers receive a command it calls for respective commands and executes the test.
Selenium WebDriver 4.0 Architecture.
Here Json wire protocol is replaced by the W3C protocol. The problem with JSON protocol is that the commands need to be converted into HTTP requests because the server only understands protocols but with the introduction of the W3C protocol there is no such need so the test can happen faster.
Virtual Environment
It is the way we can separate different Python environments for different projects.
Significance of virtual environment
Isolation
If one is working on multiple projects and each project relies on packages like Flask, Django but in different versions, then installing these packages globally on his device may create conflicts and may even break the working projects. To avoid conflict virtual environment is created individually for every single project. And on these virtual environments, we can install all the necessary dependencies like libraries.Dependency management
Easy to manage dependencies like libraries, online services, and programming scripts.Version Compatibility
Simultaneously working on different versions of Python in different projects.Clean and Reproducible Environments
Easy to share projects and deploy we can give requirement files so the client can reproduce the environment.Security
By sandboxing Python projects it provides security to the project.
Also, it prevents unauthorized access to the global libraries installed in the system.Portability
Packaging the entire project including its virtual environments project has higher portability.Enabling Continuous Integration (CI) and Deployment
Virtual environments play an important role in CI/CD (Continuous Integration and Continuous Deployment) pipelines. These pipelines use virtual environments to set up reproducible build and test environments.Work on multiple Python projects
Usually, all IT workers including Developers and Testers work on multiple projects and it is highly useful in that case.
Posted on October 3, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.