The Selenium Web Application Testing Framework

Web application testing time...

The more Web applications we use, the more tools are needed to automate the testing process, for which there are many options that simplify the process. Since testing processes and methods vary from one organisation to another, their effectiveness also differs. This article introduces Selenium, a famous framework for testing Web applications, and in particular, its IDE component.

Selenium offers a variety of tools to automate the Web application testing process across multiple platforms. It can run on many browsers and operating systems, and can be controlled by many programming languages, including Python, Perl, PHP, Ruby, Groovy and HTML. Selenium consists of three major tools: Selenium IDE, Selenium Remote Control (RC), and Selenium Grid. In this article, we will cover the first one.

Selenium IDE is the open source test automation tool to generate test cases. Firefox supports an add-on for Selenium IDE, with the same name. This is a user-friendly automation tool; anyone can develop and run individual test cases or entire test suites. The Selenium IDE can be used to generate the code for any of the programming languages mentioned above, with just a single click!

Installation

You can install the Firefox add-on from the relevant section on its website. Click the link to the .xpi file in Firefox, and it will prompt you to install the add-on. Once the installation succeeds, restart your browser. After that, you can access the add-on via the Tools –> Selenium IDEmenu. The default screen looks like what is shown in Figure 1.

Selenium IDE default screen

Figure 1: Selenium IDE default screen

Recording

Recording is started automatically when the IDE is accessed. You can disable this option; uncheck the “Start recording immediately on open” option in the Options –> Options –> General tab.

The recorded actions are stored as Command, Target and Value in the Table view. The code can be viewed in the Source tab. By default, the code is generated in HTML format. The programming language can be specified via the Options –> Format menu.

Verification

During recording, the code is generated for an action. The response of the action is not verified. For example, let’s assume you are performing/recording a user creation action in the Web application. The recording action will generate code to create the user, but it cannot verify if the user has been successfully created. To verify the response, you can right-click on the text which you want to verify, and choose the VerifyTextPresent option. In this case, you can right-click on the text which informs you that user creation was successful.

The code can be saved as a test suite or a test case. A test suite is a collection of test cases.

Playback

You can click the Play the entire suite button to execute the test suite. You can also click the Play current test casebutton to execute a single test case. The difference in the appearance of these two buttons can be seen in Figure 2.

Selenium IDE toolbar

Figure 2: Selenium IDE toolbar

Note: When the test script is executed, logs are generated for every command. This is useful while investigating any issues with the test script.

Figure 3 shows what the Selenium IDE Table view looks like after executing tests.

Table view after running tests

Figure 3: Table view after running tests

The Selenium IDE add-on provides a playback option for HTML code, but does not support playback for other programming languages. Test suites written or generated in other programming languages can be executed using the Selenium RC (Remote Control) tool — why don’t you try it out yourself? :-)

  • http://www.limelight-digital.com.au limelight

    Thanks for posting this! I’m looking for a medium that can help us to get a good amount of promotion for my websites which in return gave me a business too through websites and I must say this has definitely helped me in this process.

  • Tanmay Joshi

    When is the next article going to be published in this series?
    Also hoping that you will cover regression testing with Selenium.

    Thanks,
    Tanmay Joshi

All published articles are released under Creative Commons Attribution-NonCommercial 3.0 Unported License, unless otherwise noted.
Open Source For You is powered by WordPress, which gladly sits on top of a CentOS-based LEMP stack.

Creative Commons License.