Thursday, June 12, 2008

Selenium Core

Selenium Core is a test tool for web applications. Selenium Core tests run directly in a browser, just as real users do. And they run in Internet Explorer, Mozilla and Firefox on Windows, Linux and Macintosh. No other test tool covers such a wide array of platforms. Team of programmers and testers at Thought Works developed it.

It allows the tests to run in any supported browser on the client-side, mainly allows you to do the following:
Browser compatibility testing: Test your application to see if it works correctly on different browsers and operating systems. The same script can run on any Selenium platform.
System functional testing:
Create regression tests to verify application functionality and user acceptance.


Advantages: Selenium Core works on
all the major browsers on all the platforms. Selenium Core is a simpler form of Selenium and it is suitable for non-developers, but it has some inherent limitations and few others mentioned below.

  • Recommended use: Non- developers
  • Better use: Developers writing custom tests
  • Optional command line

It Supports Platforms and browsers are as below:

Windows:

  • Internet Explorer 6.0 and 7.0
  • Firefox 0.8 to 2.0
  • Mozilla Suite 1.6+, 1.7+
  • Seamonkey 1.0
  • Opera 8 & 9

Mac OS X:

  • Safari 2.0.4+
  • Firefox 0.8 to 2.0
  • Camino 1.0a1
  • Mozilla Suite 1.6+, 1.7+
  • Seamonkey 1.0
  • Not yet supported: OmniWeb

Linux:

  • Firefox 0.8 to 2.0
  • Mozilla Suite 1.6+, 1.7+
  • Konqueror
  • Opera 8 & 9

Disadvantages: Must have write access on web server, because directly writes core tests in web applications. It is extremely complicated for first time users.


Selenium Core installation: If this is your first time using a Selenium tool, you may not want to just use Selenium Core directly; one good way to get introduced to Selenium's features is to use Selenium IDE , which embeds Selenium Core internally. Download Selenium IDE and you'll get Selenium Core along with it. Give it a spin!

Selenium Core is pure DHTML/JavaScript, to use Selenium Core you need to make it available from the same web server as the application you want to test. That means that you can't use Selenium Core (pure DHTML/JavaScript) to write a test of google.com this is because Selenium Core is pure DHTML/JavaScript, and so it is bound by JavaScript's security restrictions. Specifically, JavaScript enforces (This is a JavaScript security requirement. If you can't/won't modify the web server you want to test, Selenium Core may not be the right tool for you; you may just want to use Selenium IDE or Selenium RC instead. If you're on Windows and you only want to use Selenium Core with Internet Explorer, you may also use HTA mode to run your tests against a remote web site.)

Normally, this is as simple as extracting the Selenium Core zip file into the DocumentRoot, htdocs, or webroot of your webserver. Then, try to open the TestRunner.html page on your website, which should be in the core/ directory.


Run Selenium’s test suite: We can run our scripts using Test Runner only. Test Runner gives you nice browser interface to execute your tests and also gives summary of how many tests were executed, how many passed and failed.Here is a screen shot of Test Runner.

The screen is divided into four sections: "Test Suite", "Current Test", "Control Panel" and the main application frame where your application will reside. Initially, none of the Control Panel buttons will work, because you haven't selected a test suite. By default, Selenium Core offers to run the test suite in "../tests/TestSuite.html". Click "Go" to open that test suite.

If you installed the /tests along with /core, you should now see a list of tests to run. Press the "Run All Tests" button to run all of our automated tests. Note that some tests may fail if your browser blocks pop-ups, manages passwords, or does other helpful things that interfere with automation. Be sure to turn these features off before running the tests!


Here's a close-up view of the Selenium Control Panel:

Run All Tests: Run every test in the test suite.

Run Selected Test: Click on one test in the test suite, then click here to run just that one test.

Pause / Continue: While a test is running, press the Pause button to temporarily stop running commands. After you press Pause, you can press Continue to resume the test.

Step: Click on a test in the test suite, and then click on just one line of the test to set a "breakpoint." When the TestRunner reaches a breakpoint, it will automatically pause execution on that line. You may then press the Step button to run the next line of the test and pause again. You can also click on a breakpoint line to remove the breakpoint.


HTA Mode: Selenium Core provides an additional mechanism for running automated tests called "HTA mode." HTA Mode only works on Windows, and only with Internet Explorer; you can't use HTA mode to test any other browser. An HTA file is a special type of HTML file that is allowed to violate the same origin policy and to write files to disk. When running in HTA mode, you don't have to install Selenium Core on the same webserver as the AUT. HTA files are also allowed to save test results directly to disk, rather than POSTing the test results to a webserver.
To run Selenium Core in HTA mode, just double-click on TestRunner.hta, in the /core directory of your Selenium installation. (As you can see, TestRunner.hta is just a copy of TestRunner.html; but that ".hta" extension makes a big difference!) You can then run your test suite just like any other Selenium Core test, but since the tests are being run in HTA mode, you're free to run your tests against any website.

You can also run TestRunner.hta from the command line, passing arguments to it just like you would pass arguments to an HTML file, like this:

C:\selenium\core>TestRunner.hta "test=..%2Ftests%2FTestSuite.html&auto=true&close=true&resultsUrl=results.html&save=true"


Advanteges of HTA mode:

  • Can use tests against other sites
  • Suggested use: Regression testing against a site being rebuilt.

Disadvantage of HTA mode:

  • Only runs with IE

Thursday, April 17, 2008

Selenium IDE

Selenium IDE is an integrated development environment for Selenium tests. It is implemented as a Firefox extension simply we can say like selenium via FF plugin and allows you to record, edit, and debug tests. Selenium IDE includes the entire Selenium Core, allowing you to easily and quickly record and play back tests in the actual environment that they will run. Selenium IDE is the easiest way to use Selenium and most of the time it also serves as a starting point for your automation. As compared to most of the test automation tools it is very simple and lightweight.

Advantages: Selenium IDE is the only flavor of Selenium, which allows you to record user action on browser window. It can also record user actions in most of the popular languages like Java, C#, Perl, Ruby etc. This eliminates the need of learning new vendor scripting language. For executing scripts created in these languages, you will need to use Selenium Remote Control. If you do not want to use Remote Control than you will need to create your test scripts in HTML format.

Disadvantages: Biggest drawback of Selenium IDE is its limitation in terms of browser support. Though Selenium scripts can be used for most of the browser and operating system, Scripts written using Selenium IDE can be used for only Firefox browser if it is not used with Selenium RC or Selenium Core.

Features:

  • Easy record and playback.
  • Intelligent field selection will use IDs, names, or XPath as needed.
  • Autocomplete for all common Selenium commands.
  • Walk through tests.
  • Debug and set breakpoints.
  • Save tests as HTML, Ruby scripts, or any other format.
  • Support for Selenium user-extensions.js file.
  • Option to automatically assert the title of every page.

Selenium IDE installation: This can be installed from either openqa or mozilla distribution site. Selenium extension will be downloaded as XPI file. If you open this file using File -> open in Mozilla (version: 1.5 or higher), it should get installed. If installed properly, Selenium can be accessed from tool --> Selenium IDE in your browser toolbar.

Selenium Toolbar contents and their functionality:The small red button on the right hand side gives you an indication on whether Selenium is in recording mode or not. By default when the IDE comes up it has recording turned on. You might want to turn it off by clicking on the red button, until you are ready to begin recording. Go to a web site that you want to record, click on the record button and begin your browsing task(s). You will notice that as you click and type in the browser the IDE is recording everything you are doing. Also, Selenium IDE will not record any operation that you do on your computer apart from the events on Firefox browser window. So go ahead read your mail, open a word doc or do anything else, Selenium will record only your actions on browser. When you are done, simply end recording and click on the green arrow to play back your script you just created. Don't forget to save your script before closing the IDE.

If you are created script manually, simply go to the Source tab in the IDE and paste the script in there. Now go back to the Editor tab and click on the Green arrow button. You should now see the actions taking place in your Firefox browser. If you want to slow down the execution select the Walk radio button before playing the script. You may need to increase the pause commands if the web pages are not rendering fast enough, and thus causing an error.

If you open the option window by going to Option, you will see there are some self explanatory options available. For example, encoding of test files, timeout etc. You can also specify Selenium Core and Selenium IDE extensions on this page. Selenium extensions can be used to enhance the functionality provided by Selenium.

Final button present on the Selenium IDE toolbar is the Selenium TestRunner. Test Runner gives you nice browser interface to execute your tests and also gives summary of how many tests were executed, how many passed and failed. It also gives similar information on commands, which were passed or failed. TestRunner is also available to tests developed in HTML Only.Here is a screen shot of Selenium IDE.




Tuesday, April 15, 2008

Selenium- Automation tool for web based applications.

Selenium is an open source tool for web application testing, using this tool we can test Functional or System tests for web applications as well as Selenium is not meant for unit testing. Selenium is primarily developed in Java Script and browser technologies and hence supports all the major browsers on all the platforms.

In terms of coverage for platform and browser Selenium is one of the best tool available in the market. For example, you can have your automation scripts written for Firefox on Windows, with out major changes you can run them on Firefox in Mac.

Selenium tests run directly in a browser, just like real users do. It runs in Internet Explorer, Mozilla and Firefox on Windows, Linux, and Macintosh, Safari on the Mac.They having plans to target Safari on the iPhone in some months.

There are three variants of Selenium, which can be used in isolation or in combination to create complete automation suite for your web applications.

  • Selenium IDE.
  • Selenium Core.
  • Selenium Remote Control.

Thursday, January 10, 2008

Importance Of Testing

Testing is an important step in software development life cycle. The process of testing takes place at various stages of development in programming. This is a vital step in development life cycle because the process of testing helps to identify the mistakes and sends the program for correction. This process, while seen by some as tedious, tiresome and unnecessary, plays a vital role in software development.

Software is useful in Human Lives. For Eg: Software has infiltrated almost all areas in the industry and has over the years become more and more wide spread as a crucial component of many systems. System failure in any industry can be very costly and in the case of critical systems (fight control, nuclear reactor monitoring, medical applications, etc.) it can mean lost human lives. These "cost" factors call for some kind of system failure prevention. One way to ensure system's reliability is to extensively test the system. Since software is a system component, it requires a testing process also.

Basic Theory of Testing:-
The process of software testing involves creating test cases to "break the system" but before these can be designed, a few principles have to be followed.

1.Testing should be based on user requirements. This is in order to uncover any defects that might cause the program or system to fail to meet the client's requirements.

2.Testing time and resources are limited. Avoid redundant tests.

3.It is impossible to test everything. Exhaustive tests of all possible scenarios are impossible; simple because of the many different variables affecting the system and the number of paths a program flow might take.

4.Use effective resources to test. This represents use of the most suitable tools, procedures and individuals to conduct the tests. The test team should use tools that they are confident and familiar with. Testing procedures should be clearly defined and it should be based on client’s requirement.

5.Test planning should be done early. This is because test planning can begin independently of coding and as soon as the client requirements are set.

6.Testing should begin at the module. The focus of testing should be concentrated on the smallest programming units first and then expand to other parts of the Project.

7.Equal importance for functional and non functional attributes. Traditionally testing should focuses on functional attributes (ex: Correct calculations) only, but non functional attributes (ex: reliability, availability, timeliness) are equally important.

We look at software testing in the traditional (procedural) sense and then describe some testing strategies and methods used in Object Oriented environment. We also introduce some issues with software testing in both environments.