Wednesday, April 10, 2013

Verify Sheet existence



          Method 1
Function isSheetExists()
                    On Error Resume Next
                    isSheetExists=True
                    Err.Clear
                    Set objSheet=Datatable.GetSheet("Global")
                    If Err.Number <>0 Then
                             isSheetExists=False
                    End If
                    msgbox isSheetExists
          End Function
          Call isSheetExists()

          Method 2
          shtCnt=Datatable.GetSheetCount
          For shtNum=1 to shtCnt
                   If Datatable.GetSheet(shtNum).Name=”Action1” Then
                             Msgbox “Action 1 sheet exist”
                   End If
          Next  

Contributed by: Vamshi Gowtham
m.vamsigowtham@gmail.com 

DataTable



A Data Table provides a way to create data driven test. It is similar to MS Excel spreadsheets and can be used to run an Action multiple times. Data table has one global data sheet which is accessible to all actions and each action has its own private data table also known as local data table. 

Types of Data Table:
There are 2 types of data table
 i) Design time data table :   A data table during script design time is known as design time data table.
              Note: Any changes to this are saved when the script is saved.

 ii) Run-time data table:  The run time data table contains a copy of the design time data table when a script is executed. It may contain values that are changed during script execution and are presented in the test result summary
          Note: The changes made to the data table during run-time are not saved to design time data table.

Setting data table iterations:
          To run a test case for some number of iterations we need to set the iterations of global data table in the Test Settings dialog, which is invoked using File → Settings → Test Settings window  → Run ( tab ) → Select required data table iterations radio buttons.
          Note: We can set the iteration settings for an Action call by going into the keyword view and then right clicking on the Action and selecting Action Call Properties

Accessing a data from the data table:

          msgbox datatable("val")
          msgbox datatable.GlobalSheet.getparameter("val").value
          msgbox datatable.GlobalSheet.getparameter("val").ValueByRow(2)
          msgbox datatable.value("val",dtGlobalSheet)
          msgbox datatable.Value("val",1)
          msgbox datatable.LocalSheet.Getparameter("val1").ValueByRow(2)
          msgbox datatable.GetSheet(2).Getparameter("val1").ValueByRow(2)

Entering data into data table:

          datatable.value("COLUMN NAME",dtGlobalSheet)=VALUE

Contributed by: Vamshi Gowtham
m.vamsigowtham@gmail.com 

Monday, April 8, 2013

Bitmap check point

Bitmap check point is used to compare the bitmap files.

Script : Write a script to compare given bitmap files.

Optional Explicit
Dim filePath1,filePath2
filePath1=”D:\Vamsi\file1.bmp”
filePath2=”D:\Vamsi\file2.bmp”
Set bmpObj=CreateObject(“Mercury.FileCompare”)
compareResult=bmpObj.IsEqualBin(file1,file2,0,1)
If compareResult=0 Then
    Msgbox “not match”
    Else
        Msgbox “match”
    End If

Contributed by: Vamshi Gowtham
m.vamsigowtham@gmail.com

Text Area Check point

It is used for checking the text present in the specified area.

Navigation:

Keep the tool under record mode -> Insert menu ->check point -> Text area check point -> Select the desired text by using cross hair icon ->Click OK -> Select any options like Match case, Ignore spaces, Exact Match, Text not displayed -> Click OK

Coding Text area check point:

Script:
Ex: In Note Pad       
There is a QTP class
There is no prerequisite
There is a monitor

Now identify whether “is” exists between “class” and “no”

Option Explicit
Dim foundTxt, startPos, endPos
Dim substr, actualtxtpos

foundTxt=window("Notepad").WinEditor("Edit").GetVisibleText()

startPos=InStr(foundTxt,"class")
endPos=InStr(foundTxt,"no")

substr=mid(foundTxt,startPos,endPos + len(“no”))

actualtxtpos=InStr(substr,"is")
If  actualtxtpos<>0 Then
    Reporter.ReportEvent micPass,"text should be displayed","Text is displayed"
Else
    Reporter.ReportEvent micFail,"text should be displayed","Text is not displayed"
End If

Script: Write a script to extract file name, file path and drive letter

Option Explicit
Dim filePath,firstloc,driveName
Dim filePathVal,secondloc,filename
filePath=”D:\Vamsi\Test data\sample.xls”
    firstloc=Instr(filePath,"\")
driveName=mid(filePath,1,firstloc-2)
msgbox driveName
secondloc=InstrRev(filePath,"\")
filePathVal=mid(filePath,firstLoc+1,secondLoc-4)
msgbox filePathVal
fileName=mid(filePath,secondLoc+1,len(filePath)-secondLoc)
msgbox fileName

Contributed by: Vamshi Gowtham
m.vamsigowtham@gmail.com

Text check point

Text check point is used for checking the text present in the specified object.
Navigation :
Keep the tool under record mode ->Insert menu -> Check point -> Text check point -> select the desired object with handler pointer -> click OK -> select any option like Match, Ignore spaces, Exact Match, Text not displayed -> Click OK

Coding the Text check point:

We have to do the following for implementing text check point via code.

1.    Specify the text to be checked.
2.    Get the text visible on the application
3.    Check whether the expected text exists in the captured text.
4.    Report to QTP results.

Script: Verify “version 4.0’ text is displaying in Help

Option Explicit
Dim expText=”version 4.0”
Dim getText, txtPos
expText="Version 4.0"
getText= window("Flight Reservation").Dialog("About Flight Reservation").GetVisibleText()

txtPos=Instr(getText,expText)
If txtPos<>0 Then
    Reporter.ReportEvent micPass,"Text should be found","Text is found"
Else
    Reporter.ReportEvent micFail," Text should be found","Text is not found"
End If
   
    GetVisibleText() method: It returns the text that is visible on the object during runtime.
    InStr() function: It compare the actual text with expected text and returns the position.

    Script: Write a Script to count number of occurrences for a given string in actual string.

    Method 1
    Option Explicit
    Dim actualTxt,exptxt,indx,instCnt
actualTxt=”My name is James there is not pre-requisite for learning qtp”
    expTxt=”qtp”
    indx=0
    instCnt=0
    Do
        Indx=InStr(indx+1,actualTxt,expTxt)
        If indx > 0 Then
            instCnt=instCnt + 1
        Else
            Exit Do
        End If
    Loop While (True)
   
Method 2

Option Explicit
    Dim actualTxt,exptxt
actualTxt=”My name is James there is not pre-requisite for learning qtp”
    expTxt=”qtp”
msgbox (len(actualTxt)-len(Replace(actualTxt,expTxt,””)))/len(expTxt)


Contributed by: Vamshi Gowtham
m.vamsigowtham@gmail.com

Standard check point

It is used to test the GUI properties of the objects like : Text, Enabled, Height, width, class etc.,

Navigation: Record mode -> Insert menu -> check point -> Standard check point -> select the handler pointer -> click on the object which we want to check the properties -> specify expected values -> Click OK button -> stop recording.

Syntax: <obj hierarchy>.check checkpoint(<check point name>)

To find the status of check point:

Val=<obj hierarchy>.check (checkpoint(<check point name>))

Ex: Focus to window

-> Flight button should be disable

Open a new record

-> Flight button should be disable

Enter date

-> Flight button should be disable

Select Fly From

-> Flight button should be disable

Select Fly To

-> Flight button should be enable


Contributed by: Vamshi Gowtham m.vamsigowtham@gmail.com

Check points



Check points are used to verify the properties of GUI objects, Images, data bases…..
Check points allows us to compare the current behaviors of the application with earlier behavior of the application.
Types of check points:
1.     Standard check point
2.     Text check point
3.     Text area check point
4.     Bitmap check point
5.     Data base check point
6.     Accessibility check point
7.     XML check point from Application
8.     XML check point from Resource

Operational overview of Check point:

IT is divided into 2 phases.
1.     Pre-Execution phase :
i) Captures the expected value
ii) Generates the corresponding test script statement
2.     While Execution phase:
i) Captures the actual value
ii) Compare the actual value with expected value
iii) Display the result.

Disadvantages:
1.     It takes more time to verify and validate and hence test execution time is more
2.     It depends on the screen resolution and hence it might vary from system to system.

Note: In real time we mostly avoid use of check points.

Contributed by: Vamshi Gowtham
m.vamsigowtham@gmail.com

AI in Software Testing: How Artificial Intelligence Is Transforming QA

For years, software testing has lived under pressure: more features, faster releases, fewer bugs, smaller teams. Traditional QA has done her...