What is Selenium?

What is Selenium?

Selenium is open-source framework for automated testing and validation of web applications. It is not bound to specific programming language. Tests can be written in C#, Java, JavaScript, Python… 

Using Selenium ensures that you execute action, or a group of actions, in the exact same way, every time, across every browser. And those actions can be executed faster through Selenium tests than if the tester would do them manually. So, by using Selenium tests we can ensure clients that the web application that we make for them will be tested in a consistent way.

Selenium test suite contains: Selenium IDE, Selenium RC, Selenium WebDriver, Selenium Grid.

Selenium IDE is an extension for Firefox and Chrome that can generate tests and record them. You can use this tool and run tests without any programming knowledge.

For using Selenium RC, you are required to know at least one programming language.  But it provides more flexibility when writing tests.

Selenium WebDriver is advanced version of Selenium RC. It was made to overcome limitation that Selenium RC had. It can also be used with multiple programming languages.

Selenium Grid is used to run tests on different browsers, machines and operating systems at the same time, making cross browser testing easier and faster.

In order to execute a Selenium test, to run and complete an action, firstly we need to find an element that we want to test. That can be done in a couple of ways. Selenium has two methods for finding web element on a web page, findElement and findElements.

Former returns single, first matching, web element and latter returns a list of all matching web elements.

Syntax used for locating elements is:

WebElement elementName = driver.findElement(By.locator (“value”));

and attributes that can be used as a locator are:

  • ID
  • Name
  • Class name
  • Tag name
  • Link text
  • XPath

The following is an example of a small test from BrowserStack documentation. 


public void login() {

System.setProperty(“webdriver.chrome.driver”, “path of driver”);

WebDriver driver = new ChromeDriver();




WebElement username = driver.findElement(By.id(“user_email_Login”));

WebElement password = driver.findElement(By.id(“user_password”));

WebElement login = driver.findElement(By.name(“commit”));






String actualUrl = “https://live.browserstack.com/dashboard”;

String expectedUrl = driver.getCurrentUrl();



Firstly, we have a @Test annotation, to tell Selenium that this method can be run as a test case. 

Then, below the annotation, we have a method that is created to test login process. We create Selenium WebDriver, configure browser window size if needed, and navigate to sign in page. We locate needed elements and enter required information. Once we submit that we expect to redirect to certain URL, and we check if expected and actual URLs match. If everything is working properly the test will pass.

Selenium automated testing helps us test and retest functionalities on our web applications on multiple machines and in multiple browsers fast and accurate. And that ensures that the client gets exactly what they asked for and that everything works as it should. Selenium helps speed up testing process allowing developers to spend more time on creating new things. That is why Selenium automation tool is very important, very useful and is being used more and more in the IT industry.