WORKING WITH QTP

TestEveryThinG

QTP 11.00 New Features

Posted by rajivkumarnandvani on September 24, 2010

QuickTest 11.00 now offers the following new features.

Manage Your Test Data

Quality Center (HP ALM) test configuration functionality enables you to determine at runtime which data sets to use for your tests.

ALM test configurations enable you to:

  • Unbind your data from your tests
  • Share common data sources across different tests
  • Filter your data to fit your testing needs
  • Increase requirements traceability

You store the data for your tests in the Quality Center Test Resources module in the form of data table resource files.

You can then define multiple test configurations for a test in the Test Plan module. When working with data-driven QuickTest tests in HP ALM, each configuration is a QuickTest test that is set to run with a selected data resource file and optional data filter settings.

One or more specific configurations of the test can be included in a Test Set to cover different parts of a requirement or to cover multiple requirements.

By using Quality Center test configurations, you can create more generic tests and reuse them by associating a different set of data with each. You can also reuse your data by associating the same data table file with multiple tests.

Test Your GUI and UI-Less Application Functionality in One Test

The new QuickTest-Service Test integration enables you to test across the GUI and non-GUI layers of your application.

You can use QuickTest steps to start testing the GUI elements in your application, then call a Service Test test to validate service communications (standard Web Services, non-SOAP Web Services, such as REST, etc.), and then step back into your QuickTest GUI testing, all in a single test run.

The results of the QuickTest and Service Test steps are displayed in a unified report in the new Run Results Viewer.

New Run Results Viewer

The new Run Results Viewer provides an Executive Summary page with summary data, pie charts and statistics for both the current and previous runs, a quick link to the previous run results, and more.

The Run Results Viewer displays the results of your run session in a set of panes that you can show, hide, move, dock, and otherwise customize to your needs.

You can install the Run Results Viewer as a standalone installation. This enables you to share the results of your tests with business analysts and developers who do not work with QuickTest.

Help QuickTest Identify Your Objects as a Manual Tester Would – VISUALLY

You can now use visual relation identifiers to identify application objects based on other objects that are always near them.

This enables you to create a more reliable identification definition for test objects that are otherwise difficult to differentiate, and to ensure that the identification remains reliable even if the user interface design changes.

The Visual Relation Identifier Dialog Box provides the interface and tools to help you create and verify your visual relation identifier definitions.

Collaborate with Developers to Pinpoint Defects Using Log Tracking

In today’s more agile development environment, it is more important than ever for QA engineers and developers to work together throughout the development and release process.

QuickTest’s new Log Tracking functionality helps you work with developers to pinpoint the root causes of unexpected behavior in your application.

When you enable log tracking, QuickTest receives the Java or .NET log framework messages from your application and embeds them in the run results.

You can click a log message in the results to jump to the relevant step in the run results tree, or you can click a step in the run results tree and view the log message that was generated at the time that the selected step ran. You can also specify that a log message of a particular level (or higher) will fail your test.

After you view the results, you can print or export the log tracking details to a file to show to a developer, or you can provide the developer with the standalone Run Results Viewer installation so that the developer can view and analyze the results directly on his or her own desktop.

Out-of-the-Box Support for Web 2.0 Toolkit Applications

QuickTest 11.00 provides Web Add-in Extensibility-based add-ins for ASP .NET Ajax, GWT, Yahoo UI, and Dojo Web 2.0 toolkits.

You can use these add-ins just as you would any other add-in. You can also use Web Add-in Extensibility or Extensibility Accelerator to customize the provided support to match your needs.

You install these add-ins by running the Web 2.0 Toolkit Support Setup from the Add-in Extensibility and Web 2.0 Toolkits option in the QuickTest Professional setup window.

The operations supported for each Web 2.0 test object class are a combination of custom operations developed for that test object class and operations directly inherited from the corresponding (base) Web Add-in test object class.

New Web Testing Capabilities

Many new testing capabilities are now available for working with Web-Based objects.

  • Firefox Testing. You can now record steps on Mozilla Firefox and use the .Object property to access the Firefox DOM.
  • XPath, CSS, Identifiers. You can add the XPath or CSS identifier properties to instruct QuickTest to identify a Web object in your application based on its XPath location or CSS definition.
  • Event Identifiers. You can also now use the attribute/* notation in the test object description to identify a Web-based object based on an event associated with that object. For example, you can add attribute/onClick as a property in a WebButton test object description to identify a button that is associated with the onClick event.
  • Embed or Run JavaScripts in Your Web Pages. You can use the new EmbedScript/EmbedScriptFromFile and RunScript/RunScriptFromFile functions to embed JavaScripts in all loaded browser pages and frames or to run JavaScripts in specific pages. Use these scripts to perform operations on, or retrieve data from, the browser pages in your application.

Automatically Parameterize Steps

You can instruct QuickTest to automatically parameterize the steps in your test’s actions at the end of a recording session.

This enables you to create actions that can be used for a variety of different purposes or scenarios by referencing different sets of data.

You activate this option by selecting the Automatically parameterize steps option in the General tab of the Options dialog box. You can set the option to use Global Data Table Parameters or Test Parameters.

When you stop a recording session while this option is selected, QuickTest replaces the constant values in the test object operation arguments of your steps with either Data Table parameters or action parameters, based on your selection in the Options dialog box.

QuickTest performs this automatic parameterization for all relevant steps in any action in your test, in which you recorded one or more steps during that recording session.

If you work with HP ALM, and you select the Global Data Table Parameters option, you can map the generated parameters to the column names of a data resource and then use different configurations in your test sets.

If you work with SAP eCATT and you select the Test Parameters option, you can then supply the values for the test parameters from eCATT.

New Silverlight Add-in

You can use the new Silverlight Add-in to test objects in Silverlight 2 and Silverlight 3 applications.

After you install the Silverlight Add-in, it is displayed in the Add-in Manager as a child add-in under the WPF Add-in.

Extend WPF and Silverlight Support

The WPF and Silverlight Add-in Extensibility SDK enables you to develop support for testing third-party and custom WPF and Silverlight controls that are not supported out-of-the-box by the relevant QuickTest add-ins.

You install the WPF and Silverlight Add-in Extensibility SDK from the Add-in Extensibility and Web 2.0 Toolkits option in the QuickTest Professional setup window.

Use Extensibility Accelerator for Web Add-in Extensibility Development

The new Extensibility Accelerator for Functional Testing is a Visual Studio-like IDE that facilitates the design, development, and deployment of Web Add-in Extensibility support.

It provides a user interface and special tools that help you define new test object classes, map those test object classes to the controls in your application, and teach QuickTest how to identify the controls, perform operations on the controls and retrieve their properties.

You install the Extensibility Accelerator from the Add-in Extensibility and Web 2.0 Toolkits option in the QuickTest Professional setup window.

It’s Easier Than Ever to Insert Regular Expressions

The Smart Regular Expression list provides syntax hints that make it easier than ever to insert regular expressions into your test steps. It also enables you to access the Regular Expression Evaluator, which lets you test regular expressions to make sure they suit your needs.

Load Function Libraries at Run Time

The new LoadFunctionLibrary statement lets you load a function library when a step runs instead of at the beginning of a run session. This means, for example, that you can define conditional steps that use functions from various function libraries, but load only the required function libraries during a run session.

Avoid Downtime Due to License Server Failures

With redundant license servers you create failover, so that if your main license server fails, your remaining servers maintain availability of your licenses without causing any downtime or loss of licenses for users.

The redundant license server feature is especially useful for enterprise customers

who have a large network installation and want to maintain license server backup.

Improved Documentation Structure Helps You Find the Information You Need

When you open the QuickTest Professional Help, you can now access the entire Documentation Library from one central point, the Home page. It provides links to all available guides in each available format, including PDF files.

The HP QuickTest Professional User Guide and the HP QuickTest Professional for Business Process Testing User Guide are now organized into topic types: Concepts, Tasks, and References. Use each topic type to access specific information about a feature or product area.

For example, you can use the Tasks topic type to learn the overall workflow of a feature to help you accomplish your goals, or you can use the Reference topic type to look up a specific user interface element, such as a window, dialog box, or page.

Posted in QTP | 2 Comments »

Lock the system after QTP script execution completion using VBSCRIPT

Posted by rajivkumarnandvani on September 22, 2010

Hi All,

By using below mentioned script you can  lock the system after QTP script execution completion.

rem  create winshell object

Set obj = CreateObject(“WScript.Shell”)

sCmnd = “%windir%\SYSTEM32\rundll32.exe user32.dll,LockWorkStation”

obj.Run sCmnd, 0, False

Set obj =nothing

Posted in QTP | 5 Comments »

Compare bitmap file using QTP ( using Mercury.FileCompare object )

Posted by rajivkumarnandvani on June 17, 2010

Hi All,
We can use QTP in-build method for File compare with the help of Mercury.FileCompare.
Here I am going to describe how to use that.

Rem variable to store the location of the expected bitmap file
strstoreBMPfile = “D:\rajivkumarnandvani.bmp”

Rem variable to store the location of the actual bitmap file
strActBMPfile = “D:\rajiv\runtimebmpfile.bmp”

Rem Activate the window

Window(“Flight Reservation”).Activate

Rem Capture the actual bitmap image from the application during run-time
Window(“Flight Reservation”).Static(“Static”).CaptureBitmap strActBMPfile , True

Rem here True will overwrite the file
Rem here we write the function for compare the bitmap file using qtp inbuild method Mercury.FileCompare.
Rem Function FnCompareTwoBMPfiles
Rem Description: this function Compares two bitmap images
Rem input pathExpBMPfile path of Expected bmp file
Rem input pathActBMPfile path of Actual bmp file
Rem return value 1 if both file are same ; 0 if different

Function FnCompareTwoBMPfiles( byval pathExpBMPfile , byval pathActBMPfile)
rem create qtp file system object
Set objMercuryFilecompare = CreateObject(“Mercury.FileCompare”)
rem here we use binary compare
if objMercuryFilecompare.IsEqualBin( pathExpBMPfile , pathActBMPfile , 0,1) Then
rem if match then return 1
FnCompareTwoBMPfiles = 1
else
rem if does not match then return 0
FnCompareTwoBMPfiles = 0
end if
rem discard the object
Set objMercuryFilecompare = nothing
End Function

Rem now we call this function

if FnCompareTwoBMPfiles(strstoreBMPfile ,strActBMPfile) = 1 then
msgbox “ BMP file match”

else
msgbox “BMP file not match”
end IF
Rem same thing we can use for other files also.

Posted in QTP, WINDOWS | Tagged: , , , | 9 Comments »

How can I access HTML tags directly?

Posted by rajivkumarnandvani on June 3, 2010

QuickTest provides direct access to the browser’s Document Object Model
(DOM) through which you can access the HTML tags directly. Access to the
DOM is performed using the .Object notation.
The test below demonstrates how to iterate over all the tags in a page. The
test then outputs the inner-text of the tags (the text contained between the
tags) to the Test Results using the Reporter object.
‘ Use the on error because not all the elements have inner-text.

On Error Resume Next
Set Doc = Browser(“CNN Interactive”).Page(“CNN Interactive”).Object
‘ Loop through all the objects in the page.
For Each Element In Doc.all
TagName = Element.TagName ‘ Get the tag name.
InnerText = Element.innerText ‘ Get the inner text.
‘ Write the information to the test results.
Reporter.ReportEvent 0, TagName, InnerText
Next

Posted in QTP, WEB | 1 Comment »

QTP not recording web application in VISTA

Posted by rajivkumarnandvani on April 21, 2010

Hi All,

I faced the problem when I installed the QTP in vista.QTP  was not recording any web application then i tried to check with OBJECT SPY how its identify the web object Object Spy identify the each web object as a winobject. Then i found the solution to solve this problem this was because vista User control . In Vista you need to off USER CONTROL option after that QTP works fine and records the web application. To off the USER CONTROL option follow the following steps:

Click Start  >Control Panel>User Accounts and Family Safety>User Accounts

and uncheck  the Turn User Account Control On or OFF option

QTP not recording web application in VISTA

Posted in QTP | 32 Comments »

Get File count and found matching file name VB script

Posted by rajivkumarnandvani on January 7, 2010

Dim fs ‘ variable declared outside a procedure (this is a global variable)
‘ this is hold a reference to the file system object
”create an instance
On Error Resume Next
Set fs = CreateObject(“scripting.filesystemobject”)
Set MyFile = fs.CreateTextFile(“c:\Filepath.txt”,True,True)

‘ count files in windows directory
folderpathvalue = inputbox (“Plese Enter Folder path” ,”Folder”,”C:\WINDOWS\”)
FileNamevalue = inputbox (“Plese Enter File name/extension of file” ,”FileName”,”.txt”)
Filecountvalue = CountFiles (folderpathvalue , FileNamevalue )
Set WshShell = CreateObject(“WScript.Shell”)
Set MyFile = nothing
Set fs = nothing
rem it will return the total file count value not the matching file count value
msgbox “Total File count is ” & Filecountvalue
rem it will show the how many file found with matching criteria
WshShell.run(“c:\Filepath.txt”)
Set WshShell =nothing

‘ takes a string argument containing the name of the directory

‘ returns an integer contiang the nubmer of files in that direcrectory

‘ and all sub directories

Function CountFiles (ByVal StrFolder ,byval FileNamevalue)
Dim ParentFld
Dim SubFld
Dim IntCount
‘ note the use of the fs global variable
Set ParentFld = fs.GetFolder (StrFolder)
‘ count the number of files in the current directory
IntCount = ParentFld.Files.Count
For Each oFile In ParentFld.files
On Error Resume Next
If InStr(1, lcase(oFile.path),FileNamevalue) > 0 then
MyFile.writeline oFile.path
end If
Err.clear
Next
For Each SubFld In ParentFld.SubFolders
‘ count all files in each subfolder – recursion point
IntCount = IntCount + CountFiles(SubFld.Path ,FileNamevalue)
Next
‘ return counted files
CountFiles = IntCount
End Function
Err.clear

Posted in QTP | Tagged: , , , | Leave a Comment »

Check page broken link using VB script

Posted by rajivkumarnandvani on January 5, 2010

Hi,
I created a script that will check broken link in a page means valid url is that or not by using Microsoft.XMLHTTP object

rem create link object description
Set alllinkob = Description.Create()
alllinkob(“micclass”).value =”Link”
alllinkob(“html tag”).value =”A”

rem get alllink objects
set objAlllinkObj = Browser(“Google”).Page(“Google”).ChildObjects(alllinkob)
rem run a loop as per link on the page
For a =0 to objAlllinkObj.count-1
rem get link url
url = objAlllinkObj(a).getroproperty(“url”)
rem call function
call geturlstatus(url )

Next

Set objAlllinkObj = nothing
rem Clear browser cache
Public Function ClearBrowserCache()
On Error Resume Next

rem TEMPORARY_INTERNET_FILES file path in system
Const TEMPORARY_INTERNET_FILES = 32’&H20& ‘Decimal 32 is equivalent to hex value &H20&

rem create file system object
Set objCacheFSO = CreateObject(“Scripting.FileSystemObject”)

rem create shell application  object
Set objShell = CreateObject(“Shell.Application”)

rem create temporary folder path object
Set objFolder = objShell.Namespace(TEMPORARY_INTERNET_FILES)

Rem delete all file under temporary folder
objCacheFSO.DeleteFile(objFolder.Self.Path & “\*.*”)

Rem get cache folder path..

sPath = objCacheFSO.GetFolder(objFolder.Self.path) & “\Content.IE5\”

Rem create cache folder object..
Set objFolders = objCacheFSO.GetFolder(sPath)
For Each objFName In objFolders.SubFolders
‘WScript.Echo sPath & objFName.Name
objCacheFSO.DeleteFolder sPath & objFName.Name, True
Next
ClearBrowserCache= True
Set objFolder=Nothing
Set objShell=Nothing
Set objCacheFSO=Nothing
err.clear
End Function

Public Function geturlstatus(url )
On Error Resume Next
Call ClearBrowserCache()
Set webService = nothing
Set webService= CreateObject(“Microsoft.XMLHTTP”)
webService.open “GET”, url, False
webService.Send
pagestatus = webService.status
If pagestatus < 200 or pagestatus >399 Then
print “In valid request “& pagestatus &” ” & url
geturlstatus = 0
else
geturlstatus = 1
print “valid request “& pagestatus &” ” & url
End If
Set webService = nothing
err.clear
End Function

rem __________________________________________

url = “http://en.wikipedia.org/wiki/List_of_HTTP_status_codes&#8221;

call geturlstatus(url )

Posted in QTP | Tagged: , | 45 Comments »

Using Date in VB script

Posted by rajivkumarnandvani on January 1, 2010

Hi All,
Some time we required date in different format like DD/MM/YY but when we use now or date function it will written the value as per ur system configuration date format like if today is 1st jan 2010 and we need the date in DD/MM/YY format means 01/01/2010 but it will written 1/1/2010 if date 31 jan 2010 then it will written 31/1/2010 while we need 31/01/10
so for this we can use in this way

dim dayvalue, monthvalue , yearvalue
dayvalue =right(“0″&day(now),2)
msgbox “dayvalue =” &dayvalue

monthvalue =right(“0″&month(now),2)
msgbox “monthvalue =” & monthvalue
yearvalue=right(year(now),2)
msgbox “yearvalue =” & yearvalue

Posted in QTP | Tagged: | Leave a Comment »

Check object is Visible OR Not on Web Page QTP

Posted by rajivkumarnandvani on December 21, 2009

Hi All,

Some times we have to  check that a object(WebElement) should not exist on the page. For this we use object exist = False  property but when we run the script it gets failed While object is not showing in the Page. We think that there is  something  wrong.

The reason behind why QTP  is giving this because object is present in the page but not visible means it not displaying while it exist in HTML code.

So for this we have to be understand the object property( object.currentstyle.display) there will be case some time object inherit the property from its parent or another parent element property to display in page. First we have to identify that object when it not showing/displaying in page.We have to check its display property

Display property value we can get through like this

rem disvalue

disvalue =Browser(“Google”).Page(“Google”).Image(“Happy Holidays from Google!”).Object.currentStyle.display

if disvalue =”block” then

print ” object not displaying”

else

print ” object displaying”

end if

like this(incase if object using display property from its  parent object )  we have to check by which element my object showing on page

Posted in QTP | 8 Comments »

Use of index property in QTP

Posted by rajivkumarnandvani on November 28, 2009

Hi ALL,

Some time we use index proerty to idendify the object incase object found more than one with same property.
So before adding index property we have to understand that is this property realy required or not becos incase if an object one(unique in application). in case object unique in application and you add index property for that it increase the time to identified the object. In QTP 9.2 it taking more time with respect to QTP 9.5

Here i am showing an example that will show the time calculate withuse of index/creationtime property and without use of this and shows the time difference to execute the steps
First open the QTP application with WEB adding and copy the script in QTP
now open the browser(IE) after open the browser run the script

rem with creationtime

set objBrowser = Description.Create()
objBrowser(“micclass”).value =”Browser”
objBrowser(“CreationTime”).value=0
a= timer
print “with creation time” & Browser(objBrowser).GetROProperty(“title”)
print timer-a

Set objBrowser = nothing

rem without creationtime

set objBrowser = Description.Create()
objBrowser(“micclass”).value =”Browser”

b= timer

print “without creation time” & Browser(objBrowser).GetROProperty(“title”)
print timer-b

Set objBrowser = nothing

Posted in QTP | 4 Comments »