chat-image

What is Selenium?

 

By Kaloyan, QA Lead at Flat Rock

When you think about what to automate, the first thing which appears in one’s mind probably will be the way in which the QA tests the system by clicking on every button and filling all fields with different types of information.

One of the best tools to do that is Selenium. It’s a free UI tool which interacts with the system in the same way like the QA specialist. You can use one of the three types of the tool which are developed till now:

1. Selenium IDE - it’s a Firefox plugin and provides an easy-to-use interface for developing automated tests. The main advantage of the IDE is that it can record the user actions and then these actions/cases could be exported into a reusable script in one of many programming languages. The main disadvantage is that it cannot be used alone as the risk of wrong results is high.

2. Selenium 1.0 RC – this has been the main tool for testing for a long time. It’s a server-based and is used to run the scripts written on one of the programming languages – Java, C#, PHP, Python, etc. Some of the disadvantages are that it runs on older browsers versions, the commands are more complicated than in the WebDriver and everything is translated to the Selenium Core’s language and then simulated through the browser.

3. Selenium 2.0 WebDriver - it’s an improved version of the Selenium Server. The WebDriver could be used standalone (no need of a server) which makes it simpler than the RC. Most of the browsers could be used for testing. All you need for that is a web driver for this browser. Currently there are drivers for Chrome, IE 6-11, Firefox, Safari, Opera, HtmlUnit, Android (using Appium), iOS (using Appium). Selenium RC’s API is more mature but contains redundancies and often confusing commands. The WebDriver is simpler in that aspect. It interacts with page elements in a more realistic way. Currently the official Selenium version is the WebDriver. The RC server is no longer supported and there will be no updates for it.

Now let’s dig deeper in what the WebDriver is. It’s a library with different methods, which are basically used for interacting with the html elements displayed on the page. The most used methods are for finding specific elements in the html, for example buttons, text fields, check boxes, etc. The WebDriver uses locators for finding them:

→ By ID – it’s the best way to find an element on the page, because the ID is unique and the driver will not be confused. It would be good to avoid auto-generating IDs.

→ By class – this refers to the attribute on the DOM element. Often there are many DOM elements with the same class and in this situation it will be hard to find a specific one.

→ By tag name – the DOM tag element on the page. Again – there will be many elements with the same tag on the page.

→ By name – find the input element with matching its name attribute.

→ By link text – find a specific hyperlink on the page by matching its visible text.

→ By partial link text – find a specific hyperlink with partial matching its visible text.

→ By CSS selector – it’s a locator strategy by CSS. Native browser support is used by default but some CSS locator which might work in one browser but may not work in another.

→ By XPath – WebDriver uses a browser’s native XPath. On those that don’t have native support, Selenium HQ have provided their own implementation.

In some cases, it’s not easy to find a specific element on the page. As it was mentioned before, Selenium is working like an end-user and can interact only with elements which are visible on the page at the moment. In case that something cannot be find with these locators, the QA specialist should use a different approach.

Selenium 2.0 WebDriver has multiple browser support. The only limitation is when a new version of the browser is released. Then it will take time for the new version of the WebDriver to be developed.

Selenium is good for regression testing. Every test case written by the QA should be transformed into a script. Selenium supports different languages through Selenium drivers – Java, C#, Python, PHP, Haskell, JavaScript, Ruby, Perl, Objective-C. To run all scripts one after another, the QA should use a specific framework (JUnit for Java, NUnit for .NET, PHPUnit for PHP, etc.) or a Selenium server. One of the disadvantages is that in most cases the QA specialist should write different scripts for every project, no matter that some of the functionalities (such as login or register) will be the same.

It’s possible to integrate Selenium with JIRA, Jenkins or other servers and tools which the development team is using in the project.

Selenium 2.0 WebDriver is a good way to automate one big part of the QA process. It’s also suitable for mobile applications with its Appium library. Earlier this year Selenium HQ announced their new tool – Selenium 3.0 WebDriver with an improved functionality.

Flat Rock is specialized in development and testing of bespoke software both manually and automated. Contact us to learn how to optimize your product or in case you need a hand in verifying software quality.

Similar Blogs

View All
An illustration of a laptop. The banner reads: Implementing QA Best Practices in Agile Software Development.
Quality Assurance
Software Development

Implementing QA Best Practices in Agile Software Development

Written by: Nino Dakhundaridze on January 23, 2024
Quality Assurance vs Quality Control: Differences and Significance
Quality Assurance

Quality Assurance vs Quality Control: Differences and Significance

Written by: Nino Dakhundaridze on November 21, 2023

Looking for a trusted development partner?

Our team is ready to discuss and offer the most suitable approach for bringing your ideas to market, along with feasible solution alternatives.