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 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).
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.
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.
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.
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.
It is the way we can separate different Python environments for different projects.
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.
Easy to manage dependencies like libraries, online services, and programming scripts.
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.
By sandboxing Python projects it provides security to the project.
Also, it prevents unauthorized access to the global libraries installed in the system.
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.