Friday, 10 May 2013

Introduction To Quick Test Professional


Now along with selenium we will have post regarding different automation tools.
Quick Test Professional is one of the automation tool.


Quick Test Professional , popularly know by its acronym QTP is the functional automation testing tool from Mercury Interactive now acquired by HP. It is now called as HP Functional Test
QuickTest Professional is the solution for functional test and regression test automation.
QTP is easier to use and implement for both technical & non technical testers in comparison to other functional testing tools available.

QTP's Scripting Language is VB Script which is easy to use , understand and program.

Quick Test Professional is the most widely used tool for the purpose of Test automation and has emerged as the test automation tool of choice for the software industry.

Why QTP

  • It is easy even for a non-programmer to understand QTP and start adding test cases.
  • Support for record and playback and ability to edit scripts after recording. Also different recording modes are provided in QTP viz. Normal, Analog & Low level.
  • Excellent Object Identification process / mechanism
  • Ability to let you enhance the existing tests even without the AUT (Application under test) through active screen.
  • Supports all popular Automation frameworks - Keyword driven testing approach, Data driven testing approach, Modular testing approach, Hybrid frameworks etc.
  • QTP comes with an inbuilt IDE, which is simple and easy to use.
  • QTP can be integrated with Test management tools like QC (Quality Center), Test director and also functional test tools like Winrunner. The test cases can be mapped to the automation scripts and be executed from QC (Quality Center) itself. Also, it can kick off Winrunner test execution from within.
  • Easy to maintain different types of suites viz. Smoke, Sanity, Regression etc.
  • It comes with loads of inbuilt properties and methods in QTP as well as inbuilt functions in VBScripts
  • Use of Datatables/Excel files are easier and provides a variety of methods to play around with rows and columns.
  • Easy to maintain test iterations and data driving the tests through configurations.
  • Test reporting with all necessary details for analysis is provided.
  • Microsoft Object model can be implanted in QTP easily (Example – Word document object, Excel Object, Outlook Object, ADO objects, File system objects, DOM etc)


Monday, 31 December 2012

Happy New Year !!


Wish you and your family a Joyful, Bright, Healthy,Prosperous and Happiest New Year ahead!

Happy New Year 2013!!







Wednesday, 3 October 2012

Error Handling In Selenium RC

With help of error handling you can able to get details of failure.
If any of the steps in your tests fails then selenium will throw an exception and tests would stop. If you handle the exceptions using 'try catch', then you should be able to achieve what you are looking for. 

As an example, see the code below. This would handle the Element Not Found Error.And you can write that exception to file




public void test() throws Exception {
try {
selenium.open("http://seleniumhq.org/");
selenium.click("xpath=(//button[text()='Login'])[2]");
}catch (SeleniumException e){  //If any error occurs

try{
//Code to write error in file
FileWriter fstream = new FileWriter("e:/filename1.txt",true); //Will
                                           write error details here, if file doesn't exists it will create new    

BufferedWriter bw = new BufferedWriter(fstream);
bw.write("Test Project " + e.getMessage());
bw.newLine();
bw.close();
}catch(Exception a){  //For File handling Error
System.out.println("Error In File Handling");  
}
    }
}


Output
Test Project ERROR: Element xpath=(//button[text()='Login'])[2] not found

Tuesday, 4 September 2012

Verify the height and width of image in Selenium


You can verify image height and width with help of selenium.

I have shared sample script. In this script i'm storing width and height of image and then comparing it with expected width and height.

CODE - 

int wid = (Integer) selenium.getElementWidth("css=p > img.medialeft");
int hght = (Integer) selenium.getElementHeight("css=p > img.medialeft");
System.out.println(wid);
System.out.println(hght);
 if ((hght == 234) && (wid == 140))
    {
      
       System.out.println("image size" +wid + " X "  + hght + "pixels");
  
     }

 Else
   {
       System.out.println("Image width and height is not matching with expected");
   }



Here expected width and height is 140 and 234 respectively.
In if condition it is checking whether width and height is same as required, if it is same it will print, else will move to other part or any error message.





Compare a variable with blank value in selenium



To compare variable with blank value, you can try solution like suggested      below - 
Here 'test' and 'j' are two variable. j having blank value.
It will compare 'test' and 'j' variable and accordingly it will display message  whether test variable is blank or not.


storeValue  |  element  |  test
store          |           |  j  (blank value)
gotoIf        |  storedVars['test']==storedVars['j']  |  true
getEval      |  alert("test Variable Value is not blank")
gotolabel   |  finish
label         |  true
getEval      |  alert("test Variable Value is blank")
label         |  finish


Xpath to determine checkbox “checked” attribute

If there is multiple check-boxes with same ids and you have to select the next check-box which is not selected/checked. 
For such scenario you can refer below script - 




Here 'stnewrecord' is class of check-box. Script will store number of check-box, and according to that loop will follow. It will check whether check-box is checked or not if not it will check else move to next step.
xpath=(//input[@class='stnewrecord'])[${i}]  
This is xpath of check-box. 'i' is position, it will increase on each iteration.

Configure Selenium RC With JUnit Using Eclipse



Before configuring Selenium RC with Junit Using Eclipse below components are required - 


1.Install JRE : http://www.java.com/en/download/
2.Download Eclipse IDE for Java Developers : http://www.eclipse.org/downloads/
3. Download Latest version of JUnit: https://github.com/KentBeck/junit/downloads
4.Download and Install Selenium IDE firefox plugin : http://seleniumhq.org/download/
5.Download Selenium RC server and Selenium Client Drivers for Java:http://seleniumhq.org/download/



Once done with above steps launch Eclipse.
After launching eclipse, you need to Create New Project for selenium scripts

Go to File > New > Project then In Select a Wizard Click Java Project. Then provide all details like project name.

Once new project is created, right click on project go to Build Path > Configure Build Path.
Click on Libraries menu when pop-up appears, then click to "Add External Jar's ". Select Selenium RC server and Selenium Client Drivers for Java which is downloaded from http://seleniumhq.org/download/.



Once it is done, now build path is configured and project is ready to use.
Now create a package for project.
Once package is created then next step will be to create class.Right click on Package and add new class, it will ask for name. Click on Finish once class name is provided.



Once done with all above steps, your package explorer looks like below -




Once class is created you are ready to write script for selenium scenario. As well you can execute created script on eclipse IDE.

Thank you...

Thursday, 3 May 2012

CKeditor with Selenium IDE


There are two ways to deal with Ckeditor

1)
focus  |  class=cke_show_borders
typeKeys |  class=cke_show_borders  | testing content

'cke_show_borders' is a class of body area

2)

runScript | CKEDITOR.instances["editor1"].setData('
testContent
');

'editor1' is instance of Ckeditor






































With help of these option you can able to tackle with CKeditor.

Friday, 30 March 2012

Selenium IDE and CAPTCHA


Selenium can only be used to test a web app protected by CAPTCHA if a human involved for the test. So, if you are automating registration form of any site that includes a CAPTCHA, you will require human interaction during the specific section that requires a CAPTCHA response.

There are two ways in which you can automate CAPCHA
1.By break command
2.By input-box

Suppose after command 3, there is CAPTCHA

1.By break command

Command 1
Command 2
Command 3
4th command will be
Break
Enter CAPTCHA manually and resume execution of test
continue with your next commands

2.By input-box
Command 1
Command 2
Command 3
4th command will be
storeEval | prompt(“Enter value for captcha”); |variable
type | locator of CAPTCHA field | ${variable}
continue with your next commands



Saturday, 3 March 2012

Selenium supported browsers


Below are the browsers which selenium supports :


  *firefox
  *mock
  *firefoxproxy
  *pifirefox
  *chrome
  *iexploreproxy
  *iexplore
  *firefox3
  *safariproxy
  *googlechrome
  *konqueror
  *firefox2
  *safari
  *piiexplore
  *firefoxchrome
  *opera
  *iehta