Wednesday, June 22, 2011

Selenium IDE and its useful features

Selenium IDE, a firefox extension is the easiest way to record, edit, debug and run web test. Selenium is a web application testing system and selenium IDE (sometime refereed as SIDE) is a part of it. Once download, it appears as a Firefox plug-in under 'tools'. Selenium IDE works only with Firefox browser. A Selenium test recorded in Selenium IDE can be run in other browsers with the Selenium Server.

Installation :
You can download Selenium IDE from:
http://selenium-ide.openqa.org/download.jsp

If you want to open it, lunch the Firefox browser then go to  Tools> Selenium IDE.You will see the following window.




Selenium IDE is a lightweight tool and it doesn't have a lot of features as well. Some of the important features are:

Base URL: The base URL of the application. Selenium IDE automatically captures it. Test starts with this URL and all 'open' command will be relative to it unless a full path is specified with 'open' command


User Extensions: You can add new actions and assertions in selenium IDE with javascript. Create your own user-extension and save it as .js file. Go to Tools-> Options and browse your js file here. Next time when you open lunch your Selenium IDE, it will be available in command drop-down. To learn more about Selenium User Extension visit here.



Wednesday, June 15, 2011

Selenium HTML-Testrunner framework with 2.0rc2

There are so many languages and frameworks for selenium, such as JAVA, jUnit framework, and C# .Net. These are excellent if you are comfortable with one of the languages and tools. It will help you to create dynamic, advanced test framework according to your test need. Moreover, it opens door to use powerful development language in your test. For example if and else logic.
However, this HTML framework is easy and requires low maintenance. It is powerful enough for most of the automation need and you can use javascript to make your test more meaningful if necessary. You as an automation tester do not need development language either.
Please follow these steps if you want to adopt this for your test automation purpose. I have used website facebook login page for this tutorial. I am assuming you know about selenium IDE and recording the recording. If answer is ‘no’ then going to this page and come back here.
Download Selenium Server
  • Go to http://seleniumhq.org/download/. It is also known as Selenium Server. 
  • If you cannot   find stable build find from this page: http://code.google.com/p/selenium/downloads/list.
  • It is a .ZIP file. Once download is completed unzip it in C:\selenium
  • Test it.  To test it runs properly follow the following step:
1.   Open command line.
2.   Go to the folder that contains the selenium server. (You can go using DOS cd command to navigate from one folder to another.). Type following commands: java -jar selenium-server-standalone-2.0rc2.jar. If it runs successfully, you will see the following screen:


If it doesn't run check the error message. Usually, problem is with the port. Selenium server’s default port is 4444. If it is taken already, problem occurs. Easy solution is to restart your machine.
 Next step is to run your script from the command line. Before I explain more about it, let me share my file and folder structure with you. Please look at the files/folders inside 'selenium' folder carefully before you try to run script from the command line.
fb_1
I have stored my Scripts in this fb_1 folder. Second picture is about where I have put my Selenium Server 2.0

 login:
 In this folder I have my script file 'login'. I hope you have saved or renamed all your script with .html extension. If not please do that.
testsuite:
I have created one more .html file named 'testsuite'. (Or you have directly save your test script as "save test suite as"). Here I am going to explain about HTML file I have saved as testsuite.
 This .html file is a part of selenium HTML-testrunner framework and should be kept inside same folder. My script is associated with this file. Let me copy and paste what I have inside my testsuite file:



1:
It is a batch file to run test with one click.
result1:
It is the result. It should get updated after each test run.

selenium-2.0rc2


This is simply unzipped selenium server.
Now we are ready to run our test. You can name your folder and file name anything. But make sure your command is pointing to right path.
Running Test:
I am able to run my test successfully with the help of following command:
java -jar selenium-server-standalone-2.0rc2.jar -htmlSuite "*firefox" "http://www.facebook.com" "c:\\selenium\fb_1\testsuite.html" "c:\\selenium\fb_1\result1.html"
This command invokes test runner. This looks like:
:


To run test in different browser replace *firefox with :-
*chrome
*iexplore
*safari
Once you can run your script successfully, save your command in a notepad with .bat extension. Next time when you want to run your test, just double-click this batch file. You can schedule your batch file to run automatically at a specific time as well. For this use windows scheduled Task utility. You can add as many test script as you want in your batch file. Another will run automatically once previous stops running.
Always remember, Selenium is an open source tool, you might get so many errors before a successful test run. Try to make fewer errors from your side.                   

Thursday, June 9, 2011

Selenium - All you need


On the way...
Selenium Starter Kit
 2.  Selenium Scripting - Simple
 3. How to create a test suite in Selenium?
 5. Variable substitution, Store command, regular expression.
 6. Javascript solutions for selenium.
 7. Using xPath - xPath solutions.
 8. How to find elements by CSS? - very useful
How to create test suite using jUnit and eclipse in selenium