Monday 23 September 2013

Capturing the Sub Menu values using Selenium Web Driver

This program opens url and prints all submenu of Home menu.

import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;

public class ReadSubMenu {

public static void main(String[] args) {
WebDriver driver = new FirefoxDriver(); //object created to start firefox driver

Actions action = new Actions(driver); // object created to perfomr mouse operation

driver.get("http://demo.lateralcode.com/css-drop-down-menus/"); // open url

WebElement home = driver.findElement(By.linkText("Home")); // find home menu

action.moveToElement(home).build().perform(); //put mouse pointer on Home menu

List we = home.findElements(By.xpath("//*[@id='menu']/ul/li[1]/ul/li")); // common property of all sub menu item

//travers through all submenu & print their text
for (int i =0; i
{
System.out.println(we.get(i).getText()); //print submenu text
}
 }

}

Tuesday 17 September 2013

HP QTP :- What is the file extension of the script file and OR in QTP

In QuickTest Professional, File extension is as follows –

·        Per test object rep: filename.mtr
·        Shared Object rep: filename.tsr
·        Code file extension id: script.mts

Monday 16 September 2013

Selenium : - Code to Login into drobbox.com

Code to Open dropbox.com & login is as follows - 

WebDriver driver; //declare object of WebDriver

driver = new FirefoxDriver(); //create object reference of Firefox driver

driver.get("http://dropbox.com"); //open dropbox.com

String parent = driver.getWindowHandle(); //read & store windows handle of parent browser

driver.findElement(By.linkText("Sign in")).click(); //click on Sing In link

//Switch to new window opened

for(String winHandle : driver.getWindowHandles()){ //iterate through all window open

   driver.switchTo().window(winHandle); //put focus to child browser window

}

driver.findElement(By.cssSelector("*[id='login_email']")).sendKeys("hello");//enter email

driver.findElement(By.cssSelector("*[id='login_password']")).sendKeys("hello"); //enter password

driver.findElement(By.name("login_submit_dummy")).click(); //click on Sign In button

driver.switchTo().window(parent); //return the control to parent browser

Friday 13 September 2013

Selenium : How to switch to Web Dialog window & back to Parent Browser Window

Steps are as follows -

           1.  Before clicking the link, get the handle id of the browser window.
                  String BrowserParent = driver.getWindowHandle();

     2.  After clicking the link & once Web Dialog is opened
                 String str = driver.getWindowHandle();
                 driver.switchTo().window(st); // switch to child browser

     3.  Once the operation on the web dialog box is completed.    
                driver.switchTo().window(BrowserParent); //return back to Browser window

What is the use of desired capabilities

Selenium desired capabilities allows to set/change a lot of browser capabilities like cookies, profile, set proxy etc..


It helps to handle cookies, SSL certificate alerts, file upload/save(in Firefox) etc.

Thursday 12 September 2013

JXL And POI, which api is better and why

  •      jxl does not support  XLSX files
  •      jxl exerts less load on memory as compared to ApachePOI
  •      jxl doesn't support rich text formatting while ApachePOI does.
  •      jxl has not been maintained properly while ApachePOI is more up to date.
  •      Sample code on Apache POI is easily avaialble

Wednesday 11 September 2013

How to handle java script/error/exception alert using WebDriver

WebDriver would support handling js alerts using Alert interface.
         
          // Bring control on already opened alert
               Alert alert = driver.switchTo().alert();

          // Get the text/message of the alert or prompt
               alert.getText(); 
         
         // Click ok button of alert
              alert.accept();

         // Click Cancel button of alert
              alert.dismiss();

How to open Selenium IDE in Firefox

Selenium IDE can be opened in two way
  1.  Go to [View -> Side bar -> Selenium IDE]
  2.  Go to [Tools -> Selenium IDE]

What are the technical issues with Selenium

Limitation of Selenium are as follows -

  1.      Very difficult to find good documentation
  2.      We cannot run scripts from step as we can do in QTP. SO script generation takes a lot of time
  3.      WebDriver doesn’t support safari and mac (as of now).
  4.      No documentation for Selenium Grid
  5.      Difficult to generate reports.
  6.      Password encryption is not possible.

Tuesday 10 September 2013

QTP/UFT : Working with WebTable

QTP provides different methods to perform operation on WebTable.  This blog discusses about few of them -
How to check if  a WebTable exist
    msgbox Browser(…).page(…).webtable(…).exist ‘returns true/false
 How to find number of rows in WebTable
msgbox Browser(“").Page("").WebTable(“").RowCount  ‘ returns count of row in a           WebTable

How to find number of columns in a web table
    msgbox Browser("").Page("").WebTable(“").ColumnCount(1) ‘return column count in a 1st   
    row of WebTable

How to read data from a Cell WebTable
    msgbox Browser("").Page("").WebTable(“").GetCellData(row,column)
  ‘Where row & column specifies row number & column number of a Cell
How to find object using  childObject on a WebTable
 Set oDesc=Description.Create
 oDesc("micclass").value= WebCheckBox
 set oChild=Browser("").Page("").WebTable(“").ChildObjects(oDesc)
 msgbox oChild.count

How read data from WebTable using ChildItemCount and childItem
     oChild=Browser("").Page("").WebTable(“).ChildItemCount(row,col,” WebCheckBox”)
    If oChild >0
    Childitem will return object oftype defined in arguments for childitem
    Set cItem = Browser("").Page("").WebTable(“").ChildItem(row,col, WebCheckBox,0)
    If (strobjType = "Link" or strobjType ="WebEdit") Then
       cItem.Click
    ElseIf(stobjType = "WebCheckBox") Then
       cItem.Set "ON"
    End If
 

Friday 6 September 2013

Which environments are supported by HP QTP

 QTP supports the following environments
  •         Active X
  •         Delphi
  •         Java
  •         .Net
  •         Oracle
  •         People Soft
  •         Power Builder
  •         SAP
  •         Siebel
  •         Stingray
  •         Terminal Emulator
  •         Visual Basic
  •         Visual Age
  •         Web
  •         Web Services

What are the Features & Benefits of Quick Test Pro


  •       Key word driven testing
  •       Suitable for both client server and web based application
  •       VBScript as the scripting language
  •       Record and playback Feature which helps in faster test script creation
  •     Easier maintenance and powerful Data Driven capability. provides inbuilt methods to integrate with 3rdparty application like Excel, MS Access etc
  •       Operates stand-alone, or could be integrated into HP Quality Center
  •      Identifies objects with Unique Smart Object Recognition, even if they change from build to build, enabling reliable unattended script execution
  •      Enables thorough validation of applications through a full complement of checkpoints
  •      The screen shots can be recorded of Run time error


What is keyword view and Expert view in QTP

The Keyword View enables you to create and view the steps of your test in a keyword-driven, modular, table format. The Keyword View is comprised of a table-like view, in which each step is a separate row in the table, and each column represents different parts of the steps. You can modify the columns displayed to suit your requirements.

You create and modify tests by selecting items and operations in the Keyword View and entering information as required. Each step is automatically documented as you complete it, enabling you to view a description of your test steps in understandable English.
Each operation performed on your application during a recording session is recorded as a row in the Keyword View.


For each row in the Keyword View, HP QuickTest displays a corresponding line of script in the Expert View.
Advanced testers can view and edit their tests in the Expert View, which reveals the underlying industry-standard VBScript that QuickTest automatically generates. Any changes made in the Expert View are automatically synchronized with the Keyword View.
The Expert View is composed of statements coded in the Microsoft VBScript programming language. The Expert View provides an alternative to the Keyword View for testers who are familiar with VBScript. You can also create function libraries in HP QuickTest using VBScript.