
Description:
This blog contains QTP FAQs and QTP Interview Questions.
Contents:
What is the present version of the VB Script we are using
Present version of VB Script is 5.6.
We can findout the version of vbscript you are using by going through the location C:WindowsSystem32, search for the file vbscript.dll, and right click on it and choose the properties. Move to the version tab.
You can findout the version number.
Can a function return dictonary object
Yes.
Functions can return a dictonary object.
Dim dicObj Set dicObj = CreateObject("Scripting.Dictionary")
Set obj=getname MsgBox(obj.item("name"))
Public Function getname() dicObj.add "name","Uday Kumar" Set getname=dicObj End function
How the Message Boxes Close Automatically
The following script shows a message box that disappears after the specified timeout (in seconds). The script execution then continues.
If TimeOut is 0, it behaves just like a normal message box. If TimeOut is greater than 0, the dialog box disappears after the specified number of seconds.
Set wShellObj=createobject("WScript.shell") wShellObj.popup "Hello Uday, How are you",10,"This is sample" ' Displays like this:

The message box automatically closes after 10 sec.s
Even we can handle the error messages from the error handling mechanism like this: Set fileSysObj=createobject("Scripting.filesystemobject") On Error resume next fileSysObj.opentextfile("c:uday.txt") str=Err.description wShellObj.popup str,3,"This is for file not found"
How can I remove test result files from old tests?
You can use the Test Results Deletion Tool to view a list of all the test results in a specific location in your file system or in a Quality Center project. You can then delete any test results that you no longer require.
The Test Results Deletion Tool enables you to sort the test results by name, date, size, and so forth, so that you can easily identify the results you want to delete.
You can find this utility in Start > Programs > QuickTest Professional > Tools > Test Results Deletion Tool.
By using this tool, we can choose the test, for which you want to delete all the result folders.
Here we can select the result folders and delete that folders.

How can I configure the report to show only errors by default?
You can configure the report to show only errors by default by adding the following section to the QTReport.ini file in your in folder.
[FilterDialog]
ReportAppDefaultFilter=1 # for error only ReportAppDefaultFilter=3 # shows all messages (default)
How do I create an action template?
If you want to include one or more statements in every new action in your test, you can create an action template. For example, if you always enter your name as the author of an action, you can add this comment line to your action template. An action template applies only to actions created on your computer.
To create an action template, create a text file containing the comments, function calls, and other statements that you want to include in your action template. The text file must be in the structure and format used in the Expert View.
Save the text file as ActionTemplate.mst in your dat folder. All new actions you create contain the script lines from the action template.
For Ex: Here i am adding the following content in the text file. ' You are using QTP 9.0 ' The author of the software is Uday
Here it shows how it looks like for every action in the QTP:

How to use a key combination to send input from keyboard to a application
For Ex: how to send a key combination Alt + F1 key combination to Terminal Emulator?
You can use the below statements:
Dim WshellObjSet WshellObj=WScript.CreateObject("WScript.Shell") WshellObj.SendKeys "%+{F1}"
But make sure, whether QTP set context to the application before the these statements.
How to find out the number of links in a web page
Here i am writing the link names in a text file
Set fileSysObject=createobject("Scripting.FileSystemObject") Set linksFileName=fileSysObject.opentextfile("D:samplelinkfile.txt",2,true)
Set linkDescObj=description.Create linkDescObj("micclass").value="Link" Set noOfLinks=browser("Browser").Page("Yahoo! India").ChildObjects(linkDescObj)
For i=0 to noOfLinks.count-1 linkName=noOfLinks(i).getROProperty("name") linksFileName.writeline(linkName) Next linksFileName.close Set fileSysObject=nothing
what is the difference between Automation object model(AOM) and test object model(TOM)?
By using QTP automation object model, we can automate QTP operations. By using object, methods and properties provided by QTP, we can write programs that can configure QTP operations and settings. For example, you can create and run an automation program from Microsoft Visual Basic that loads the required add-ins for a test or component, starts QuickTest in visible mode, opens the test, configures settings that correspond to those in the Options, Test Settings, and Record and Run Settings dialog boxes, runs the test, and saves the test. Test Object Model, is nothing but how QTP identifies the objects in the application. How to get the class of an object, what mandatory and assistive properties are used during recording the application, how it identifies the objects during run session etc...
What is the vb script when the url enter into the browser
Browser Object.navigate "URL"
Ex: Browser("browser").navigate "www.yahoomail.com"
How to capture screen shots when an error occurs?
In QTP8.2, we can choose the run setting: Test -> settings -> Run tab -> set ON save image of desktop when error occurs checkbox
In QTP 9.2, follow the below navigation: Tools -> Options -> Run tab -> In the drop down list box "On Error"(default) is selected for "Save step screen capture to results"
And even we can also configure, whether we have to proceed to next step or stop the test execution by following below navigation: File Menu -> Settings -> Run Tab -> Choose the required action from the "Whenever an error occurs during run session" drop down list box.
Where the text version of script file located in file system?
Path of your testnameActionNameScript.mts
Ex: D:QTPSampleSampleTestAction1Script.mts
How to call action into a script
We can call an action as per our needs.
If you want to call a new action, follow below navigation Insert Menu ->Call to New Action -> Give an action name description etc...
If you wish to call a read only copy of an action, use "Call to copy of action" and follow the below navigation for it: Insert Menu ->Call to copy of action ->Choose the test name and action name
If you wish to call a reusable action, then use "Call to existing action" Insert Menu ->Call to existing of action ->Choose the test name and action name
If you wish to call a reusable action within your programatically during run-time use RunAction "ActionName",NoOfIterations,Parameters
If you wish to call a reusable action in another test your programatically during run-time use RunAction "ActionName[ScriptName]",NoOfIterations,Parameters
How to get line numbers in your editor in expert view?
Follow below navigation: Tools -> Editor Options -> General tab -> set show line numbers check box
How to Parameterize Object repository in QTP?
In QTP 8.2, we can parameterize both the per-action OR and shared OR.
For Per-Action OR, we can parameterize in both the global sheet and local action sheets.
To do this, we can select the object in OR, and choose parameter radio button in configure value dialog, and choose global or current action sheet in parameter options.
If the OR is shared OR, here only global sheet option is visible and current action sheet is disabled.
To parameterize the OR follow below navigation: Open the OR by Tools -> OR or OR button -> Select the object in OR or parent object -> Click parameter radio button -> click on the parameter options button beside the textbox ->select data table in parameter type list box -> choose the data sheet type and choose column name in the sheet
What are the product enhancements in QTP 9.2
Enhanced Object Spy Functionality: You can now use the Object Spy to spy on multiple objects during a single spying session. When you click the pointing hand, QuickTest is hidden, but the Object Spy remains visible. You can hover over different objects in your application and view the methods and properties of each one. When you want to return the focus to QuickTest to view methods and properties of a particular object, you click the object with the pointing hand. Web Drag and Drop Support: You can now test drag and drop operations in your Web-based application using the new Drag and Drop methods, available for all Web test objects (except the container objects Browser, Page, and Frame). You can use these methods to drag one Web object onto another Web object, to drag a Web object from one location in a frame to another, or to drag an item within a Web object to another location within that object (drag and pan). Text Recognition Support for Windows-Based Environments: In recent versions of QuickTest Professional, text-capturing test object methods, reserved object methods, text/text area checkpoints, and text/text area output value steps were not available for objects in Windows-based environments (Standard Windows, Visual Basic, ActiveX, .NET Windows Forms, ActiveX, and Terminal Emulators). In QuickTest Professional 9.2, you can use the text and text area checkpoint or output value commands to verify or retrieve text in your Windows-based objects. Alternatively, you can use the testobject.GetText (for Terminal Emulator objects), testobject.GetVisibleText, or testobject.GetTextLocation test object methods, or the TextUtil.GetText or TextUtil.GetTextLocation reserved object methods to capture the text you need. When capturing text for a text/text area checkpoint or output value step, or using one of the above mentioned methods, QuickTest tries to retrieve the text directly from the object. If QuickTest cannot capture the text this way (for example, because the text is part of a picture), it tries to capture the text using a new OCR (optical character recognition) mechanism. Whenever possible, it is highly recommended to check text from your application window by inserting a standard checkpoint, output value, or GetROProperty method for the object containing the desired text to retrieve the value of it's text (or similar) property. New Supported Operating Systems and Environments QuickTest Professional 9.2 has added support for the following operating systems, browsers, and development environments. Ø Microsoft Windows Vista Ø Citrix support Ø VMWare desktop support (QuickTest and the tested application must both be installed on the virtual machine). Ø Microsoft Internet Explorer 7 Ø Mozilla Firefox 2.0 Ø Netscape Browser 8.1.2 Ø Microsoft Windows Presentation Foundation (supported with the .NET Add-in 9.2)
What are the new features in QTP 9.2
Mercury Screen Recorder: You can instruct QuickTest to save a movie of your entire run session or to capture only the segments surrounding errors or warnings that occur. This can be useful to help you see how your application behaved under test conditions or to debug your test or component. When you select a step in the test results tree and click the Screen Recorder tab, the right pane of the Test Results window displays the frame in the movie corresponding to the highlighted step in the test results tree. Once you have a movie stored with your test results, you can export the movie file or attach the movie file to the defects you report to Quality Center. You can also use the Mercury Micro Player if you want to watch a captured movie without opening QuickTest. You can customize the criteria QuickTest uses to save movies in the Run tab of the Options dialog box. You can customize the criteria QuickTest uses to save movies by selecting Always, For errors, or For errors and warnings in the Save movies to results list in the Run tab of the Options dialog box. To configure screen recorder options, follow below navigation: Tools -> Options -> Run Tab
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. At the beginning of a run session, the RepositoriesCollection object contains the same set of object repository files as the Associated Repository Files tab of the Action Properties dialog box. The operations you perform on the RepositoriesCollection object affect only the run-time copy of the collection. You can use the RepositoriesCollection object to associate or disassociate shared object repositories with an action during a run session or change the priority order of the objects in the list. We can associate the object repositories to an action by following below navigation: Edit Menu -> Action -> Action Properties -> Associate Repositories tab.
Can the class of an object be retrieved using the logical name
QTP does not have a method or function to retrieve the class of an object based on the logical name. This is a limitation of the QTP product. However, you may use a unique property of an object to determine the class of the object. Include the unique property in a description object then use the ChildObjects method to capture a collection of the objects which have that description. The GetROProperty method can be used on each object in the collection to get the "micclass" property. Set oDesc = Description.Create()oDesc( "text").Value = "Cancel"Set child = Dialog("Login").ChildObjects (oDesc)msgbox child(0).GetROProperty("micclass")
Why QTP iterates for rows removed from the Data Table
If the user deletes a row from the data table using CTRL-X or the Delete key, QTP still runs an iteration for that row. The DataTable contains four rows with data. The user uses the Delete key to delete the third and fourth rows. On replay, QTP still replays four iterations, even though he expects it to replay only two iterations. Why does this happen? The row was not deleted from the Data Table; only its contents were removed. Each row in the table represents an iteration of the test script. You can see this in the Data Table. Any rows that are used for iterations have a black bottom grid line (instead of a gray grid line). The CTRL-X and Delete keys remove the values from the cells in the row, but do not remove the rows (the grid line for the is still black). If you want to prevent QTP from running an iteration on a row, you need to delete the entire row from the Data Table using the Edit -> Delete option (Ctrl+K). (This restores the bottom grid line from black to gray.)
When are optional steps used?
When recording a test or component, the application you are testing may prompt you to enter a user name and password in a login window. When you run the test or component, however, the application does not prompt you to enter your user name and password, because it has retained the information that was previously entered. In this case, the steps that were recorded for entering the login information are not required and should, therefore, be marked optional.
Home
|