Share This Post

Business / Education - Technology / Internet of Things (IoT) / Technology

Selenium

Selenium

Selenium is an open source tool which is used to execute test scripts on web applications. It supports various programming languages such as Java, C#, PHP, JavaScript, and Ruby and supports various operating systems for execution like Windows, Linux, MacOS, etc.  Also being a cross-platform most top companies prefer it rather than using Quick Test Professional (QTP) and CodedUI, which are both licensed versions.

Each browser has its own driver for executing the test scripts; for executing Selenium scripts on Chrome, we have Chromedrivers. For IE, we have Internet Explorer drivers. For Safari, we have Safari drivers. For Opera, we have Opera drivers. But only Internet Explorer (IE) and Google Chrome support both the 32bit and 64bit versions.

Current Types Of Selenium:

Selenium comes in two primary forms: the Selenium WebDriver, which enables developers to scale and distribute scripts across many different environments and create browser-based regression automation suites and tests, and the Selenium IDE, an integrated developer environment is useful for creating quick bug reproduction scripts and for exploratory testing aided by automation. The WebDriver is the successor to the now-deprecated Selenium Remote Control (coupled with Selenium 1.0); Selenium 1.0 + WebDriver = Selenium 2.0

Most developers get started with Selenium IDE (integrated development environment). This helps with gaining familiarity with Selenium commands. Using this IDE, developers can create simple tests rapidly – sometimes within mere seconds. However, Selenium’s developers don’t recommend using Selenium IDE for all testing automation purposes.

Projects In Selenium (a.k.a. Selenium WebDriver)

Selenium WebDriver aims to overcome the limitations of the previous Selenium Remote Control, offering better support for dynamic web pages where the elements on a page are subject to changing without the page itself being reloaded. Because a variety of browsers supporting it, Selenium WebDriver uses each browser’s native support for automation. Thus, the features supported and the way direct calls are made depends on the browser that you’re using.

Additionally, the way that you set up a Selenium WebDriver Project depends on both your programming language and your development environment. It’s possible to set up projects using several programming languages:

  • Java: These projects are most easily setup using Maven, which will download Java bindings and all dependencies and create the project for you.
  • C#: C# bindings are distributed as part of a set of signed dlls and dependency dlls. You can download the latest selenium-dotnet zip file here. Then, you’ll need to add a reference to each unzipped dll to your project in whatever IDE you’re using.
  • Python: Run pip install selenium from a command line to add Selenium to a Python environment.
  • Ruby: Run gem install selenium-webdriver from a command line to add Selenium to your Ruby environment.
  • Perl: Bindings for Perl are provided through a third party, such as this example, which offers documentation on getting started.
  • PHP: PHP bindings are also available through third parties
  • JavaScript: The Selenium Project provides JavaScript bindings on npm. Install them by running npm install selenium-webdriver.

Once you’ve set up your project, Selenium WebDriver functions just like a normal library. It’s self-contained and typically doesn’t require you to start additional processes or run any installers before using it. There are a few exceptions, however, with additional setup steps required for

  • ChromeDriver
  • Opera Driver
  • Android Driver
  • iOS Driver

Managing Test Cases Using Selenium IDE (Integrated Development Environment)

The Selenium IDE is the tool that you’ll use to develop your test cases. It’s a Firefox plugin that’s intuitive to use, containing a time-saving context menu and Selenium command options that make the process of learning Selenium script syntax simple.

Once you’ve installed Selenium IDE in Firefox, it’s available in the Firefox Tools menu. Selecting it will open a new, empty script-editing window as well as a menu for loading or creating test cases. From there, you can use one of three methods to build test cases (often, you’ll need to use all three):

Recording test cases: This records a test case based on interactions with a website. The record button is on by default when IDE is opened, but you can turn this off in the Options menu. During recording, Selenium automatically inserts commands based on your actions, such as clicking a link (the click or clickAndWait command), entering values (the type command), selecting options from a drop-down menu (the select command), or clicking check boxes or radio buttons (the click command).

Adding verifications and asserts: This process enables your test to check the properties of a web page using the assert and verify. To use it, right-click anywhere on the page in the browser displaying your test application and choose from ‘assert and verify options‘ in the context menu. More commands get added to this menu as you continue to use Selenium IDE, which attempts to predict what command and parameters you’ll need for an UI element on a web page. Pure simplicity!

Editing: You’ll also likely encounter the need to edit test cases and manually insert or edit commands and comments. In table view, simply select the point in your test case where you want to insert a command, right-click, and select insert command. Selenium IDE adds a blank line ahead of your selected line where you can use the command editing text fields to enter a new command and its accompanying parameters. In source view, the process is similar: select the point where you want to enter the new command, left-click between the commands in the test pane where you want to enter it, and enter HTML code to create a three-column row with the command, the first parameter (if required), second parameter (if required to locate an element), and third parameter (if required to have a value). You can also enter comments throughout your test cases; these will be ignored when the test case is run.

With Selenium IDE, you can also use a base URL to run test cases in different domains by specifying a relative URL instead of an absolute URL as the argument to open a test case.

To define a test suite, a collection of test cases that you want to run as a continuous batch job, you can use a simple HTML file to define your list of tests. Each row in your HTML file should define the file system path to the tests you want to include in the suite.

Once you’ve mastered the basics of Selenium, you’ll find tons of ways you can put these tools to use to improve your development and testing processes. With many advanced features and functionality, yet being quite simple for beginners to begin using and master, Selenium is a valuable suite of tools for novices and experienced developers alike. The Selenium Wiki on GitHub is a useful source for learning about many advanced capabilities this tool offers. Selenium is a great tool to help with software testing and load testing.

 

Closing Remarks

You know the name Selenium comes from a joke made by Huggins in an email, mocking a competitor named Mercury, saying that you can cure mercury poisoning by taking selenium supplements. The others that received the email took the name and ran with it.

As compared to other test automation tools, it is Selenium’s strongest characteristic. Selenium Remote Control support for multiple programming and scripting languages allows the test automation engineer to build any logic they need into their automated testing and to use a preferred.

Share This Post

Leave a Reply

Translate »
error: Alert: Sorry... Content is protected!