Showing posts with label QTP Automation Testing. Show all posts
Showing posts with label QTP Automation Testing. Show all posts

Wednesday, February 23, 2011

What is Transactions ?

Sometime you want to know the time script or part of script is taking time to execute in such case Transactions will help to find out.
You define transactions within your test by enclosing the appropriate sections of the test with start and end transaction statements.
How to Inserting Transactions
You define the beginning of a transaction in the Start Transaction dialog box.

·         click the step where you want the transaction timing to start point
·         Insert Start Transaction.
                    


·         The Start Transaction dialog box opens.
·         Enter Transaction name
·         Select radio button as per your need
 To insert a transaction before the current step, select Before current step.
 To insert a transaction after the current step, select After current step.
·         Click OK.
How to Ending Transactions
You define the end of a transaction in the End Transaction dialog box.
·         Click the step where you want the transaction timing to end.
·         Insert End Transaction. The End Transaction dialog box opens.
                         
  • The Name box contains a list of the transaction names you defined in the
Current test. Select the name of the transaction you want to end.
  • Select radio button, where to insert the end of the transaction:
                 To insert a transaction before the current step, select Before current step.
 To insert a transaction after the current step, select After current step.
  • Click OK.

Tuesday, February 22, 2011

What is Exists property in QTP

You can use Exist statements to wait for a window to open or an object to appear.
E.g Browser(“x”).page(“y”).webbutton(“z”).exists

Exists returns Boolean value. Basically, it is used for user define checkpoint

E.g
if Browser(“x”).page(“y”).webbutton(“z”).exists then
            Reporter.Report ,,”pass”
            Else
            Reporter.Report ,,”Fail”
End if

Difference between Exists and Wait
Exists:   Exists will wait till timeout, if object doesn’t exist and return false and start execution
Wait: Wait will wait till default time or user specific time and start execution.

What is Synchronization

Some time running application may not always respond with the same speed. Sometime due to server slow process your response will get late. How to handle such type of situation?

With the use of Synchronization concept in QTP
           
·         Use of Sync property:  You can insert a synchronization point, which tells QTP to pause the test until an object property achieves the value.

E.g. Browser(“x”).page(“y”).webbutton(“z”).sync

  • Use of Wait Statement: You can insert Exist or Wait statements that tell QTP to wait until an object exists or to wait a specified amount of time before continuing the test.
E.g.  
            Wait(10) or Wait // After 10 second, qtp start execution below statement
Browser(“x”).page(“y”).webbutton(“z”).sync

  • Increase timeout time: You can also increase the default timeout settings in the Test Settings and Options dialog boxes in order to tell QTP to allow more time for certain events to occur.
We can set from here File >> Settings >> Run, Increase Object Synchronization timeout limit.

Friday, February 11, 2011

Execution of .vbs or .txt files in qtp

To execute the .vbs or .txt files in qtp, user has to associate those file in qtp

Associate library files in qtp

Concept behind this association of library file is that the script is written in separate library file like .vbs or .txt file and to run script you need to associate those files if you want to use them. After Association of the file, File will place in File -> settings -> resource.

There are two way to execute those files in qtp

1.       ExecuteFile key word
2.       Associate in Library

1.       ExecuteFile keyword:

ExecuteFile "File path" ( E.g: ExecuteFile “C:\test.vbs” )
In this concept, user has to call the function defined the .vbs file. Here library file will not be placed in File -> settings -> resource. But still user can access function defile in the file.
2.       Associate in Library:
Here, run time association of the file will be placed in File -> settings -> resource path in qtp.
Now user can access the function by calling it.

Example:

Set App = CreateObject("QuickTest.Application")
App.Launch
App.Visible = True
App.Test.Settings.Resources.Libraries.RemoveAll
App.Test.Settings.Resources.Libraries.Add "D:\test1.vbs”
App.Test.Settings.Resources.Libraries.Add "D:\test2.vbs"
Set App = Nothing

Note:    Associate file concept will help users to debug in file while run time however ExecuteFile will not be help in debugging.


Thursday, February 10, 2011

Data Table Object Details


1 AddSheet Method

Adds the specified sheet to the run-time Data Table 
      Syntax: DataTable.AddSheet(SheetName)
      Example:
      Variable=DataTable.AddSheet ("Sheet1").AddParameter("Name", "Neeraj")

2.    DeleteSheet Method

Deletes the specified sheet from the run-time Data Table.
Syntax: DataTable.DeleteSheet SheetID
Example: DataTable.DeleteSheet "Sheet1“

3.    Export Method

Saves a copy of the run-time Data Table in the specified location.
Syntax: DataTable.Export(FileName)
Example: DataTable.Export ("C:\FileName.xls")

4.    ExportSheet Method

Exports a specified sheet of the run-time Data Table to the specified file.
Syntax: DataTable.ExportSheet(FileName, DTSheet)
Example: DataTable.ExportSheet "C:\FileName.xls" ,1

5.    GetCurrentRow Method

Returns the current (active) row in the run-time global data sheet.

6.    GetRowCount Method

Returns the total number of rows in the longest column in the global data sheet or in the specified data sheet of the run-time Data Table.
Example:
rowcount = DataTable.GetSheet("Sheet1").GetRowCount

7.    GetSheet Method

Returns the specified sheet from the run-time Data Table.
Example:MyParam=DataTable.GetSheet ("Sheet1").AddParameter("Name", "Neeraj")

8.    GetSheetCount Method

Returns the total number of sheets in the run-time Data Table.

9.    Import Method

Imports the specified Microsoft Excel file to the run-time Data Table.
Syntax: DataTable.Import(FileName)
Example: DataTable.Import ("C:\FileName.xls")

10. ImportSheet Method

Imports a sheet of a specified file to a specified sheet in the run-time Data Table.
Syntax:  DataTable.ImportSheet(FileName, SheetSource,SheetDest)
Example: DataTable.ImportSheet "C:\FileName.xls,1 ,"name"

11. SetCurrentRow Method

Sets the specified row as the current (active) row in the run-time Data Table.
Example: DataTable.SetCurrentRow (2)

12. SetNextRow Method

Sets the row after the current (active) row as the new current row in the run-time Data
Table.

13. SetPrevRow Method

Sets the row above the current (active) row as the new current (active) row in the run-time
Data Table.

14. GlobalSheet Property

Returns the Global sheet of the run-time Data Table.
Example:
DataTable.GlobalSheet.AddParameter "Name", "Neeraj"

15. LocalSheet Property

Returns the current (active) local sheet of the run-time Data Table.
Example:
MyParam=DataTable.LocalSheet.AddParameter("Name ", " Neeraj ")

16. RawValue Property

Retrieves the raw value of the cell in the specified parameter and the current row of the run-time
Data Table.
Syntax: DataTable.RawValue ParameterID [, SheetID]
SheetID can be the sheet name, index or dtLocalSheet, or dtGlobalSheet.

17. Value Property

Retrieves or sets the value of the cell in the specified parameter and the current row of the run-time Data Table.
Syntax:DataTable.Value(ParameterID [, SheetID])

Wednesday, February 9, 2011

Write Log Report in QTP with the help of Class


' Calling class method.
dim fineName
set objLogger = new Logger fileName = objLogger.createLogFile()
objLogger.getInput "1",Date,"Login","User can Login","Login successfully","Pass"
objLogger.writeLogDetails fileName

' Class defination


Class Logger
           dim slNo
           dim dtTime
           dim functionName
           dim expectedResult
           dim actualResult
           dim status
           dim path

             Function createLogFile()

                            path = inputbox("Enter the log path:")
                            driveName = "d:\" 
                            Fullpath = driveName & path 
                            set fso = CreateObject("Scripting.FileSystemObject")
                            set f1 = fso.CreateTextFile(FullPath, True)

                             If (fso.FileExists(Fullpath)) Then
                                    msgbox Fullpath & " exists."                            
                             Else
                                    msgbox = Fullpath & " doesn't exists."
                             End If                            
                             createLogFile=Fullpath
            End Function

  Function getInput(VslNo,VdtTime,VfunctionName,VexpectedResult,VactualResult,Vstatus)      
                            slNo = Vslno
                            dtTime = VdtTime
                             functionName = VfunctionName 
                             expectedResult = VexpectedResult
                             actualResult = VactualResult
                             status = Vstatus
            End Function 

            Function writeLogDetails(fpath)
                            f1.writeLine = slNo
                            f1.writeLine = dtTime
                            f1.writeLine = functionName
                            f1.writeLine = expectedResult
                            f1.writeLine = actualResult
                            f1.writeLine = status
                           msgbox "write Done"
           End function
End Class

Tuesday, February 8, 2011

What is Output Values and types of Output Values ?

An output value is a step in which one or more values are captured at a specific point in your test or component and stored for the duration of the run session. The values can later be used as input at a different point in the run session.

Output values are stored only for the duration of the run session. When the run session is repeated, the output values are reset.

You can insert an output value by using commands on the Insert menu or by clicking the arrow beside the Insert Checkpoint button on the Test toolbar. This displays a menu of options that are relevant to the selected step in the test tree.

Types of Output Values

1: Page Output Values:
You can create a page output value from a Web page property value. When you run the test,
QuickTest retrieves the current value of the property and stores it in the run-time Data Table as an
output value.

2: Text Output Values:
QuickTest allows you to create text output values by adding one of the following to your test:
     Text Output Value—enables you to output the text displayed in a screen or Web page, according to 
              specified criteria. It is supported for all environments.
     Standard Output Value—enables you to output an object’s text property. This is the preferred way of
             outputting the text displayed in many Windows applications.
     Text Area Output Value—enables you to output the text string displayed within a defined area of a
            Windows-application screen, according to specified criteria. It is supported for Standard
            Windows, Visual Basic, and ActiveX environments.

3: Standard Output Values:
You can create a standard output value from an object property value. When you run the test, QuickTest
retrieves the current value of the property and enters it in the run-time Data Table as an output value.

4: Image Output Values:
You can create an image output value from the property value of a Web image. When you run the test,
QuickTest retrieves the current value of the property and enters it in the run-time Data Table as an output
value.

5: XML Output Values:
You can create an XML output value from an element value or attribute of an XML file or Web page/frame.
When you run the test, QuickTest retrieves the current value of the element or attribute and enters it in the
run-time Data Table as an output value.

When you run your test, you can view summary results of the XML output value in the Test Results window.
You can also view detailed results by opening the XML Output Value Results window.

6: Table Output Values:
You can create a table output value from the contents of a table cell. When you run the test, QuickTest
retrieves the current value of a table cell and enters it in the run-time Data Table as an output value.

7: Database Output Values:
You can create a database output value from the contents of a database cell. When you run the test,
QuickTest retrieves the current value of a database cell and enters it in the run-time Data Table as an output
value.

Types of environment variables in QTP

There are three Types of Environment Variables in qtp
 1: User-Defined Internal
2: User-Defined External
3: Build-in

1: User-Defined Internal

User defined internal variables are the variables that you define within the test. They are saved with the test and accessible only within the test in which they were defined.

        • In the Edit value section of the Object Properties, Object Repository, Method Arguments, or 
          Checkpoint Properties dialog box, click Other as the type of parameter you want to use.
       • Click the Edit Parameter Options button next to the parameter type box. The Parameter Options

         dialog box opens.
       • Select Environment in the Parameter Types box.
       • Accept the default name or enter a new name to add a new user-definedinternal environment

          parameter, or select an existing environment variable name from the Name box. If you select an 
         existing internal parameter, you can modify the value.
       • If you created a new parameter or selected an existing user-defined-internal parameter, enter the value

         for the parameter in the Value box.
       • Select the Regular Expression check box if needed and Enter the regular expression
       • Click OK to save your changes and close the dialog box.

2: User-Defined External

User defined external variables are the variable that you pre-defined in the active external environment variables file. You can create as many files as you want and select an appropriate file for each test. Note that external environment variable values are designated as read-only within the test.

To define these variables create an external environment variables file
To select the active external environment-variables file:
      • Choose Test > Settings to open the Test Settings dialog box.
      • Click the Environment tab.
      • Select the Load variables and values from external file (reloaded each test run) check box.
      • Use the browse button or enter the full path of the external environment- variables file you want to use
         with your test.

3: Build-in



Built-in variables, such as Test path and Operating system. They are accessible from all tests, and are designated as read-only.
Steps to add or modify environment variable parameters:       

What is Parameterization in qtp and Types of Parameterize ?

A parameter is a variable that is assigned a value from various data sources or generators.

Types of Parameter :

Test, Actions and component parameters enable you to use values passed from your test or component, or values from other actions in your test.


Environment variable parameters enable you to use variable values from other sources during the run session.
Random number parameters enable you to insert random numbers as values in your test or component.

How to do User-defined checkpoint in QTP

Dim OuterHTMLPro

OuterHTMLPro = Browser("BrowserName").Page("PageName").WebEdit("Editboxname").GetROProperty("outerHTML")

If OuterHTMLPro <> "name=neeraj" Then
       Reporter.ReportEvent micPass, "Property mached", "Property is Same"
Else
       Reporter.ReportEvent micFail, "Property mached", "Property is not Same"
End If

Monday, February 7, 2011

Close all open browser before start execution

Public Function CloseAllBrowsers()


     'Create a description for browser
      Set oBrowser = Description.Create
      oBrowser("micclass").Value = "Browser"
      Set oPage = Description.Create
      oPage("micclass").Value = "Page"
      'Get all browsers
      Set allBrowser = Desktop.ChildObjects(oBrowser)
      Dim i, iCount
      iCount = allBrowser.Count - 1
      For i = 0 To iCount
            'Get the page object from the browser
            Set oPg = allBrowser(i).ChildObjects(oPage)(0)
            allBrowser(i).Close
     Next

End Function

Thursday, February 3, 2011

Test Object Model Concept

The test object model is a large set of object types or classes that QuickTest uses to represent the objects in your application. Each test object class has a list of properties that can uniquely identify objects of that class and a set of relevant methods that QuickTest can learn about it.

A test object is an object that QuickTest creates in the component to represent the actual object in your application. QuickTest stores information on the object that will help it identify and check the object during the run session.

A run-time object is the actual object in your application on which methods are performed during the run session

Each Test object Properties contains:

1. Name ( Logical Name )
2. Class ( Button, Edit box, Combo box etc)
3. Physical Property ( Test Object details)
        a. HTML Property Name
        b. Value of HTML Property

Understanding How QuickTest Identifies Objects during the Run Session

During a run session, QuickTest searches for a run-time object that exactly matches the description of the test object it learned previously. It expects to find a perfect match for both the mandatory and any assistive properties it used to create a unique description while learning the object. As long as the object in the application does not change significantly, the description learned is almost always sufficient for QuickTest to uniquely identify the object. This is true for most objects, but your application could include objects that are more difficult to identify during subsequent run sessions.
QuickTest uses process of elimination with its Smart Identification mechanism to identify an object, even when the learned description is no longer accurate. Even if the values of your test object properties change, QuickTest maintains your component's reusability by identifying the object using Smart Identification.

Understanding How QuickTest Learns Objects

Object being learned and stores it as a test object, determining in which test object class it fits. In the same way, QuickTest might classify the test object as a standard Windows dialog box (Dialog), a Web button (WebButton), or a Visual Basic scroll bar object (VbScrollBar)

Then, for each test object class, QuickTest has a list of mandatory properties that it always learns; When QuickTest learns an object, it always learns these default property values, and then "looks" at the rest of the objects on the page, dialog box, or other parent object to check whether this description is enough to uniquely identify the object. If it is not, QuickTest adds assistive properties, one by one, to the description, until it has compiled a unique description; If no assistive properties are available, or if those available are not sufficient to create a unique description, QuickTest adds a special ordinal identifier, such as the object's location on the page or in the source code, to create a unique description.

Keyword- Driven concept in QTP

Keyword-driven testing is a technique that separates much of the programming work from the actual test steps so that the test steps can be developed earlier and can often be maintained with only minor updates, even when the application or testing needs change significantly.
Using the keyword-driven approach, test automation experts have full access to the underlying test and object properties, via an integrated scripting and debugging environment that is round-trip synchronized with the Keyword View.

New Features in QTP 9.5

QuickTest now offers the following new features.


  1. Process Guidance. QuickTest offers a special Process Guidance tool that lets you navigate through the core activities of important testing processes to learn how to best perform those processes.
  2. Maintenance Run Mode. Maintenance Run Mode enables you to run your test or component and to update your steps and repositories as the test or component runs to reflect changes in the application.
  3. New QuickTest IDE Panes. QuickTest has introduced the Test Flow pane, Resources pane, Available Keywords pane, and Missing Resources pane to help you create and manage tests and components faster and easier.
  4. All-in-one QuickTest Installation. The QuickTest installation enables you to install any or all QuickTest add-ins.
  5. Checkpoint and Output Objects in the Object Repository. When you insert a checkpoint or output value, it is created as an object and stored in your local object repository.
  6. Test Your PowerBuilder Applications in QuickTest. QuickTest now offers the PowerBuilder Add-in for testing your Power Builder applications.
  7. Extend QuickTest Web Support for your Custom Web Objects. The new QuickTest Professional Web Add-in Extensibility enables you to provide high-level support for third-party and custom Web controls that are not supported out-of-the-box by the Web Add-in.
  8. Accelerate SAP Testing with HP Business Process Testing for SAP Applications. The HP Business Process Testing for SAP Applications solution enables you to automatically create and manage components and flows that represent screens and transactions in your SAP application.

Wednesday, February 2, 2011

Why Automated Testing?

Below is the resone for Why Automation Testing.
  1. Automated Software Testing Saves Time and Money
  2. Automated Software Testing Improves Accuracy
  3. Automated Software Testing Increases Test Coverage
  4. Automated Software Testing Does What Manual Testing Cannot
  5. Automated Software Testing Helps Developers and Testers
  6. Automated Software Testing Improves Team Morale


Defining boundaries between automation framework and a testing tool

Tools are specifically designed to target some particular test environment. Such as: Windows automation tool, web automation tool etc. It serves as driving agent for an automation process. However, automation framework is not a tool to perform some specific task, but is an infrastructure that provides the solution where different tools can plug itself and do their job in an unified manner. Hence providing a common platform to the automation engineer doing their job.


There are various types of frameworks. They are categorized on the basis of the automation component they leverage. These are:
  1. Data-driven testing  
  2. Modularity-driven testing  
  3. Keyword-driven testing  
  4. Hybrid testing  
  5. Model-based testing

Framework approach in automation

A framework is an integrated system that sets the rules of Automation of a specific product. This system integrates the function libraries, test data sources, object details and various reusable modules. These components act as small building blocks which need to be assembled to represent a business process. The framework provides the basis of test automation and simplifies the automation effort.




Popular Test Automation Tools

Tool Name                                      Company Name             Latest Version

========================================================
HP QuickTest Professional               HP                                 11.0
IBM Rational Functional Tester        IBM Rational                  8.1.0.3
Parasoft SOAtest                             Parasoft                          9.0
Rational robot                                  IBM Rational                  2003
Selenium                                          OpenSource Tool           1.0.6
SilkTest                                           Micro Focus                   2010
TestComplete                                  SmartBear Software        8.0
TestPartner                                     Micro Focus                    6.3
Visual Studio Test Professional        Microsoft                         2010
WATIR                                          OpenSource Tool             1.6.5