How to do testing of a web application by using selenium ?


Web applications (those applications that are accessed through a web browser) are used widely and it’s really impossible to overvalue or misjudge their role in our life. A number of applications have gone online including office apps, CRM systems and more.

Essential advantages of web applications are that they can be accessed from anywhere, in most cases the data is stored on the server and there is no way to be worried about the safety & accessibility. You need not download, install as well as set up anything on your personal desktop to use them.

With advantages here come to some disadvantages as well. As they are allowed by a browser, it is challenging to decide the same layout for every user, a number of people interact with a server at same point of time, data transmitted between a client & a server can be replaced or seized, users can change application functionality & interface changing browser setting, small glitches in app security may cause great loss of money.

So, it’s really important to focus on web application testing. There are many tools for web application testing automation; however Selenium is the most buzzing one.

Why testing a Web Application with Selenium?

  • It’s free
  • It evolves & grows
  • It supports a lot of platforms and browsers
  • Recorded test cases from Selenium IDE can be interpreted in different programming languages: Java, PHP, Ruby.NET, Perl, Python
  • There are various ways to make & run test cases: record & run using Selenium IDE, record and run using Cubic Test, refactor, record and run using Java IDE, use Selenium Core, Web Driver or Selenium Grid to run tests etc;

Main Components of Selenium

Selenium IDE: It is a Firefox add-on, which simplifies recording and playback tests in FireFox 2+. One can use it to generate code to run the tests in accordance with Selenium Remote Control.

Selenium Remote Control: It’s a client/ server system, which helps you control web browsers locally or on other PCs, using almost any testing framework and programming language.

Selenium Core: It is the authentic JavaScript-based testing system, which is now used basically as a main part of Selenium Remote Control; however it can also be used as a complete JavaScript/ HTML testing system.

Selenium Grid: It helps Selenium Remote Control to next level by running tests on various servers at the same time; reducing the time it consumes to test multiple browsers or OS (operating systems).

CubicTest: It is a graphical eclipse plug-in so as to write Selenium & Watir tests. It accelerates tests and simplifies to write as well as provides abstractions to make tests more reusable and robust.

Selenium on Rails: It facilitates an easy way to test Rails application together with Selenium Core. Suite files are made on the fly for every directory & the Selenium Core files do not have to the public.

Bromine: It is a QA (Quality Analysis) tool for Selenium, which lets you easily run selenium RC tests, as well as view the results. It scales amazingly from the single tester that only wants to run some tests with no hassles to the corporate solutions with multiple user-groupers & hundreds of tests cases.

Selenium Ruby: It is the core for newer Ruby related Selenium projects.

How to do testing of a web application by using selenium?

  • After the installation of Selenium IDE, navigate to the Tools Menu & select Selenium IDE option. Upon selection, recording will begin automatically.
  • Type in address bar & press Enter. You’ll find out that in your recorder in Base URL input field address become visible.
  • Now type Selenium into search field & press Google search button. Don’t enter as selenium IDE doesn’t recognize it. Choose address become visible after the first result, right-click on it and choose verifyTextPresent Now press the red button marked “Step 1”. Here you are almost done with the first test case.

The first column features Selenium commands. Choose any one of it to see the short description. The second column features targets. For command “open” target is browsed URL, for commands “type” & “click” argument “target” includes element id. The third column includes an optional value for example; string to be entered into an input field.

Test Suite Formation

It appears that there is just one single test case, however actually there is a test suite together with a test case. In order to see that press vertical separator or create a new test case with the help of menu File.

Having made an empty test case & recorded two test scenarios the same way, we will get the test suite together with two test cases. Next, step is to just execute it.

Execution & Debug

IDE and Selenium TestRunner are the two ways by which you can execute the test cases.

Choose first test case “Selenium” & click on the “Play current test case” button so as to execute it. In many cases test failed because the page hasn’t been loaded completely & verification process executed when body text wasn’t received as well as parsed. So we must modify the test case & insert one more command. Choose the last command “VerifyTextPresent”, click the option “Insert new command” in context menu & fill in the suitable data to perform the test case.

Target = 30000 means simply that you should wait until the page is loaded, but wait no more than 30 seconds. Run the test one more time, it should succeed.

In Selenium IDE the user can toggle breakpoint, set the execution speed, run specific commands, or walk step by step with the help of test script.

Use “Play with Selenium Test Runner” button to execute the test cases in a much more informative way. Here you can review all your test scripts, see the time spent, test execution and test results in just one window.

Test Export   

After recorded test scripts having been saved, you will get an HTML file. It isn’t useful since you cannot use it anywhere except Selenium IDE, however, you can modify test scripts to various programming languages. Just go to Option menu, choose Format option & select the suitable format.

Exported test scripts can be carried out outside the Selenium IDE with the help of Selenium RC, i.e., in case of Java in Eclipse or as a standalone set of JUnit tests.

Hope you got the testing procedure through Selenium.





Tags - Selenium Training in Delhi , Selenium Institute in Delhi 


Get Weekly Free Articles

on latest technology from Madrid Software Training