Quick test professional

QTP Tips QTP codes QTP Faqs and more

Compare 2 XML files

This Example was written for comparing two XML files assuming the contents of the both XML has the following elements:
<Books>
<Title>QTP</Title>
<Author>Mohan</Author>
<Title>VBS</Title>
<Author>Kumar</Author>
</Books>

Dim description, filepath
Set xmlDoc1 = CreateObject(“Msxml2.DOMDocument”)
xmlDoc1.load(“C:Documents and Settingsmohan.kakarlaDesktop1.xml”)’file 1
Set xmlDoc2 = CreateObject(“Msxml2.DOMDocument”)
xmlDoc2.load(“C:Documents and Settingsmohan.kakarlaDesktop2.xml”)’file 2
Set ElemList1= xmlDoc1.DocumentElement.ChildNodes
Set ElemList2= xmlDoc2.DocumentElement.ChildNodes
If ElemList1.length=ElemList2.length Then’ check weather both xml file has same number of childnodes
  msgbox “Both XML files have same number of Child nodes”

   For i = 0 to ElemList1.length-1

       If ElemList1.item(i).Text=ElemList2.item(i).Text Then
          msgbox “child element:”&i &” is same in both XML files”
      Else
         msgbox “child element:”& i &” is not same in both XML files, In XML file 1, The valueis:”&ElemList1.item(i).Text &” and In XML file 1, The value

is:”&ElemList2.item(i).Text
     End If
  Next
End If

Author: Mohan Kumar Kakarla

March 3, 2008 Posted by | XML Scripting | , , , , , , , , , , | 111 Comments

Compare 2 Excel sheets cell by cell

This code will open two excel sheet and compare each sheet cell by cell, if any changes there in cells , it will highlight the cells in red color  in the first sheet.
Set objExcel = CreateObject(“Excel.Application”)
objExcel.Visible = True
Set objWorkbook1= objExcel.Workbooks.Open(“C:Documents andSettingsmohan.kakarlaDesktopDocs1.xls”)
Set objWorkbook2= objExcel.Workbooks.Open(“C:Documents and

Settingsmohan.kakarlaDesktopDocs2.xls”)

Set objWorksheet1= objWorkbook1.Worksheets(1)

Set objWorksheet2= objWorkbook2.Worksheets(1)

   For Each cell In objWorksheet1.UsedRange
       If cell.Value <> objWorksheet2.Range(cell.Address).Value Then
           cell.Interior.ColorIndex = 3’Highlights in red color if any changes in cells
       Else
           cell.Interior.ColorIndex = 0
       End If
   Next

set objExcel=nothing
 Author: Mohan Kumar Kakarla

February 27, 2008 Posted by | Excel Automation | , , , , , , , , , | 87 Comments

Excel Sorting(Ascending , Descending) By Rows and Columns

Excel Sorting By Row:

Const xlAscending = 1
Const xlNo = 2
Const xlSortRows = 2

Set objExcel = CreateObject(“Excel.Application”)
objExcel.Visible = True

Set objWorkbook = objExcel.Workbooks.Open(“C:Documents and Settingsmohan.kakarlaDesktopDocs1.xls”)
Set objWorksheet = objWorkbook.Worksheets(1)
objWorksheet.Cells(1,1).activate

Set objRange = objExcel.ActiveCell.EntireRow
objRange.Sort objRange, xlAscending, , , , , , xlNo, , , xlSortRows
set objExcel=nothing

Excel Sorting By Colum :

Const xlAscending = 1’represents the sorting type 1 for Ascending 2 for Desc
Const xlYes = 1

Set objExcel = CreateObject(“Excel.Application”)’Create the excel object
objExcel.Visible = True’Make excel visible
Set objWorkbook = _
objExcel.Workbooks.Open(“C:\Documents and Settings\mohan.kakarla\Desktop\Docs1.xls”)’Open the

document

Set objWorksheet = objWorkbook.Worksheets(1)’select the sheet based on the index .. 1,2 ,3 …
Set objRange = objWorksheet.UsedRange’which select the range of the cells has some data other than blank
Set objRange2 = objExcel.Range(“A1”)’ select the column to sort

objRange.Sort objRange2, xlAscending, , , , , , xlYes
set objExcel=nothing

Reference: MSDN

February 26, 2008 Posted by | Excel Automation | , , , , , , , , , , , , | 18 Comments

Whats New In QTP 9.5

  • Maintenance Run Mode :

  • Repair your test on the fly, this will assists you to  adding the steps or uodating the object proprties in OR on the fly.i.e. if your object properties are changed after a new build, you just run the Maintenance Run Mode and update your OR according to that on the fly.

  • Process Guidance :

  • This is little more than more accessible help files. Maybe this is good for when you are first learning to record a test, but it doesn’t seem to add much utility.

  • Flow Pane
  • Available Keywords Pane

  • All Test Objects and functions in one handy location.Rapid test development with drag & drop.Object repository now also supports drag & drop

    1.jpg

  • Resources Pane :

  • All resources associated with the test. You can see all your library file in this pane

    11.jpg

  • Missing Resources Pane
  • Relative Path Helper
  • Improved Bitmap Checkpoint
  • Web Extensibility :
  • 1.Anyone can add support for new web controls

    2.Rapid development in JavaScript

    3.Solid infrastructure supplied by the Web add-in

    4.Extensibility objects are first class citizens

     5.Built-in toolkit: ASPAjax

  • Tabbed browsing :
  • Tabs identified as separate browsers.Same test compatible with tabbed and non tabbed browsers.

  • New Technologies :
  • 1.PowerBuilder

    2. Oracle − Forms 10 −Apps 12

    3.StingRay Objective Grid 10, 114. PeopleSoft 9.0•

    4.New Terminal Emulator versions

    5.NET 3.5 (beta)

  • New environments  :
  • 1.Windows Vista 64 bit

    2. Eclipse 3.2, 3.3

    3.Record on SWT

    4. Firefox 3.0

    5.Netscape 9

    Reference: HP website

    You can download QTP 9.5 on HP website  https://h10078.www1.hp.com/cda/hpms/display/main/hpms_content.jsp?zn=bto&cp=1-11-127-24^1352_4000_100__

    February 21, 2008 Posted by | New Features In QTP9.5, Whats New in QTP 9.5 | , , , , , , | 49 Comments

    Get all files within a time range or specified time

    Dim From

    From = TimeSerial( 11, 0, 0 ) ‘ to emphasize 24 hour clock! 11 AM

    Dim Till

    Till = TimeSerial( 13, 0, 0 )

     Dim oFS

    Set oFS = CreateObject( “Scripting.FileSystemObject” )

    Dim oFile, tFile, Range

    For Each oFile In oFS.getFolder( “.\” ).Files

    tmFile = TimeValue( oFile.DateCreated )

    bInRange = tFile >= From And tFile <= Till

    msgbox oFile.DateCreated &”–“& oFile.Name
       Next

    February 15, 2008 Posted by | Files and Folders | , , , , , , , , , , | 4 Comments

    Dictonary Object

     Dictionary Object 

    Dictionary Object  stores data key, item pairs. A Dictionary object stores the items 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.

     

     Adavntages of using it in QTP:

    1. can be used as Global variable declaration. so that any test can access the values from it in the run time.

    2. You can store and retrive any number of run time values in to dictonary.

    3. It is one of the Parameterization techique we can use in QTP

     

     Disadvantages:

    we can not specify the values in the desingn time like Datatable , Action parameters, environment variable.

    So it is useful only in Run time , not design time

    Methods:

    Add Method

    Adds a key and item pair to a Dictionary

    object. object.Add (key, item)

    Arguments 

    object Required. Always the name of a Dictionary object.

    key Required. The key associated with the item being added.item Required.

    The item associated with the key being added. 

    Remarks

    An error occurs if the key already exists.

    The following example illustrates the use of the Add method.

    Dim d   ‘ Create a variable. 

    Set d = CreateObject(“Scripting.Dictionary”) 

     d.Add “a”, “Athens”   ‘ Add some keys and items.  

    d.Add “b”, “Belgrade”

     

     Items Method

     Returns an array containing all the items in a Dictionary object. 

    object.Items( )

     Remarks The object is always the name of a Dictionary object.The following code illustrates use of the Items method:

    Set d = CreateObject(“Scripting.Dictionary”)   
     d.Add “a”, “Athens”   ‘ Add some keys and items.  
      d.Add “b”, “Belgrade”    
       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
    Msgbox s  

         Exists Method

     Returns true if a specified key exists in the Dictionary object, false if it does not.

    object.Exists(key)

     Arguments

    object Required. Always the name of a Dictionary object.

    key Required. Key value being searched for in the Dictionary object.

     Remarks

    The following example illustrates the use of the Exists method.

    Set d = CreateObject(“Scripting.Dictionary”)  
      d.Add “a”, “Athens”   ‘ Add some   keys and items.   
     d.Add “b”, “Belgrade”   
       If d.Exists(“c”) Then   
        Msgbox  “Specified key exists.”   
     Else      
     Msgbox  “Specified key doesn’t exist.” 
       End If

      Keys Method

    Returns an array containing all existing keys in a Dictionary object.

     object.Keys( )

    Remarks

    The object is always the name of a Dictionary object.

    The following code illustrates use of the Keys method:   

    Dim a, d, i   ‘ Create some variables.   
     Set d = CreateObject(“Scripting.Dictionary”)   
     d.Add “a”, “Athens”   ‘ Add some keys and items.  
      d.Add “b”, “Belgrade”   
      a = d.Keys   ‘ Get the keys. 
       For i = 0 To d.Count -1 ‘ Iterate the array.    
       s = s & a(i) & “<BR>” ‘ Return results.   
      Next
    Msgbox s

     Remove Method  

    Removes a key, item pair from a Dictionary object. 

    object.Remove(key) 

    Arguments

     object Required. Always the name of a Dictionary object.

    key Required. Key associated with the key, item pair you want to remove from the Dictionary object.

    Remarks

    An error occurs if the specified key, item pair does not exist.

    The following code illustrates use of the Remove method:

    Dim a, d   ‘ Create some variables. 
    Set d = CreateObject(“Scripting.Dictionary”) 
    d.Add “a”, “Athens”   ‘ Add some keys and items. 
    d.Add “b”, “Belgrade”
     d.Add “c”, “Cairo”  
    d.Remove(“b”)   ‘ Remove second pair.

    RemoveAll Method

     The RemoveAll method removes all key, item pairs from a Dictionary object.

     object.RemoveAll( ) 

    Dim a, d, i    Create some variables.
     Set d = CreateObject(“Scripting.Dictionary”) 
    d.Add “a”, “Athens”   ‘ Add some keys and items.
     d.Add “b”, “Belgrade” 
    d.Add “c”, “Cairo”  
    a = d.RemoveAll   ‘ Clear the dictionary.

    Author: Mohan Kakarla

    Reference:MSDN

    February 15, 2008 Posted by | Dictonary Object | , , , , , , , , , | 1 Comment

    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

    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

    QTP Additional Faqs

    QTP Additional Faqs

    1) How to Stop  the execution of the test.

        Syntax

       Services.Abort 2)How to add folders

    Sub AddNewFolder(path, folderName)     Dim fso, f, fc, nf   
      Set fso = CreateObject("Scripting.FileSystemObject")    
     Set f = fso.GetFolder(path)
    
         Set fc = f.SubFolders    
     If folderName <> "" Then
    
            Set nf = 
    fc.Add(folderName)
    
        Else        
    Set nf = fc.Add("New Folder")
    
     
        End If End Sub
    
    

    An error occurs if the folderName already exists.

    3 )How to get the ASCII valuse for a character

    Remarks

    In the following example, Asc returns the ANSI character code of the first letter of each string:

    Dim MyNumber  MyNumber = Asc("A")    
    
       ' Returns 65.
    
     MyNumber = Asc("a")
    
           ' Returns 97.
    
     MyNumber = Asc("Apple")   ' Returns 65.

    Note   The AscB function is used with byte data contained in a string. Instead of returning the character code for the first character, AscB returns the first byte. AscW is provided for 32-bit platforms that use Unicode characters. It returns the Unicode (wide) character code, thereby avoiding the conversion from Unicode to ANSI.

    4) How to get Character fron ASCII value

    Remarks

    Numbers from 0 to 31 are the same as standard, nonprintable ASCII codes. For example, Chr(10) returns a linefeed character.

    The following example uses the Chr function to return the character associated with the specified character code:

    Dim MyChar
     MyChar = Chr(65)   ' Returns A.
     MyChar = Chr(97)   ' Returns a.
    MyChar = Chr(62)   ' Returns >.  MyChar = Chr(37)   ' Returns %.

    Note   The ChrB function is used with byte data contained in a string. Instead of returning a character, which may be one or two bytes, ChrB always returns a single byte. ChrW is provided for 32-bit platforms that use Unicode characters. Its argument is a Unicode (wide) character code, thereby avoiding the conversion from ANSI to Unicode.

    5)Accessing User-Defined Properties of Web Objects

    You can use the attribute/<property name> notation to access native properties of Web objects and use these properties to identify such objects with programmatic descriptions. For example, suppose a Web page has the same company logo image in two places on the page: <IMG src=”logo.gif” mce_src=”logo.gif” LogoID=”122″> <IMG src=”logo.gif” mce_src=”logo.gif” LogoID=”123″> You could identify the image that you want to click using a programmatic description by including the user-defined property LogoID in the description as follows: Browser(“Mercury Tours”).Page(“Find Flights”).Image(“src:=logo.gif”,”attribute/LogoID:=123″).Click 68, 12 Note: The attribute/<property name> notation is not supported in Netscape 4.x.

    6)How to Run Your Automation Program

    There are several applications available for running automation programs. You can also run automation programs from command line using Microsoft’s Windows Script Host. For example, you could use the following command line to run your automation program: WScript.exe /E:VBSCRIPT myScript.vbs 7) What is the other way of making coments instead of astrik(‘)

    Ans: “Hello” : Rem Comment after a statement separated by a colon.

    8)How to run commands in command prompt from qtpAns:You can run standard DOS commands in your QuickTest test using the VBScript Windows Scripting Host Shell object (WSCript.shell). For example, you can open a DOS command window, change the path to C:\, and execute the DIR command using the following statements: Dim oShell Set oShell = CreateObject (“WSCript.shell”) oShell.run “cmd /K CD C:\ & Dir” Set oShell = Nothing 9) what is optional stepAns:

    Description

    Causes a step to be bypassed if an object in that step is not found.

    Syntax

    OptionalStep.StatementToMakeOptional

    Example

    The following example uses the OptionalStep object to make the Paris selection from the Depart WebList an optional step. OptionalStep.Browser(“Mercury Tours”).Page(“Find Flights”).WebList(“depart”).Select “Paris” 10)What is the alternative way to getROpropertyAns) object.QueryValue(property to get)11)How to get the number of childs in a tree a) Object.children.lengthex: Browser(“xxx”).Page(“xxx”).Image(“xxx”).Object.children.length11)How to know that the table has no recordsa) rs.RecordCount 12)What are the types of parameters available in QTPa) 3 types   1)  Action Parameters(Input ,output)These parameters are restricted to that action only.i.e we can not use them for another action.Note:Don’t think that the output action parameter can pass values between action.The only purpouse with output action parameter is to assign the values at run time rather than design time from the external source(application)Advantage: These parameters are bound to the action even this action is called from another test.How to Declare: Using Action property tabSyntax: Input parameter —variable= parameter(“name”)              Output parameter—Parameter(“name”)=value              2)  Test Parameters(Input ,output)These parameters are not restricted to that action i.e we can use them for any nother action.Note These parameters are not found and unable to use them in any action  is called from another test.Advantage: test  parameters can pass values between action.How to Declare: Using  Test Setting-à parameters tabSyntax: Input parameters—   variable= TestArgs (“name”)Output parameters–   TestArgs (“name”)=value3)Local ParametersThese are also same as test parameters but we need to Declare and use them from code not from IDE.Advantage:These parameters still can used even the actions are called from any testSyntax:Declarationà LocalParameter(“name”)=valueUse: variable= LocalParameter(“name”)13)what are the different ways to delay the execution steps in QTPAns)3 ways1) object.waitProperty ”propertyName”,”value”,”time in milli sec”This is called conditional wait  This will pauses the execution as long as the specified value of the property exist in the AUT or specified time out which ever is earlier2) Wait(seconds)This is called unconditional wait.i.e it will wait for the specified time3) Services.ThinkTime 10Same as wait14) How to minimize QTP while runninga) Set qtApp = CreateObject(“QuickTest.Application”)
        qtApp.WindowState = “Minimized”
         Set qtApp = Nothing

      Source: Mercury Forum’s KB articles

    Author : Tarun Lalvani

    February 14, 2008 Posted by | QTP Additional Faqs | , , , , , , , , | 5 Comments

    update data in a database

    To update information is entered into the database at runtime, you will need to add code to your script which will open a connection to the database, update the database, then close the connection. Here are the steps to do this (an example follows). 1. Create an “ADODB.Connection” object (the database object).
    2. Set the connection string for the database object.
    3. Open the connection to the database.
    4. Execute a SQL statement.
    5. Close the database connection.

    Example:Set cnBiblio = CreateObject(“ADODB.Connection”)

    ‘ Set the connection string and open the connection
    cnBiblio.ConnectionString = “DSN=QT_Flight32;DBQ=C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight32.mdb;Driver=C:\WINDOWS\System32\odbcjt32.dll;DriverId=281;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;”
    ‘ Open the connection to the database
    cnBiblio.Open

    ‘ or use this method if a DSN entry was created.
    ‘ cnBiblio.Open(“DSN=Flight32”)

    ‘ Execute the update query (SQL statement)
    cnBiblio.Execute “Update Orders SET Orders.Customer_Name = ‘John Doe’ where Orders.Order_Number = 1”

    ‘ Close the connection.
    cnBiblio.Close Note: The syntax of the Update SQL statement may vary depending on the database in use. The example above uses the sample Flight32 MS Access database.

      Source: Mercury Forum’s KB articles

    February 14, 2008 Posted by | Update data in a database | , , , , , , , , , | 2 Comments