Frontend Development 12 min read

Understanding Selenium: Architecture, Components, and a Sample WebDriver Test Script

This article introduces Selenium as a suite of web UI automation tools, explains the architecture of Selenium 1 and WebDriver, details the roles of the Selenium server and client libraries, and presents a simple Java WebDriver script for logging into an ITA portal, including code snippets and element locating strategies.

DevOps
DevOps
DevOps
Understanding Selenium: Architecture, Components, and a Sample WebDriver Test Script

Selenium is a collection of web‑based UI automation testing tools that support B/S applications across multiple platforms, browsers, and programming languages. It can directly control browsers to perform actions, making it suitable for comprehensive front‑end testing.

The Selenium suite includes Selenium IDE, Selenium RC (Selenium 1), Selenium WebDriver (Selenium 2), and Selenium Grid. Selenium IDE is a Firefox plug‑in for recording and replaying user actions, while Selenium RC provides a server that interprets Selenium commands (Selenese) and can be driven by various languages such as Java, Python, C#, Ruby, etc. Selenium WebDriver merges Selenium RC and the original WebDriver project, offering a more direct, faster, and more stable way to control browsers via native drivers.

1. Selenium overall framework – The core Selenium Core is written in JavaScript (based on JsUnit) and runs in any JavaScript‑enabled browser. Selenium Grid enables parallel execution of tests across different environments, greatly accelerating functional testing.

2. Selenium 1 (RC) working principle – Selenium RC consists mainly of a Selenium Server that receives commands from test programs, interprets them, and injects Selenium‑Core into the browser. The client library files provide language‑specific APIs that generate Selenese commands and communicate with the server via HTTP GET/POST requests.

2.1 Selenium Server – The server launches Selenium‑Core, acts as an HTTP proxy, and processes Selenese commands. It can receive commands from any language that can issue HTTP requests.

2.2 Client library files – These libraries expose programming interfaces for each supported language, allowing developers to write test scripts that send commands to the Selenium Server and receive results.

3. WebDriver working principle – WebDriver uses a driver (e.g., FirefoxDriver, ChromeDriver) that runs an internal HTTP server. Test scripts send HTTP requests (JSON‑encoded) to the driver, which translates them into native browser actions. The driver returns responses indicating success or failure.

Typical request/response flow:

Test script creates a request (e.g., driver.get("http://ita.abc/ita/login.action") ).

The driver’s HTTP server receives the request, performs the action in the browser, and sends back a JSON response such as {"name":"get","sessionId":"******","status":0,"value":""} .

WebDriver supports the JSON Wire Protocol, which standardises the HTTP communication and enables operations like opening URLs, clicking elements, sending keys, and retrieving page information.

4. Concrete example (Java WebDriver script)

The following simple script logs into the ITA management portal by opening the login page, locating the username field by its id , entering credentials, and submitting the form.

WebDriver driver = new FirefoxDriver(); // instantiate a driver

driver.get("http://ita.abc/ita/login.action");

driver.findElement(By.id("userNameInput")).sendKeys("myUser");

driver.findElement(By.id("passwordInput")).sendKeys("myPass");

driver.findElement(By.id("loginButton")).click();

During execution, the driver sends HTTP POST requests to the browser driver (e.g., POST /session/{sessionId}/url ) and receives JSON responses indicating the status of each operation.

5. Summary

Selenium comprises IDE, WebDriver, RC, and Grid components. Selenium 1’s client libraries generate Selenese commands that the Selenium Server executes via Selenium‑Core, while WebDriver directly drives browsers for faster, more reliable automation. However, WebDriver requires compatible driver binaries for each browser version.

JavapythonAutomated TestingSeleniumwebdriver
DevOps
Written by

DevOps

Share premium content and events on trends, applications, and practices in development efficiency, AI and related technologies. The IDCF International DevOps Coach Federation trains end‑to‑end development‑efficiency talent, linking high‑performance organizations and individuals to achieve excellence.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.