Tuesday, 30 July 2013

Dictionary Object

Dictionary Object is a object that stores data key, item pairs.

A Dictionary object is the equivalent of a PERL associative array. Items can be any form of data, and are stored in the array. Each item is associated with a unique key. The key is used to retrieve an individual item and is usually an integer or a string, but can be anything except an array.

Following methods can be used with Dictionary Objects:

1-Add- Adds a key and item pair to a Dictionary object.
2-Exists- Returns true if a specified key exists in the Dictionary object, false if does not.
3-Items- Returns an array containing all the items in a Dictionary object.
4-Keys- Returns an array containing all existing keys in a Dictionary object.
5-Remove- Removes a key, item pair from a Dictionary object.
6-RemoveAll- RemoveAll method removes all key, item pairs from a Dictionary object.

The following code illustrates how to create a Dictionary object:


Dim d   'Create a variable.
Set d = CreateObject("Scripting.Dictionary")
d.Add "a", "Athens"   ' Add some keys and items.
d.Add "b", "Belgrade"
d.Add "c", "Cairo"

If d.Exists("c") Then
    msg = "Specified key exists."
Else
   msg = "Specified key doesn't exist."
End If

a = d.Items   ' Get the items.
For i = 0 To d.Count -1 ' Iterate the array.
   s = s & a(i) & "<BR>" ' Create return string.
Next

b = d.Keys   ' Get the keys.
For j = 0 To d.Count -1 ' Iterate the array.
    t = t & b(j) & "<BR>" ' Return results.
Next

d.Remove("b")   ' Remove second pair.
c = d.RemoveAll   ' Clear the dictionary.


Tuesday, 2 July 2013

Difference between ChildObjects, ChildItem and Getcelldata in QTP

ChildObjects method is to access total child objects from an object using description object. In other words, it returns the collection of child objects contained within the object.

Syntax:- object.ChildObjects ([Description])
ChildItem method is to access child objects from a web table cell in web table object without using description object. In other words, it returns a test object from the cell by type and index. 

Syntax:-object.ChildItem (Row, Column, MicClass, Index)
Getcelldata method is to retrieve data from a web table cell in web table object.

Syntax:-object.GetCellData (Row, Column) 


Tuesday, 28 May 2013

Does QTP support Endur Automation?


Yes, QTP support endur automation. But for doing that one needs OLF plugin. One can buy this OLF plugin from Openlink itself.

I have worked on endur automation with QTP, though it has challenges but by using OLF plugin, 70-80% of the objects will be identified by QTP. Below is the sample code how it works with QTP-








Related Article on Endur Automation-
Endur Automation Posts




QTP Openlink Endur Automation

Limitations of QTP OLF Plugin
  1. Only about 75-80 % object are being identified.
  2. QTP’s Virtual Object functionality does not work with the OLF QTP Addin. 
  3. QTP Text/Text Area Checkpoints do not work with the OLF QTP Add-in.
  4.  Login screen is not automation enabled, QTP doesn't identify the controls, OITestAgent not loaded until after logon.
  5. Sometimes by using Object Spy, it shows you the object’s properties but QTP will not add or Record  on the object (e.g. Current Date in Market Manager window)
  6. In Trading Manager window, when  we  find any deal, the returned deal (shown as a box in the window) is not being  identified by QTP.
  7. QTP does not recognize arrow button that is used to select different tabs from desktop window.

Related Endur Automation Posts


DOM Uses in QTP


Wikipedia defines Document Object Model(DOM) as:

A platform- and language-independent standard object model for representing HTML or XML and related formats.

In QTP, one can understand DOM as a method for accessing the source code of a webpage directly through vb scripting. 
Web pages typically consist of graphics and text written in HTML. Web pages may also use other scripted languages such as Java, JavaScript, Common Gateway Interface (CGI), and Visual Basic script. To view the HTML source code for a Web page, right-click the Web page, and then click View Source.We can access the source page of any webpage using .object notation.

For example- if you need to check total links on a web browser, then you can use the following code:


Set Links = Browser("Google").Page("Google").Object.Links
msgbox "Total links: " & Links.Length

Common HTML DOM Methods-


getElementById Method - Returns a reference to the first object with the specified value of the ID attribute.


'Sets the value of obj to the first element in the page that has an ID of "mark":
Set obj = Browser("Browser").Page("Yahoo!").Object.getElementByID("mark")


'Sets value in web edit using element's ID:
Browser("name:=Google").Page("title:=Google").Object.getElementByID("XXXX").Value="QTP"

getElementsByName Method - Retrieves a collection of objects based on the value of the NAME attribute.



Set obj= Browser("name:=Google").Page("title:=Google").Object
.getElementsByTagName("INPUT")  
inCount=obj.Length-1  

For i=0 to inCount  
If obj(i).Name="q" and obj(i).Type="text" Then  
Browser("name:=Google").Page("title:=Google").Object.getElementsByName(obj(i).Name)(0).Value="QTP" 'Sets value in web edit using element's name.  
End If  
Next



getElementsByTagName Method - Retrieves a collection of objects based on the specified element name.


Set Parent = Browser("Mortgage Calculator").Page("Mortgage Calculator")
Set obj = Parent.Object.getElementsByTagName("input")
inCount=obj.Length-1 

For i=0 to inCount
    If obj(i).Name="param" and obj(i).Type="text" Then
        obj(i).Value="QTP"  
   End If
Next 


More Examples-

1-'find the src of the images in the web table
Set img = Browser(“Browser”).Page(“Page”).WebTable(“Happy”).Object.all.tags(“img”)
msgbox img.length

For i=0 to img.length-1
   msgbox img(i).src
Next

2-'find the column count in a web table-
Set col=Browser(“Browser”).Page(“Page”).WebTable(“Happy”).Object.cols
msgbox col.count

Monday, 27 May 2013

CheckPoints in QTP

QuickTest enables you to add checks to your test. A checkpoint is a verification that compares the current value for specified properties of an object with the expected value. This helps you to identify whether your application is functioning correctly.


When you add a checkpoint, QuickTest inserts a checkpoint step to the current row in the Keyword View and adds a Check CheckPoint statement in the Expert View. By default, QuickTest names the checkpoint using the name of the test object on which the checkpoint was created. 

Types of CheckPoints-

You can insert the following checkpoint types to check objects in an application-


Standard Checkpoint-  Checks property values of an object in your application. For example, you can check that a radio button is activated after it is selected or you can check the value of an edit box. 
Standard checkpoints are supported for all add-in environments.

Image Checkpoint-  Checks the value of an image in your application. For example, you can check that a selected image's source file is correct. 
You create an image checkpoint by inserting a standard checkpoint on an image object. Image checkpoints are supported for the Web add-in environment.

Bitmap Checkpoint-  Checks an area of your application as a bitmap. For example, suppose you have a Web site that can display a map of a city the user specifies. The map has control keys for zooming. Using the bitmap checkpoint, you can check that the map zooms in correctly. 
You can create a bitmap checkpoint for any area in your application. Bitmap checkpoints are supported for all add-in environments.

Table Checkpoint-  Checks information within a table. For example, suppose your application contains a table listing all available flights from New York to San Francisco. You can add a table checkpoint to check that the time of the first flight in the table is correct. 
Table checkpoints are supported for all add-in environments that have a Table test object. Table checkpoints are also supported for some list view objects, such as WinListView and VbListView.

Text Checkpoint-  Checks that a text string is displayed in the appropriate place in an application. For example, suppose a Web page displays the sentence Flight departing from New York to San Francisco. You can create a text checkpoint that checks that the words "New York" are displayed between "Flight departing from" and "to San Francisco". Text checkpoints are supported for most add-in environments.

Text Area Checkpoint-  Checks that a text string is displayed within a defined area in a Windows-based application, according to specified criteria. For example, suppose your Visual Basic application has a button that says View Doc <Num>, where <Num> is replaced by the four digit code entered in a form elsewhere in the application. You can create a text area checkpoint to confirm that the number displayed on the button is the same as the number entered in the form. 
Text area checkpoints are supported for all Windows-based environments, such as Standard Windows, Visual Basic, and ActiveX add-in environments.

Accessibility Checkpoint-  Identifies areas of your Web site that may not conform to the World Wide Web Consortium (W3C) Web Content Accessibility Guidelines. For example, guideline 1.1 of the W3C Web Content Accessibility Guidelines requires you to provide a text equivalent for every non-text element. You can add an Alt property check to check whether objects that require the Alt property under this guideline, do in fact have this tag. Accessibility checkpoints are supported for the Web add-in environment. 

Page Checkpoint-  Checks the characteristics of a Web page. For example, you can check how long a Web page takes to load or whether a Web page contains broken links. 
You create a page checkpoint by inserting a standard checkpoint on a page object. Page checkpoints are supported for the Web add-in environment. 

Database Checkpoint-  Checks the contents of a database accessed by your application. For example, you can use a database checkpoint to check the contents of a database containing flight information for your Web site. Database checkpoints are supported for all add-in environments. 

XML Checkpoint-  Checks the data content of XML documents in XML files or XML documents in Web pages and frames. For more information on XML checkpoints, see XML Checkpoints. 
The XML Checkpoint (Web Page/Frame) option is supported for the Web add-in environment. The XML Checkpoint option is supported for all add-in environments.


Friday, 24 May 2013

DataTable Methods in QTP

DataTable Methods

One can apply number of methods on run time DataTable.  All methods performed on this object apply to the run-time DataTable object only. Changes to the run-time DataTable object are reflected in the run results, but the design-time Data Table is not affected.

Associated Methods -


1- AddSheet Method
Adds the specified sheet to the run-time Data Table and returns the sheet so that you can directly set properties of the new sheet in the same statement.

Syntax- DataTable.AddSheet(SheetName)
Example- DataTable.AddSheet ("MySheet")

2- DeleteSheet Method
Deletes the specified sheet from the run-time Data Table.

Syntax- DataTable.DeleteSheet SheetID or SheetName
Example- DataTable.DeleteSheet "MySheet"

3- Export Method
Saves a copy of the run-time Data Table in the specified location.

Syntax- DataTable.Export(FileName)
Example- DataTable.Export ("C:\flights.xls")

4- ExportSheet Method

Exports a specified sheet of the run-time Data Table to the specified file.

  • If the specified file does not exist, a new file is created and the specified sheet is saved.
  • If the current file exists, but the file does not contain a sheet with the specified sheet name, the sheet is inserted as the last sheet of the file.
  • If the current file exists and the file contains the specified sheet, the exported sheet overwrites the existing sheet.

Syntax- DataTable.ExportSheet(FileName, DTSheet)
Example- DataTable.ExportSheet "C:\name.xls" ,1     'Saving first sheet of the run-time Data Table to the name.xls file

5- Import Method
Imports the specified Microsoft Excel file to the run-time Data Table.

Syntax- DataTable.Import(FileName) 
Example- DataTable.Import ("C:\flights.xls") 

6- ImportSheet Method
Imports a sheet of a specified file to a specified sheet in the run-time Data Table. The data in the imported sheet replaces the data in the destination sheet. 

Syntax- DataTable.ImportSheet(FileName, SheetSource, SheetDest)
Example- DataTable.ImportSheet "C:\name.xls" ,1 ,"name"   'Importing the first sheet of the name.xls table to the name sheet in the test's run-time Data Table.

7- GetCurrentRow Method
Returns the current (active) row in the first sheet in the run-time Data Table (global sheet).

Syntax- DataTable.GetCurrentRow
Example- row = DataTable.GetCurrentRow   'Retrieving the row currently used in run-time DataTable.


8- GetRowCount Method
Returns the total number of rows in the longest column in the first sheet in the run-time Data Table (global sheet). 

Syntax- DataTable.GetRowCount
Example- cnt=DataTable.GetRowCount
              rowcount = DataTable.GetSheet("MySheet").GetRowCount


9- GetSheet Method
Returns the specified sheet from the run-time Data Table. 

Syntax-  DataTable.GetSheet(SheetID)
Example- MyParam=DataTable.GetSheet ("MySheet").AddParameter("Time", "8:00")     'using GetSheet method to return the "MySheet" sheet of the run-time Data Table and add a parameter to it.

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

Syntax- DataTable.GetSheetCount
Example- sheetcount = DataTable.GetSheetCount


11- SetCurrentRow Method
Sets the specified row as the current (active) row in the run-time Data Table. 

Syntax- DataTable.SetCurrentRow(RowNumber)
Example- DataTable.SetCurrentRow (2)  'using SetCurrentRow method to change the active row to the second row in the global run-time Data Table.


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

Syntax- DataTable.SetNextRow
Example- DataTable.SetNextRow

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

Syntax- DataTable.SetPrevRow
Example- DataTable.SetPrevRow

Associated Properties-

1- GlobalSheet Property
Returns the first sheet in the run-time Data Table (global sheet).

Syntax- DataTable.GlobalSheet
Example- DataTable.GlobalSheet.AddParameter "Time", "5:45"

2- LocalSheet Property
Returns the current (active) local sheet of the run-time Data Table.

Syntax- DataTable.LocalSheet
Example- DataTable.LocalSheet.AddParameter("Time", "5:45")

3- 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 is optional if not used, global sheet of run time data table is used.
Example- Val=DataTable.RawValue ("Date", "Sheet1")  'Using Sheet1
                Val=DataTable.RawValue ("Date")  'Using Global Sheet

4- Value Property
DataTable default property. Retrieves or sets the value of the cell in the specified parameter and the current row of the run-time Data Table.

Syntax-
To find the value:

DataTable.Value(ParameterID [, SheetID])   'SheetId is optional if not used, global sheet of run time data table is used.

or

DataTable(ParameterID [, SheetID])   'SheetId is optional if not used, global sheet of run time data table is used.

To set the value:

DataTable.Value(ParameterID [, SheetID])=NewValue   'SheetId is optional if not used, global sheet of run time data table is used.

or

DataTable(ParameterID [, SheetID]) =NewValue    'SheetId is optional if not used, global sheet of run time data table is used.

Example- DataTable.Value ("Destination", "Sheet1")="ABC"    'Using Sheet1
                DataTable.Value ("Destination")="ABC"        'Using Global Sheet
               Val=DataTable.Value("Name","dtGlobalSheet")                      'Using Global Sheet
               Val=DataTable.Value("Name",1)           'Using Sheet1
               Val=DataTable.Value("Name")             'Using Global Sheet

  


Wednesday, 15 May 2013

Object Identification Workflow

Object Identification Workflow

Below are the steps that will follow to identify a object-

Step 1- QuickTest first attempts to identify the test object using the object’s description properties.
Step 2- If QuickTest finds one or more objects matching the test object’s description and VRI is also defined then it attempts to identify the object using the visual relation identifier.
Step 3- After the visual relation identifier is applied, if no objects or more than one object is found, the visual relation identifier fails, and QuickTest continues to identify with Smart Identification (when defined for that test object class).
Step 4- If no VRI is defined and if no objects or more than one object is found after Smart Identification is applied, QTP will use Ordinal Identifier mechanism.




Visual Relation Identifier-


A visual relation identifier is a set of definitions that enable you to identify the object in the application according its neighboring objects in the application. You can select neighboring objects that will maintain the same relative location to your object, even if the user interface design changes. This enables you to help QuickTest in creating more stable object repositories that can withstand predictable changes to the application’s user interface.

One can define visual relations in the Visual Relation Identifier dialog box, which is accessible from the local or shared object repository, and from the Object Properties dialog box

Visual Relation Categories (Relation Details Area) Category Description-

1- Horizontal - enables you to define related objects according to their horizontal location relative to the object to identify. The following options are available:

➤ Left
➤ Right
➤ In line (horizontally)

2- Vertical- enables you to define related objects according to their vertical location relative to the object to identify. The following options are available:

➤ Above
➤ Below
➤ In line (vertically)

3- Distance and hierarchy- enables you to define related objects according to their distance or hierarchical location relative to the object to identify. The following options are available:

➤ Closest on the X-axis
➤ Closest on the Y-axis
➤ Closest on both axes
➤ Contains

Considerations for Working with Visual Relation Identifiers-

Consider the following when working with visual relation identifiers:

1- If you define a visual relation identifier for a test object, then that test object’s ordinal identifier (if it exists) is not used during the test object identification process.
2- If you add a related object that was not previously in the object repository, then the test object for the related object is added to that object repository.
3- Visual relation identifiers are used only during a run session, or when identifying objects in the application. Therefore, even if you define related objects for a specific test object, if QuickTest re-learns the object, it uses only the identification properties that are defined in the Object Identification dialog box for that test object class.
4- A test object cannot be used as a related object to itself.
5- If you delete a test object (A) that is used in the visual relation identifier for another test object (B), you must make sure to remove the deleted test object A from the Related Object list for test object B.
6- Visual relation identifiers are not supported for WebService test objects.


Ordinal Identifier


An ordinal identifier assigns a numerical value to a test object that indicates its order or location relative to other objects with an otherwise identical description (objects that have the same values for all properties). This ordered value provides a backup mechanism that enables QuickTest to create a unique description to recognize an object when the defined properties are not sufficient to do so.

Note: When visual relation identifiers are used, the Ordinal identifier option is disabled in the Object Repository Manager or window.

QuickTest can use the following types of ordinal identifiers to identify an object:

Index- Indicates the order in which the object appears in the application code relative to other objects with an otherwise identical description. 

Location- Indicates the order in which the object appears within the parent window, frame, or dialog box relative to other objects with an otherwise identical description. 

CreationTime- (Browser object only.) Indicates the order in which the browser was opened relative to other open browsers with an otherwise identical description.


Smart Identification


When QuickTest uses the learned description to identify an object, it searches for an object that matches all of the property values in the description. In most cases, this description is the simplest way to identify the object, and, unless the main properties of the object change, this method will work.

If QuickTest is unable to find any object that matches the learned object description, or if it finds more than one object that fits the description, then QuickTest ignores the learned description, and uses the Smart Identification mechanism (if defined and enabled) to try to identify the object.

The Smart Identification dialog box enables you to create and modify the Smart Identification definition that QuickTest uses for a selected test object class. Configuring Smart Identification properties enables you to help QuickTest identify objects in your application, even if some of the properties in the object’s learned description have changed.

The Smart Identification mechanism uses two types of properties:

Base Filter Properties- The most fundamental properties of a particular test object class; those whose values cannot be changed without changing the essence of the original object. For example, if a Web link’s tag was changed from <A> to any other value, you could no longer call it the same object.

Optional Filter Properties- Other properties that can help identify objects of a particular class. These properties are unlikely to change on a regular basis, but can be ignored if they are no longer applicable. 

If QuickTest successfully uses Smart Identification to find an object after no object matches the learned description, the step is assigned a Warning status in the Run Results, and the result details for the step indicate that the Smart Identification mechanism was used.

Smart Identification Process-

If QuickTest activates the Smart Identification mechanism during a run session (because it was unable to identify an object based on its learned description), it follows the following process to identify the object:

1- QuickTest "forgets" the learned test object description and creates a new object candidate list containing the objects (within the object’s parent object) that match all of the properties defined in the Base Filter Properties list.

2- QuickTest filters out any object in the object candidate list that does not match the first property listed in the Optional Filter Properties list. The remaining objects become the new object candidate list.

3- QuickTest evaluates the new object candidate list:

If the new object candidate list still has more than one object, QuickTest uses the new (smaller) object candidate list to repeat step 2 for the next optional filter property in the list.
If the new object candidate list is empty, QuickTest ignores this optional filter property, returns to the previous object candidate list, and repeats step 2 for the next optional filter property in the list.
If the object candidate list contains exactly one object, then QuickTest concludes that it has identified the object and performs the statement containing the object.

4- QuickTest continues the process described in steps 2 and 3 until it either identifies one object, or runs out of optional filter properties to use. If, after completing the Smart Identification elimination process, QuickTest still cannot identify the object, then QuickTest uses the learned description plus the ordinal identifier to identify the object.
If the combined learned description and ordinal identifier are not sufficient to identify the object, then QuickTest stops the run session and displays a Run Error message.

Tuesday, 14 May 2013

Difference in different QTP versions


Advantages of QTP 9.0 over 8.2-


In QTP 8.2-

1) The Object Repository Modes are PerAction and Shared.
2) The QTP script can get connected to one repository at one time. If per action, every action of the QTP Test Script is connected to one Repository and if shared then all the actions will be connected to one Shared Repository.
3) For shared Repository QTP Script, upon recording the user activities on AUT, the objects will be added to the Repository connected.
4) In QTP 8.2, if you do not select an add-in to load then you cannot do it in the same session. You have to close QTP and then login again.
5) QTP 8.2 and below do not have support for Firefox. 8.2 and below do not include support for Internet Explorer 7.0.
6) In QTP 8.2 ‘Information pane’ and ‘Missing resources pane’ was not included. 

In QTP 9.0 version-

1) The Object Repository Modes are local and shared.
2) The QTP script can get connected to more than one repository at one time. An Action can be associated to more than one repository simultaneously. The Repositories it connects should be Shared (external in Read only mode) other than its own Repository (Local).
3) Upon recording the user activities on AUT, the objects will be added to the Local Repository but not the Shared as it will be read only mode.
4) QTP 9.0, IF you do not select an add-in you can select it in the same session via 
File->Settings->Properties tab->Modify button. 
5) QTP 9.0 provides replay support for Mozilla FireFox 1.5.  also 9.0 supports Internet Explorer 7.0.
6) In QTP 9.0 ‘Information pane’ and ‘Missing resources pane’ was included. 

Advantages of QTP 9.2 over 9.0-

1-Dynamic Management of Object Repositories- QuickTest now has a new ‘RepositoriesCollection’ reserved object that you can use to programmatically manage the set of object repositories that are associated with an action during a run session.

2-Added ‘Object Repository Manager’ which helps in merging and comparing two ORs.


Between QTP 9.5 & earlier versions 

1- Checkpoints and Output values can be seen & edited in the OR while same was not possible in the earlier versions of QTP.
2- Installation file is a single one bundled with all add-ins, previously we have to download add-ins separately.
3- Movie recorder was introduced in the results
4- Web add-in extensibility add- in was introduced
5- It also supports the 64 bit windows edition while the earlier were supporting only 32 bit systems only
6- Bitmap tolerance feature was introduced in QTP 9.5


New features/enhancements in QTP 10-

1-System performance parameters can be monitored- Local System Performance Monitor: provides the ability to monitor several resources on the computer throughout the run-session, and define custom thresholds for them.

2- Complete UI changes- most of the UI is changed, option menus are now presented as trees rather than tabs, giving a more updated look. The open / save dialogs were also updated to display a much friendlier big-button style.

3-To Do Pane- Along with all the old IDE panes DataTable, Missing Resources, Debug, Active Screen, Available Keywords, Resources, and Test Flow, a new pane is there To-Do pane. The To-Do pane contains two tabs – Tasks and Comments. Whenever we write a comment starting with “To Do”, “todo”, “to-do”, or “TODO”, the editor will automatically pick that up and show it in the TODO comment box. Double clicking on the comment will jump to the relevant position in the code, which we can use for need – a concise reminder of the issue at hand, and an anchor to the relevant position. From tasks tab we can manage ongoing project tasks.

4-Dynamically Call an Action - Another new feature is ability to dynamically call an action, without inserting it to the test using LoadAndRunAction.

5- Save Test with Resources- All test resources can be save on one go from QC
6-Attaching Images to Report- One more new feature to the reporter is the ability to attach images to report. In QTP 10, we have to just need to add the picture file path to the report command.

7-Export Result- in QTP 10 we can export test results in more formats like HTML, PDF and Doc
COM objects for the Bitmap checkpoints has been introduced
Version control with the help of QC 10.0

8-Jump to Step- QTP 10 results is now having the step sync – right click any node in the test-step tree, and select “Jump to step in QuickTest”. QTP will focus on the relevant script line within the relevant action.


New features/enhancements in QTP 11-
  
1-QTP 10 version was able to identify object through normal object identification method only where QTP11 is able to identify the object in following different ways:
Normal object identification (Like QTP10) 
Using XPath
Using CSS

2-In QTP 11, results viewer have been improved to pie charts, statics for both current and previous test runs, summary page.

3-Support for recording using Firefox is now available which will be really helpful.

4-Normal object identification method has been updated with “Visual Relation Identifier” in addition to “ordinal identifier” features in which object identification which will depend on relation to neighboring objects and will be helpful to overcome weakness of ordinal identification feature only in QTP10.

5-“LoadFunctionLibrary” statement in QTP 11 will be helpful to load function library at any step of runs instead of starting of run.

6-Automatically parameterize steps feature will be available in QTP 11.

7- Extend WPF and New Silverlight Add-in is supported to test objects in Silverlight 2 and Silverlight 3 applications.

8- Regular Expression Evaluator is available to test regular expressions that you have created.
9-Now you can test GUI and UI-Less application functionality in one test with QTP 11.

10-Avoid downtime due to license server failures.

11-Web 2.0 toolkit applications support.

12- Object Spy has been improved, you can directly add the object to Object Repository from the Object spy window as well. You can also use the clip board button to retrieve all the property value.


Object Repository in QTP


Overview

Whenever you record a test, QTP adds each and every objects to the Object repository on which you perform an operation.It is very important to understand that if you want to do a operation on certain objects, those need to be in object repository (Else one need to write Programmatic description).One can also add
test objects to the local object repository while editing your test.

There are two types of object repositories— Local object repository and a Shared object repository

A local object repository stores objects in a file that is associated with one specific action, so that only that action can access the stored objects.

A shared object repository stores objects in a file that can be accessed by multiple tests (in read-only mode). You can use the same shared object repository for multiple actions. You can also use multiple object repositories for each action. 

Tests always use the object repositories that are specified in the Associated Repositories tab of the Action Properties dialog box or in the Associate Repositories dialog box. Shared object repositories are read-only when accessed from tests; you edit them using the Object Repository Manager.

One should use Local Object Repository in following cases-

1-You are creating single-action tests.
2-You have very few tests to automate.
3-You do not expect to frequently modify object properties.
4-You are new to using QuickTest and simply wants objects to be added automatically in a local object repository by recording.


One should use Shared Object Repository in following cases-

1-You are creating tests by not using recording.
2-If you are using modular approach.
3-You often work with multi-action tests and regularly use the Insert Copy of Action and Insert Call to Action options.
4-You expect the object properties in your application to change from time to time and/or you regularly need to update or modify object properties.
5-If you are proficient, it is probably most efficient to save objects in a shared object repository. In this way, you can use the same shared object repository for multiple action, if the actions include the same objects.
6-Where same objects are being required in multiple tests, creating a shared object repository will help in maintenance of objects. When the objects in your application change, you can update them in one location for all the actions that are using this shared object repository.


How QuickTest determines the object to use when an object with the same name exists in multiple object repositories

➤ If an object with the same name is located in both the local object repository and in a shared object repository associated with the same
action, the action uses the local object definition.
➤ If more than one shared object repository associated with the same action, the object definition is used from the first occurrence of the
object, according to the order in which the shared object repositories are associated with the action. 

Exporting Local Objects-

Go to Resources->Object repository
File->Export Local Objects




Associating an Object Repository to your test

Go to Resources->Object repository
Click on Associate Repository button and then click on "+" sign to add repository
Select the repository and click on Open






After adding select the action from Available and add it to Associated Actions and click OK









Thursday, 9 May 2013

Automating QTP

QuickTest Automation Object Model
The way QTP is used to automate different applications, we can even automate QTP itself. For automating QTP, first of all one need to create a object of QuickTest Application and then by using this object, one can easily do all the configuration and run settings that is provided with the QTP interface.

QuickTest Automation Object Model consists of  objects, methods and properties. In QuickTest AOM, there is a automation object for most of the dialog boxes in QuickTest. Similarly by using corresponding object properties, most options in dialog boxes can be set or retrieved. Also most menu commands and other operations have corresponding automation methods.

Example-

'This example open a test, do the configuration and run setting, run the test

Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Dim qtTest 'As QuickTest.Test ' Declare a Test object variable
Dim qtResultsOpt 'As QuickTest.RunResultsOptions ' Declare a Run Results Options object variable


'Create the Application object
Set qtApp = CreateObject("QuickTest.Application")
qtApp.Launch ' Start QuickTest
qtApp.Visible = True ' Make the QuickTest application visible



'Set QuickTest run options
qtApp.Options.Run.ImageCaptureForTestResults = "OnError"
qtApp.Options.Run.RunMode = "Fast"
qtApp.Options.Run.ViewResults = False



'Open the test in read-only mode
qtApp.Open "C:\Tests\Test1", True 



'Set run settings for the test
Set qtTest = qtApp.Test
qtTest.Settings.Run.IterationMode = "rngIterations" ' Run only iterations 2 to 4
qtTest.Settings.Run.StartIteration = 2
qtTest.Settings.Run.EndIteration = 4
qtTest.Settings.Run.OnError = "NextStep" ' Instruct QuickTest to perform next step when error occurs



'Adding Libraries-

qtApp.Test.Settings.Resources.Libraries.RemoveAll
qtApp.Test.Settings.Resources.Libraries.Add objectFunctionFilePath
qtApp.Test.Settings.Resources.Libraries.Add globalFunctionFilePath


'Adding Environment Variable
qtApp.Test.Environment.Value("User_ID") = userid


'Adding Recovery Scenarios
'create a recovery object
Set qtTestRecovery = qtApp.Test.Settings.Recovery ' Return the Recovery object

If qtTestRecovery.Count > 0 Then ' If there are any default scenarios specified for the test
    qtTestRecovery.RemoveAll ' Remove them
End If

'Add recovery scenarios
qtTestRecovery.Add recoveryPath, "objectNotFound", 1 ' Add the "objectNotFound" scenario

'Enable all scenarios
For intIndex = 1 To qtTestRecovery.Count ' Iterate the scenarios
    qtTestRecovery.Item(intIndex).Enabled = True ' Enable each Recovery Scenario
Next

'Enable the recovery mechanism (with default, on errors, setting)
qtTestRecovery.Enabled = True

'Ensure that the recovery mechanism is set to be activated only after errors
qtTestRecovery.SetActivationMode "OnError"


'Create the Run Results Options object
Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions")
qtResultsOpt.ResultsLocation = "C:\Tests\Test1\Res1" ' Set the results location


' Run the test
qtTest.Run qtResultsOpt

ResultStatus=qtTest.LastRunResults.Status 'Check the results of the test run"


'Save the test and close QuickTest

qtApp.Test.Save ' Save the test
qtTest.Close ' Close the test
qtApp.Quit ' Quit QuickTest


'Release the objects
Set qtResultsOpt = Nothing
Set qtTest = Nothing
Set qtApp = Nothing