What is Selenium

Selenium is a set of open-source tools that allows you to automate web applications. It provides a single interface that lets you write test scripts in popular programming...

Selenium is a set of open-source tools that allows you to automate web applications. It provides a single interface that lets you write test scripts in popular programming languages like Ruby, Java, NodeJS, PHP, Perl, Python, and C#, among others.

Selenium is not just a particular tool or utility. It is a loaded package of various testing tools and is referred to as a suite. Each of the testing tools/utility is specifically designed for different testing requirements.

  • Selenium IDE (Integrated Development Environment)
  • Selenium WebDriver
  • Selenium Grid
  • Selenium RC (Remote Control): It is deprecated and obsolete now
what is selenium

Selenium IDE

Selenium IDE (Integrated Development Environment) is primarily a record-and-run tool that test case developers use to develop test automation scripts. IDE is an easy-to-use interface that records user interactions on the browser and exports them as a reusable script.

Selenium IDE equips users with playback and record functionality. It lets users create and manage several tests in no time.

Selenium IDE was available only as a Firefox extension. But now, with the recent version upgrade (3.17.0), the Selenium community introduced an IDE that also supports the chrome browser. This means we can develop test automation scripts on Chrome or Firefox browsers; however, you can run all of your Selenium IDE tests on any browser using the command line runner.

Recording: IDE allows the user to record all the actions performed in the browser. These recorded actions as a whole are the test scripts.

Playback: The recorded script can now be executed to ensure that the browser is working accordingly

Saving: The recorded script is saved with a “.side” extension for future runs and regressions.

Advantages of Selenium IDE

  • Provides a GUI (Graphical User Interface) for quickly recording your interactions with the website.
  • Easy-to-use tool. It can be used by someone new to developing automated test cases for their web applications.
  • Records multiple locators for each element it interacts with. If one locator fails during playback, the others will be tried until one is successful.
  • Test cases can be re-used using the run command. For example, this feature allows you to reuse the login logic in multiple places in the entire suite.
  • Selenium IDE ships with an extensive control flow structure, with commands like If, While, and times.
  • One does not require any particular setup to get started with Selenium IDE. You need to add the extension of your specific browser.

Limitations of Selenium IDE

  • Not suitable for extensive data
  • Connection with the database cannot be tested
  • Cannot handle the dynamic part of the web applications
  • Does not support capturing of screenshots on test failures
  • No feature available for generating results reports.

Selenium WebDriver

As discussed in the previous section, Selenium IDE is an extension to Firefox or Chrome browsers that allows users to record and playback tests. The record and playback paradigm may not be suitable for many test automation scenarios and comes with its limitations. So the second tool in the selenium suite, Selenium WebDriver, provides more control and application to automate the complex test cases.

WebDriver is a library containing multiple APIs that allows you to programmatically interact with a browser on an operating system the way a real user would. Tests can be written for WebDriver in any programming language supported by the Selenium project, including Java, C#, Ruby, Python, and JavaScript.

WebDriver is predominantly the first choice of any tester for automating web applications.

WebDrivers for different browsers

Advantages of WebDriver

  • Support for more programming languages, operating systems, and web browsers
  • Support for batch testing, cross-browser testing, and data-driven testing

WebDriver Commands

Selenium WebDriver Commands can be categorized as follows.

  • Commands for browser: Used to execute operations on the browser itself, such as opening a browser, shutting down a browser, etc.
  • Commands for navigation:  Used to move through the website. For example, open a web page URL, go to another web page by clicking any element, go back, forward or refresh the web page, etc.
  • Commands for web elements: Used for web page interactions, such as identifying elements, getting attribute properties, asserting text in WebElement, etc.
  • Action commands: Provides granular control over input devices. For example, Keyboard actions and mouse actions.

Selenium Grid

Selenium grid is part of the selenium testing suite; It enables parallel testing on different machines against different operating systems and browsers. This type of testing is referred to as distributed test execution.

Advantages of using Selenium for Automated Testing

Some unique benefits make it the preferred choice of organizations for web application testing.

  • Languages & Frameworks: You can write your scripts in multiple programming languages, like Ruby, Java, NodeJS, PHP, Perl, Python, and C#
  • Open source: The biggest strength of Selenium is that it is an open source framework and hence very cost-effective for the organization to adapt. The tool can be freely downloaded and has community-based support.
  • Multi-browser Support: Supports multiple browsers, namely Internet Explorer, Chrome, Firefox, Opera, and Safari. “One Selenium script for all browsers” is what Selenium commonly focused on and has been aiming at. You don’t need to rewrite scripts for every browser, just one hand for all browsers.
  • Different operating support: Supports different operating systems such as MS Windows, Linux, and Macintosh. You can build Selenium test suites on any supported platform and the same test suite on another platform. Developers and testers can write test automation scripts without focusing on the platform it will run on.
  • Integration with Other tools: Can easily be used with popular software development and testing tools. For example, it works seamlessly with Maven, ANT, TestNG, NUnit, JUnit, JMeter,  cloud grids like Lambda test, Browser Stack, CI systems like TeamCity, Jenkins, and many other test management tools.
  • Community Support: The Selenium community is quite active and open. Therefore, there is a lot of information and help available when needed.

Limitations of Selenium

  • It supports only Web applications.
  • There is no built-in report generation
  • The handling of dynamic elements is a cumbersome task.

What types of Testing can be Automated with Selenium

Many types of testing can be done with selenium.

Related Articles