DEV Community

Ambika
Ambika

Posted on

Describe Selenium Architecture in detail

Selenium is an open-source framework for automating web browsers. It provides a way to interact with web elements, simulate user actions, and automate testing of web applications.

The architecture of Selenium is designed to be modular and flexible, allowing users to choose the components that best suit their needs.

Selenium IDE (Integrated Development Environment).

It’s a simple web browser extension. Just download and install it for your browser to get started.

Selenium IDE can both automate and record your actions on a website. However, it’s worth noting that many prefer using Selenium scripts instead of the IDE for more control and advanced functionalities.
Selenium Remote Control

Selenium RC helped the test script talk to the Selenium server, which then communicated with the tested browser.
This made it a bit more troublesome to communicate between the driver and web browsers. It was an older version of selenium that is not used much anymore.

It has been replaced by Selenium WebDriver, Which is much better and easy to use.
Selenium WebDriver:

It is the major component of selenium architecture serving as a crucial link between programming languages and web browsers. It provides a seamless programming interface that allows effective communication and control over the web browsers.

It is comprised of various components that work together they are the Selenium client library, Selenium API, JSON wire protocol, Browser Drivers, and Browsers. In detail follows:
i*. Selenium Client Library:*

It consists of language bindings or commands utilized for crafting automation scripts. These components adhere to W3C protocols such as HTTP and TCP,

and utilize the wrappers to transmit script commands to the web browser for test execution.
ii. Selenium API:

It serves as a framework of rules and regulations that enable continuous communication among different parts of your Python program.
This framework streamlines automation, sparing the user from needing an in-depth understanding of the underlying processes.
iii. JSON Wire Potocol:

In automation testing, the commands you write are transformed into JSON (JavaScript Object Notation) format. This JSON data serves as a structured representation of your commands and is transmitted across the network or to your web browser, facilitating automation testing processes.

The communication between the client and server occurs through the HTTP protocol, a standardized protocol widely used for data transmission on web browsers.
iv. Browser Drivers:

Selenium WebDriver communicates directly with the web browser, controlling its actions just like a real user would. This allows you to automate tasks on the web browser without any manual intervention.
Performing tasks such as clicking buttons, entering text, navigating between pages, and verifying content.
Selenium Grid

Selenium Grid is a robust tool employed to conduct parallel tests across numerous devices operating various browsers, even across disparate geographical locations.

It can execute multiple test cases, by employing a master-slave architecture, it distributes the test cases as slaves, ensuring seamless and simultaneous execution across diverse testing environments.

What is the significance of the Python Virtual Environment? Give some examples in support of your answer ?
A Python virtual environment is like a mini world for your Python projects. It holds its own Python setup, including the Python language itself and any extra tools you need, like libraries or packages.
The idea of virtual environments is to keep each project separate and safe from messing with others. Think of it as having your geometry box to use only for geometrical diagrams and graphs.

In this way, you can manage what tools and versions you use for each project without worrying about them clashing or causing problems with other projects. Python virtual environments help you keep your projects organized, tidy, and free from conflicts with each other.
Creating a Virtual Environment:

To create a virtual environment named requirement;
— python3 -m venv requirement.

Activate the Virtual Environment by using this command

on Windows — .venv\Scripts\activate | .venv\Scripts\python

  1. If you want to deactivate the Virtual Environment

use the command— deactivate.

A Real-life Example of a Virtual Environment

Think of virtual environments like separate kitchens in a shared house. Each kitchen is fully equipped with its own set of utensils, ingredients, and appliances.

Now, imagine you’re cooking two different recipes at the same time. Recipe A calls for a specific type of milk, let’s say “Cow Milk” while Recipe B needs a different type of milk, “Soy Milk.”

Without separate kitchens (virtual environments), you’d have a problem. You can’t use both types of milk in the same kitchen because they might affect each other’s taste or texture.

But with virtual environments (separate kitchens), you’re all set! You can mix and match ingredients freely in each kitchen without worrying about conflicts. Recipe A has its own kitchen with Cow milk, and Recipe B has its dedicated space with Soy Milk. This way, both recipes turn out perfect, just the way you intended.

Top comments (0)