Selenium Architecture
Published: 2024-06-11 13:12:27

**Describe python selenium architecture in details?**
**Selenium** is an open-source framework for automating web browsers.
Architecture of selenium is designed to be modular and flexible, allowing users to choose the components that best suit their needs.
**1.Selenium IDE**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wgqsma6lz351l24ay7ja.png)**

 

IDE stands for integrated development environment.
User needs to download and install the extension for that web browser.
It can automate as well as record the entire automation process.
**2.Selenium RC**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f4mx8tgh0k9tav6bx7rm.png)**

 
Selenium RC comprises of two parts. 
Client libraries for preferred computer language
A server that launches and kills browser automatically.
This is older version of selenium that is not used much anymore.
**3.Selenium web driver**

 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aam2h7m9zixsox9ihfd2.png)


It is a major component of selenium test suite.
It provides interface between programming language in which we write our script and web browser itself. It provides a seamless programming interface that allows effective communication and control over web browsers.
It is composed of various components that work together. 
•  **Selenium Client Library**
  It consists of language bindings or command utilized for crafting automation scripts.
 These commands are compatible with TCP\IP and HTTP protocols.
 They utilize wrappers to transmit the script commands to web browser for test execution.

•	**Selenium API**
 It is a set of rules and regulations which your python program used to communicate with each other.
It helps in automation without need of user to understand what is happening in background.

•	**Json wire protocol**
 Commands user writes get converted into JSON (java Script Object notation) which is t   hen transmitted across the network or to you web browser so that it can be executed or automation and testing. Json requests send to client using TCP-IP\HTTP protocol.

•	**Browser drivers**
 Selenium web drivers communicates directly with the web browsers, controlling actions. This allows you to automate tasks on the web browser without any manual intervention.

**4.Selenium Grid**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3itz17iz0f5mivqzy1ko.png)
 
It is used to run parallel tests on multiple devices running on different browsers at different geographical locations. 
It works on Master-slave architecture.

**What is the significance of the python virtual environment? give some examples in support of your answer?**
Python Virtual environment is an isolated space where you can work on your python project, separately from your system installed python.
You can setup you ow libraries and dependencies without affecting the system python.
Consider you are working on a two web bases projects one of them uses Django 4.0 and other one is using Django 4.1. in such situations, we need to create a virtual environment in python that can be useful to maintain dependencies of both projects.

We use a module named virtual which is a tool to create virtual environments in python, isolated from system environment python.

Install Virtual python environment.
pip install virtualenv

Test your installation:
virtualenv - - version

create a new virtual environment for your project.
virtualenv <project folder name>
To activate virtual environment, go inside project folder.
Cd <project folder name>
Scripts<activate>
Once environment get activated the name of virtual environment will appear on the left side of the terminal.
Then you can install your dependencies are per current project
Pip install Django==1.9

Once you are done with work of current project, then you can deactivate your virtual environment.
Scripts<deactivate>

**Example of Python Virtual environment**
 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5rm6k5a06p6daj0z0e8y.png)
Here in diagram, we have shown as 3 virtual environments and each environment have different python version and different 3rd party libraries.