Selenium?
Published: 2024-04-22 04:46:59

> [Header image by Ben Mills from Wikimedia](https://commons.wikimedia.org/wiki/File:Selenium-dioxide-chain-3D-balls.png)

At a previous job, I would chat with some of the QA Automation Engineers about their work and they would often mention using something called “Selenium”. They would say that it made their work easier while giving detailed explanations for how.  I knew these Knowledge Nuggets™ would be useful for my future aspirations, but unfortunately for me, a double whammy of a bad memory along with basically zero knowledge of the terms they used means I currently Know Nothing™.
So, time to do some research!


## **Selenium History**
The Selenium collection started in 2004 with a program called "JavaScriptTestRunner".  It was created by Jason Huggins to test a Time and Expenses application for his employer, ThoughtWorks.  But was later renamed Selenium Core and released as an open source program.
The name ‘Selenium’ was chosen 4 years prior in an email discussing one of the company’s competitors, Mercury Interactive. Jason made a joke about Selenium being an antidote for Mercury poisoning and the team liked it so much that it stuck.
The collection began expanding when another Engineer at the company, Paul Hammant, created ‘Selenium Remote Control’ to circumvent the “Same Origin Policy” which required JavaScript to be used on the same Domain name. Meaning that the testers had to install Selenium Core and Web servers on their individual computers to be able to work.
Then Patrick Lightbody developed Selenium Grid which made it possible for multiple tests to run simultaneously, speeding up testing even more.
This has been followed by many more helpful expansions over the years.


## **Selenium Uses**
Selenium is a collection of resources used in automated browser testing.  They are used to verify that a website functions as intended across a variety of browsers on a variety of operating systems and devices.  
Your test code can also be written in several different programming languages: JavaScript, Ruby, & Perl to name a few.
As previously mentioned, it can run several tests simultaneously, can save reusable test scripts, and produce detailed reports for tracking test results.
Selenium is a type of open source code, meaning that it is free to use, modify, and redistribute as you please.  This freedom & flexibility makes it valuable for efficient Quality Assurance testing.


## **Selenium Breakdown**
The main ‘Selenium Suite’ is composed of multiple components.  Most notably: IDE, RC, WebDriver, and Grid.

**Selenium IDE**
Selenium has it’s own Integrated Development Environment.  It is used as an Firefox Add on or a Chrome Extension.  It’s primary function is to record user interactions and translate them into tests.  Which provides a way for testers with no programming skills to create & execute automated tests.
Selenium IDE is another expansion like the ones mentioned in the History section. It was created by Shinya Kasatani to speed up the test case creation process and was donated to the Selenium Project in 2006.

**Selenium RC**
Selenium Remote control, which was also previously mentioned, is used for remotely writing, and executing, automated browser tests in multiple programming languages.  Unlike the IDE, you must have some programming skills in order to create and execute tests.

**Selenium WebDriver**
WebDriver is Selenium’s enhanced version of RC. It’s a framework that lets you perform cross-browser testing.  You can choose any programming language to work in and does not require a unique server for testing.  Instead, WebDriver can open & control a browser instance on its own to execute tests & receive the results. It can do this remotely, like Selenium RC.
Also like RC, WedDriver requires that you have knowledge in at least one programming language.

**Selenium Grid**
Grid allows the execution of tests across multiple browsers, machines, and operating systems all at the same time.  This is achieved by using a Hub-Node system. One machine is designated as the Hub which distributes commands to the computers, nodes, connected to it. The Hub passes information to each node based on its specific system configurations.  The machine receives its unique commands then opens its browser to perform all tests demanded of it.


## **Selenium Accessibility**
Considering the Selenium Suite is free to download & use by anyone, I believe that can be considered pretty darn accessible. Documentation was easy to find for the few languages I searched up.  The Selenium dev site even has command syntax for a variety of languages along with full code examples on GitHub.
Here’s a few of the JavaScript examples (chosen due to JS being the language I am most familiar with at this time):
Reading the URL from the browser's address bar - 
```
let currentUrl = await driver.getCurrentUrl();
```
Refreshing the current browser page - 
```
await driver.navigate().refresh();
```
Adding a cookie to the current browsing context - 
```
await driver.manage().addCookie({ name: 'key', value: 'value' });
```
Selecting a specific Window or tab in your browser - 
```
await driver.getWindowHandle();
```


## **Selenium Resources**
- [BrowserStack](https://www.browserstack.com/selenium)
- [GitHub](https://github.com/SeleniumHQ)
- [Selenium Dev](https://www.selenium.dev/)
- [Webomates](https://www.webomates.com/blog/software-testing/selenium-testing/)
- [Wikipedia](https://en.wikipedia.org/wiki/Selenium_(software))

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

> Image from [Wikipedia](https://en.wikipedia.org/wiki/Selenium_(software)) & [Selenium.dev](https://www.selenium.dev/)