Quick test professional

QTP Tips QTP codes QTP Faqs and more

How to create tables in Microsoft word

How to create tables in Microsoft word 
Set objWord = CreateObject("Word.Application")
const END_OF_STORY=6
objWord.Visible = True
 
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
 
objSelection.TypeText "Table 1"
objSelection.TypeParagraph()
 
Set objRange = objSelection.Range
objDoc.Tables.Add objRange, 1, 2
Set objTable = objDoc.Tables(1)
 
objTable.Cell(1, 1).Range.Text = "This is cell 1."
objTable.Cell(1, 2).Range.Text = "This is cell 2."
objSelection.EndKey END_OF_STORY
objSelection.TypeParagraph()
 
objSelection.TypeText "Table 2"
objSelection.TypeParagraph()
 
Set objRange = objSelection.Range
objDoc.Tables.Add objRange, 1, 2
Set objTable = objDoc.Tables(2)
 
objTable.Cell(1, 1).Range.Text = "This is cell 1."
objTable.Cell(1, 2).Range.Text = "This is cell 2."
 
objSelection.EndKey END_OF_STORY
objSelection.TypeParagraph()
Author: Mohan Kakarla

February 14, 2008 Posted by | Automating MS Word | , , , , , | 4 Comments

How to register COM with QTP?

How to register COM with QTP? 

Steps to create Intellisense in QTP:

1. Create a wsc(windows scripting component) file in the below given format:

<?xml version=”1.0″?>
<component>

<?component error=”true” debug=”true”?>
<reference object=”Scripting.Dictionary” />
<registration description=”Functions” progid=”QTP.Functions” version=”1.00″ classid=”{d7c40957-00d4-41a5-a87b-89d1db311423}”>
</registration>

<public>

<method name=”Function1″ internalName=”Functiona1″ dispid=”0″>
<PARAMETER name=”strFileName”/>
</method>
<method name=”Function2″>
</method>
<method name=”Function3″ >
</method>
</public>

</component>
2. After the file is created, register the same using regsvr32.
3. Now create the following registry entries in the path HKCU\Software\Mercury Ineteractive\QuickTest Professional\MicTest\Reserved Objects\Functions –

ProgID REG_SZ QTP.Functions
UIName REG_SZ Functions

4. Restart QTP.

  Source: Mercury Forum’s KB articles

February 14, 2008 Posted by | COM and QTP | , , , , , , , , | 3 Comments

Get Each Radio in RadioGroup And Check

Get Each Radio in RadioGroup

And Check

Set opt=Description.Create
opt(“html tag”).value=”INPUT”
opt(“type”).value = “radio”
Dim allOptions,all
Set allOptions=Browser(“a”).Page(“b”).Frame(“c”).ChildObjects(opt)
all=allOptions.count
MsgBox all

for i= 0 to all
eName=allOptions(i).getROProperty(“name”)
noofradio=allOptions(i).getElementsByName(eName).length
for j= 0 to noofradio-1
radioname=allOptions(i).object.document.getElementsByName(eName).item(j).GetAdjucentText(“afterend”)allOptions(i).object.document.getElementsByName(eName).item(j).checked=true
msgbox radioname
next
next

  Source: Mercury Forum’s KB articles

February 14, 2008 Posted by | Descriptive Programming and Child Objetcs | , , , , , , , , | 8 Comments

VBScript to read XML

Dim description, filepath

VBScript to read XML  

 

Set xmlDoc = CreateObject(“Msxml2.DOMDocument”)
xmlDoc.load(“c:\test.xml”)

Set ElemList = xmlDoc.getElementsByTagName(“segment”)
filepath = ElemList.item(0).getAttribute(“filePath”)
MsgBox filepath

Set ElemList = xmlDoc.getElementsByTagName(“description”)
plot = ElemList.item(0).Text
MsgBox plot

  Source: Mercury Forum’s KB articles

February 14, 2008 Posted by | XML Scripting | 9 Comments

How to Close QTP after execution

How to Close QTP after execution 

Private Function CloseQTP        

    Set objWMIService = GetObject(“winmgmts:\\.\root\CIMV2”)     

       Set colProcess = objWMIService.ExecQuery (“Select * from Win32_Process Where Name = ‘QTPro.exe'”)     

       For Each objProcess in colProcess                      

  objProcess.Terminate()           

 Next          

  Set objWMIService = Nothing         

   Set colProcess = NothingEnd FunctionCall CloseQTP

  Source: Mercury Forum’s KB articles

 

February 14, 2008 Posted by | Automation Object Model For QTP | , , , , , | 4 Comments

How To close MsgBox Runtime

 

How To close MsgBox Runtime 

Write the below line as the first-line in your script. Set sh = CreateObject(“Scripting.Shell”) …This will create a shell object at run-time and will be available until the test ends.

If you are getting problem like ,Activex Component can’t create object Then use  Set sh =CreateObject(“WScript.Shell”)

 Now… where ever you are having “msgbox” replace it with..

sh.Popup “message content”, 5, “msg header”, (0+4)

 the above line will show the message content for 5 seconds(and vanishes after that).

The alert-box’s header will have “header info”. Last parameter(0+4) is actually two things. 0 -> show OK button in the alertBox 48 -> “!” icon… if you use 64 u will see X icon instead BTW… since u need the message to be displayed

 

 

February 14, 2008 Posted by | QTP Tips and Faqs | , , , , , , , , | 13 Comments

How to do the backward compatability in QTP

 How to run the scripts in 8.2

those are recorded in 9.0 or higher

Sol:

Step 1: Delete the object repository of 9.0

Step 2: open a Blank test in 8.2

Step 3: Create the shared object repository in 8.2 that should contain all the objects in 9.0 and save.

Step 4: create the action structure in 8.2 should contain the same num of actions, same names and structure as the script of 9.0.

Step 5: save the test. (From now we call this as 8.2 scripts)

Step 6: from 8.2 script copy Test.tsp file to the 9.0 script.

Step 7: copy all Resource.MTR file found in Action0, Action 1, etc to 9.0 scripts

Step 8: now u can run the scripts with little modifications if require

Author: Mohan Kakarla

February 14, 2008 Posted by | Backward compatability in QTP | , , , , , , , | 1 Comment

GET NAMES OF ALL OPEN BROWSERS

Set bDesc = Description.Create()

bDesc(“application version”).Value = “internet explorer 6”

Set bColl = DeskTop.ChildObjects(bDesc)

Cnt = bColl.Count

MsgBox “There are total: “&Cnt&”browsers opened”

 For i = 0 To (Cnt -1)

MsgBox “Browser : “&i&” has title: “& bColl(i).GetROProperty(“title”)

Next ‘ i

 Set bColl = Nothing

Set bDesc = Nothing

Author: Mohan Kakarla

February 14, 2008 Posted by | Browser Scripts | , , , , , , , , | 3 Comments

How Get Root Element attribute’s value from XML file

How Get Root Element attribute’s value from XML file

Function GetRootElementAttributeValueFromXML(sFileNameWithPath,sAttribute)
    ‘ Why we need to ADD 2 because each attribute followed by (=) and (“)
            iLenOfValue=len(sAttribute) + 2
            Set doc = XMLUtil.CreateXML()
            doc.LoadFile sFileNameWithPath
            Set root = doc.GetRootElement()
            If instr(1,root,sAttribute)  <= 0 then
                        Reporter.ReportEvent micFail,sAttribute,”Not Found in XML file.”
                        exitrun(0)
            else      
                        sStartPos=instr(1,root,sAttribute) + iLenOfValue
                        sEndPos=instr(sStartPos,root,””””)
                        GetRootElementAttributeValueFromXML=mid(root,sStartPos,sEndPos – sStartPos)
            end if
End Function
msgbox(GetRootElementAttributeValueFromXML(“c:\temp\request.xml”,”MerchantId”))

February 14, 2008 Posted by | XML Scripting | 3 Comments

What’s New in Quick Test Pro 9.0,9.1

What’s New in Quick Test Pro 9.0

Object Repository Manager

You can use the Object Repository Manager to manage all of the shared object repositories in your organization from one, central location. This includes adding and defining objects, modifying objects and their descriptions, parameterizing test object property values, maintaining and organizing repositories, and importing and exporting repositories in XML format. You can open multiple object repositories at the same time. Each object repository opens in its own resizable document window. This enables you to compare the content of the repositories, to copy or move objects from one object repository to another, and so forth

Object Repository Merge Tool

You can use the Object Repository Merge Tool to merge the objects from two shared object repositories into a single shared object repository. You can also use the Object Repository Merge Tool to merge objects from the local object repository of one or more actions or components into a shared object repository. When you merge objects from two source object repositories, the content is copied to a new, target object repository, ensuring that the information in the source repositories remains unchanged. If any conflicts occur during the merge, for example, if two objects have the same name and test object class, but different test object descriptions, the relevant objects are highlighted in the source repositories, and the Resolution Options pane details the conflict and possible resolutions.

Multiple Object Repositories per Action or Component

QuickTest provides several options for storing and accessing test objects. You can store the test objects for each action or component in its corresponding local object repository, which is unique for each action and component. You can also store test objects in one or more shared object repositories that can be used in multiple actions and components. Alternatively, you can use a combination of objects from the local object repository and one or more shared object repositories. You choose the combination that matches your testing needs.

XML Object Repository Format

QuickTest now enables you to import and export object repositories from and to XML format. This enables you to modify object repositories using the XML editor of your choice and then import them back into QuickTest. You can import and export files either from and to the file system or a Quality Center project (if QuickTest is connected to Quality Center).

Function Library Editor

QuickTest now has a built-in function library editor, which enables you to create and edit function libraries containing VBScript functions, subroutines, modules, and so forth, and then call their functions from your test or component. You can create, open, and work on multiple function libraries simultaneously. Each function library opens in its own document window. When working with a function library, another testing document, such as a test, application area, or component, is always open, enabling you to add calls to your functions as you create or modify them. By creating and working with function libraries directly in QuickTest, you can take advantage of QuickTest’s Expert View-like editing features, syntax checker, debug features, and so forth. For example, you can step directly into the function code in a function library while debugging a test or component. You can also use the Function Definition Generator to generate definitions for new user-defined functions, add header information to them, and register these functions to a test object, if needed. You can then complete the function by adding its content (code). You can associate a function library directly with a test or application area, to make its functions available to all of a test’s actions, or to all of an application area’s associated components. By implementing user-defined functions in function libraries and associating them with your test, you and other users can choose functions that perform complex operations, such as adding if/then statements and loops to test steps, or working with utility objects—without adding the code directly to the test. In addition, you save time and resources by implementing and using reusable functions.

Handling Missing Actions and Resources

Whenever a testing document (test, component, or application area) contains a resource that cannot be found, QuickTest opens the Missing Resources pane and lists the missing resource(s). For example, a test may contain an action or a call to an action that cannot be found; a testing document may use a shared object repository that cannot be found; or a testing document may use an object repository parameter that does not have a default value. In all of these cases, QuickTest indicates this in the Missing Resources pane, enabling you to map a missing resource to an existing one, or remove it from the testing document, as required.

New Look and Functionality for Application Areas

An application area serves as a single entity in which you store all of the resources and settings required for a component. It also provides a single point of maintenance for all elements associated with the testing of a specific part of an application. With this release, application areas have a new look and enhanced functionality. The application area document now contains a sidebar that lets you navigate directly to the resources or settings you want to modify. Application areas now include a list of keywords that you can make available to associated components. To help you decide which keywords to make available for use in a particular application area, QuickTest enables you to sort and filter the keyword list, and displays the properties for any keyword you highlight. The resources and settings you define for an application area are now linked to all associated components, ensuring that any changes you make in the resource files are immediately applied to these components. For example, if you modify the properties of an object in an associated object repository, the changes immediately affect any associated components using that test object.

New Supported Operating System Versions

QuickTest now supports the following operating system:

  • Windows 2000—Service Pack 4
  • Update Rollup 1 for Windows 2000 Service Pack 4
  • Windows XP 32-Bit Edition—Service Pack 2
  • Windows XP 64-Bit Edition—Service Pack 1
  • Windows Server 2003 32-Bit Edition—Service Pack 1
  • Windows Server 2003 R2 (32-Bit x86)

New Supported Browsers and Browser Versions

In addition to support for recording tests and components on Microsoft Internet Explorer, QuickTest now supports running tests and components on the following new Web browser versions:

  • Microsoft Internet Explorer 7.0
  • Netscape Browser 8
  • Mozilla Firefox 1.5

New Look and Feel for the QuickTest Window

The QuickTest window now contains movable and dockable tabbed panes that you can position anywhere on your screen, as required. When customizing the QuickTest window, you can move and resize panes, select to show or auto-hide panes, create tabbed panes, select which toolbars to display, and so forth. For example, you can move the Data Table to be a floating pane at the top right of the window, or you can display the Active Screen, Data Table and Missing Resources pane all as tabbed panes at the bottom left of the window. You can also apply any of the available Windows themes to the QuickTest window to change the look and feel of the main QuickTest window to suit your needs.

Improved Menus and Toolbars

The QuickTest menus and toolbars contain more intuitive categories and new commands to help you better manage your QuickTest sessions. For example, the Automation menu contains all of the commands that are related to recording and running your tests and components, as well as viewing the run results. The Resources menu contains all of the commands that are relevant for managing your object repositories, and for viewing associated function libraries. The File menu enables you to set document-specific settings, manage your testing documents, connect to your Quality Center project, associate function libraries with your testing document, and so forth.

New and Enhanced Expert View and Function Library Editor Options

You can use the following new options and enhancements when working in the Expert View or Function Library editor:

Syntax Errors

You can check for syntax errors at any time by using the new Check Syntax command. If syntax errors are identified, they are displayed in the Information Pane in the bottom left corner of your screen (configurable). You can jump directly to the statement line for each error so that you can correct it. As in the previous release, when you select to switch to the Keyword View from the Expert View, QuickTest checks whether there are syntax errors in your statements. QuickTest displays the Keyword View only after all syntax errors have been corrected.

Comment/Uncomment

You can now comment and uncomment individual statements or entire sections in your action using the new Comment Block and Uncomment Block commands. This enables you to comment out sections while debugging your actions, for example, as well as providing an additional way to implement comments.

Indent/Outdent

You can now indent and individual statements or blocks of statements using the new Indent and Outdent commands. This helps make your test actions more readable and easier to maintain.

Action Parameter Enhancement

In addition to specifying test or action parameters to pass values to and from your test, and between actions in your test, you can now use action parameters to pass values between sibling actions (actions at the same hierarchical level).

Debugging Enhancements

You can use the following new options and enhancements when debugging your tests, components, and function libraries:

New Step Commands

In addition to the Step Into, Step Over, and Step Out options, you can now instruct QuickTest to start a debug session from a particular step using the Start from Step command, or to run the debug session from the current step until it reaches a particular step using the Run to Step commands.

Run Current Action

You can also use the Run Current Action option to run a single action in your test.

Enhanced Breakpoint Support

You can now insert and remove breakpoints in the Keyword View by clicking in the margin to the left of a statement in your testing document. You can also enable and disable breakpoints as you debug different parts of your action, component, or function library. This enables you to temporarily ignore breakpoints without removing them as you debug the various parts of your test, component, or function library.

Added Control of the Object Repository from Run Session and QuickTest Automation Scripts

QuickTest provides a new Repository reserved object that enables you to set or retrieve the value of object repository parameters for the current run session. The QuickTest Professional automation object model provides a new ObjectRepositories collection object that enables you to control the object repositories associated with actions. For example, when you create a new object repository for a new product module, you can use an automation script to associate the new object repository with the actions of all relevant tests.

Checkpoint and Output Value Renaming Capabilities

When you create a checkpoint or output value, by default, its name is the name of the test object on which the checkpoint or output value step is performed. QuickTest now enables you to rename checkpoints and output values in your test. This can make it easier, for example, to see the purpose of the checkpoint or output value step without opening the checkpoint or output value dialog box.

Test Results Enhancements

You can now export run results to an HTML file to save them in HTML format. This is useful, for example, if you want to send the HTML file containing the run session results in an e-mail to a third-party who does not have QuickTest installed. You can choose to export the entire report to an HTML file, or just a part of it. You can also modify the theme of the Test Results window, just like you can for the main QuickTest window. What’s New in Quick Test Pro 9.1

Navigate and Learn

The new Navigate and Learn feature is accessible from the Object Repository Manager. Each time you select a window to learn using this feature, the selected window and its descendant objects are added to the active shared object repository according to the settings in the object filter.

Object Repository Comparison Tool

The new Object Repository Comparison Tool is accessible from the Object Repository Manager. You can use this tool to identify the differences between objects in two specified shared object repository files. It also enables you to track changes in different versions of the same shared object repository file. After the compare process, the Comparison Tool provides a graphic representation of the objects in the object repositories, indicating objects that have differences, as well as objects that are unique to one repository. You can also view the properties and values of each object in the repositories. During the comparison process, the original object repository files remain unchanged

Object Repository Automation

You can use the objects and methods of the QuickTest Object Repository automation object model to write scripts that automatically manipulate object repositories, instead of performing these operations manually using the Object Repository Manager. For example, you can add, remove, and rename test objects, import from and export to XML, and retrieve and copy test objects. The QuickTest Professional Object Repository Automation Reference is a Help file that provides detailed descriptions, syntax information, and examples for the objects and methods in the QuickTest object repository automation object model. You can write your automation scripts in any language and development environment that supports automation.

New Environment Support

QuickTest Professional 9.1 supports the following new infrastructure software, operating system, and Web browser versions:

  • QuickTest now runs under Microsoft .NET Framework 2.0. If it is not currently installed on the computer on which you are installing QuickTest, Setup prompts you to install it before continuing the installation. On-screen instructions are provided.
  • QuickTest now provides Beta-level support for Microsoft Windows Vista Beta 2—build 5384.
  • QuickTest now provides Beta-level support for Microsoft Internet Explorer 7.0 Beta 3. For more information about working with the Web add-in, see Testing Web Objects.
  • QuickTest now provides Alpha-level support for Bon Echo version 2.0a3 (Mozilla Firefox 2.0 Alpha).

Newly Integrated Tools

The QuickTest Script Editor and Business Component Upgrade Tool are now installed automatically when you install QuickTest Professional 9.1.   

February 14, 2008 Posted by | What’s New in Quick Test Pro 9.0 | , , , , , , , , , | 7 Comments