mercredi 1 juillet 2009

QTP expert view: how to insert a wait? Step 1

This message is the first of several ones describing how to insert wait statements in your script, in order to take into account the possible time outs or delay to load a webpage.

The first which is the easiest to use but the most risky for your tests is the Wait Statement:

example: Wait(10) ' qtp will wait ten seconds before doing the next step

mardi 23 juin 2009

QTP beginner: Behaviour in case of error in the script

When launching your tests for the first times you will probably see some pop up indicating that there is an error and the script stops.

I will tell you how you can manage it and choose the appropriate behaviour for your application.
On the Files/Settings/Run you have 4 choices when an error occured:
- popup message box
- proceed to next action iteration
- stop run
- proceed to next step


The more convenient for testing is to set "proceed to next step" because when an error occured, the system will go to the next step and report the issue in the reporting.
But for debugging, the popu message box could be useful.

vendredi 12 juin 2009

QTP and QC: How to be able to launch QTP scripts from Quality Center

After having installed in your computer the Quality Center Add in, a setting should be modified in QTP to let Quality Center launch QTP scripts automatically.
This seeting is in QTP: Tools/Options/Run and check "Allow other Mercury products to run tests and components"

mercredi 10 juin 2009

QTP expert view: how to exit the test?

We all face the question if we can exit the script when we want: for example, on the beginning of the script we check that the environment is the correct one, and if not, instead of trying to pass all the script and loose time, we should exit the script.
In the expert view, in vbscript, the method that could be used is: ExitTest

mardi 9 juin 2009

QTP tips: check the time to do an action

We all want to know how much time it takes for a page or an action to be done, because we need this to know if our website is fast or not.
In QTP you can check it on a very easy way by using the function "MercuryTimers".

For example:

Browser("browsername").Page("Pagename").Link("Link").Click
MercuryTimers("Timer1").Start 'Start measuring time using Timer1.
Browser("browsername").Page("Pagename").WebTable("Table").WaitProperty "visible", "true", 10000
MercuryTimers("Timer1").Stop 'Stop Timer1.
Reporter.ReportEvent micInfo, "Elapsed Time to display the booking restriction page", "Timer: " & MercuryTimers("Timer1").Stop() & "ms"
If MercuryTimers("Timer1").Stop() > 3000 Then
Reporter.ReportEvent micFail, "", "" 'Failed report if more than 3 seconds
End If

This is very simple, as you see and can be added everywhere in your scripts.
Please don't hesitate if you need details !

vendredi 5 juin 2009

QTP issue: internet explorer does not work with QTP

For the QTP 9.2, an issue can occur: when having opened QTP and then trying to open IE, this one is not opening.
To solve this problem, you can try to open QTP without ActiveX and VBscript Add-ins.
I will try to find if a patch exists and update the comment with it.