Monday, December 27, 2010

How to verify if Browser Window is already maximized

QTP Code:

hwnd = browser("creationtime:=1").GetROProperty("hwnd")

Msgbox window("hwnd:=" & hwnd).getroproperty("maximized")

However, this code won't work with IE7.

QTP Tip | Difference between micclass & micClass

Technically speaking there is no difference. You can try this code out to see it

Code:

obj("micClass").Value="Link"

MsgBox obj("micclass").Value

But for some very rare cases it has been observed that using micClass instead of micclass throws an error when calling ChildObjects.

Saturday, December 25, 2010

QTP Performance Issue

I am presenting a scenario for you to think on

#################################################################

I am using HP Quicktest Professional 11. My one Test Script makes call to around 30 External actions. (it uses most of them in one run)

When I modify a cell in one tab of the Datatable (of the 30 tabs referencing the 30 external actions in my script) and attempts to save the script, it takes so long; sometimes close to 45 seconds upto 1 minute.
If I try to open this kind of script, again it takes this much amount of time.

a) Does that mean QTP always try to save the 30 'Default.xls' files in addition to the one 'Default.xls' file that has been modified?
b) Should QTP not save just the one 'Default.xls' file that has been modified?

Note:
All the actions in my Test Script uses only the Descriptive Programming.

#################################################################

Having a look at the above scenario, what you could think of the reason behind this?

QTP Tip | Include Action In a Function

Question: Is there any way we use Reusable Actions in a specific function located in the function library?

Answer: Yes it is possible. You can insert the RunAction or LoadAndRunAction (QTP 10 or higher versions) statement inside your function.

The following code will illustrate the concept:

###############################################################

'Library
Function Test()
RunAction "My Action", oneIteration
End Function

'Action or Library
Call Test

QTP Tip | Reduce Object Repository Size

Question: Is there any way to reduce the Object Repository size in HP Quicktest Professional 11. I know that Descriptive Programming is one option. Is there any other way to do this?

Answer: You can export the XML file and then delete extra information that QTP stores about the object. This will definitely not allow QTP to perform smart identification. But your script can still recognize the objects present in the application.

QTP Tip | Disable QTP Results Report

There is definitely a way to disable the QTP results report which means no result file would be created even after the execution. This is certainly different from turning off the option "View results when the run session ends"

The solution for this is very simple. Go to Regedit and browse the key

HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\Logger\Media\Report

Change value of Active from 1 to 0 :)

Sunday, December 19, 2010

QTP Environment Variables Lost

I got a query from one of my esteemed readers which is shown below:

Query:

I am using QTP 10.0 with .NET Addin

I load environment variable from external file using
Environment.LoadFromFile
and this statement is the very first statement in my function library
and When QTP is executed it runs fine loading all environment variables
now after script has run through some time I pause QTP script for some time
and then continue script execution
Now I see that all the environment variables are lost
Note that this does not happen for If my QTP action code has few number
of lines of code
but If my QTP Action code contains more than 800 lines of code I observe this issue
has anyone observed such issue Huh?
Could someone comment if there is any patch Available to resolve this issue ??

##########################################################

Resolution: As far as this query is concerned, this is definitely a performance issue with QTP and should be raised to the HP team

I would like to know has anyone else faced this type of issue before!!

QTP Tip | Capture Application Screenshot during Execution

We can certainly capture application screenshots during execution. Use "Capturebitmap" method to accomplish this. For details please refer to QTP help.

Saturday, December 18, 2010

QTP11 Complete List of New Features

Here I am presenting a complete list of features which are available in the newly launched HP Quicktest Professional 11.

1. Syntax Hints for Regular Expressions

It is now easy to create regular expressions taking help of syntax hints. Regular expression evaluator is available in QTP 11 to test Regular expressions which you have created.

2. Visual Relation Identifiers: Identify objects in relation to other objects

HP R&D team has looked beyond the unreliability of ordinal identifers and come up with a new feature called Visual Relation Identifiers. Ordinal identifers hold good only as long as the relative positions of objects are maintained but if this position changes, the object identification fails.

According to HP Team

"A visual relation identifier is a set of definitions that enable you to identify the object in the application according its neighboring objects in the application. You can select neighboring objects that will maintain the same relative location to your object, even if the user interface design changes. You define visual relations in the Visual Relation Identifier dialog box, which is accessible from the local or shared object repository, and from the Object Properties dialog box."

3. Recording on Firefox Browser

The much anticipated feature ie recording on Mozilla Firefox browser is now available.

4. Load Function Libraries at Run Time

With the help of LoadFunctionLibrary statement. You can now load a function library when a step runs instead of at the beginning of a run session.

5. Much Awaited Log Tracking is available now

HP QTP 11 is nowcapable of receiving Java or .NET log framework messages from your application which can then be embedded in the QTP run results.

6. Managing Test Data

QTP 11 now boasts of an improved test data management on integrating with HP Quality Center.

7. XPath and CSS based object identification

Identify objects not only using normal object identification but with XPath and CSS identifier properties. This is a much awaited and a great feature.

8. Good Looking and Enhanced Results Viewer

HP team has now created a very good looking and some advanced Results viewer in QTP 11. The new improved results viewer provides an executive summary page with summary data, pie charts and statistics for both the current and previous runs and a quick link to the previous run results.

9. WPF and Silverlight Add-in Extensibility SDK

It 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.

10. Embed/Run Javascript in 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.

11. Extensibility Accelerator for QuickTest Professional

It provides a Visual Studio like IDE that accelerates and facilitates the design, development and deployment of QuickTest Web add-in extensibility support sets. These support sets extend the web add-ins so that you can test web controls that are not supported out of the box.

12. Automatically Parameterize Steps

You can instruct QTP 11 to automatically parameterize test steps at the end of record session.

Sunday, December 12, 2010

VBScript Code | Writing text to File

Write the below written QTP code inside a notepad and save it as a .vbs file. You can either run it from command prompt or run it by double-clicking on it.
VBScript Code - The following code reads first line from a text file.

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set FSO = CreateObject("Scripting.FilesystemObject")
Set QTPfile = FSO.OpenTextFile("c:\myfile.txt", ForWriting, False)

QTPfile.WriteLine(" This is my demo text")
QTPfile.Close

VBScript Code | Reading all lines from File

Write the below written QTP code inside a notepad and save it as a .vbs file. You can either run it from command prompt or run it by double-clicking on it.
VBScript Code - The following code reads first line from a text file.

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set FSO = CreateObject("Scripting.FilesystemObject")
Set QTPfile = FSO.OpenTextFile("c:\myfile.txt", ForReading , False)

While not QTPfile.AtEndOfStream
a=QTPfile.ReadLine
Print a
Wend

VBScript Code | Reading text from File

Write the below written QTP code inside a notepad and save it as a .vbs file. You can either run it from command prompt or run it by double-clicking on it.

VBScript Code - The following code reads first line from a text file.

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set FSO = CreateObject("Scripting.FilesystemObject")
Set QTPfile = FSO.OpenTextFile("c:\myfile.txt", ForReading , False)
a=QTPfile.ReadLine
QTPfile.Close
Print a

VBScript Code | Appending text to File

Write the below written QTP code inside a notepad and save it as a .vbs file. You can either run it from command prompt or run it by double-clicking on it.

VBScript Code - The following code appends a text to a file. If the file does not exist, it creates the file.

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set FSO = CreateObject("Scripting.FilesystemObject")
Set QTPfile = FSO.OpenTextFile("c:\myfile.txt", ForAppending, True)
QTPfile.WriteLine("Myfirst line of text.")
QTPfile.Close

Friday, December 3, 2010

HP Quicktest VBScript Palindrome

Write the below written QTP code inside a notepad and save it as a .vbs file. You can either run it from command prompt or run it by double-clicking on it.

VBScript Code - Finding whether a string is Palindrome or Not.

x=Inputbox("Enter a string")
if x= strreverse(x) then
Msgbox "Its a Palindrome"
else
Msgbox "Its not a Palindrome"
End if