In this QTP tutorial, we will explore – Smart Object detection, adding Synchronization point, Executing a test & analyzing the results, and the Silent Test runner.
Recommended IPTV Service Providers
- IPTVGREAT – Rating 4.8/5 ( 600+ Reviews )
- IPTVRESALE – Rating 5/5 ( 200+ Reviews )
- IPTVGANG – Rating 4.7/5 ( 1200+ Reviews )
- IPTVUNLOCK – Rating 5/5 ( 65 Reviews )
- IPTVFOLLOW -Rating 5/5 ( 48 Reviews )
- IPTVTOPS – Rating 5/5 ( 43 Reviews )
Let’s consider a scenario when no object matches or multiple objects match the recorded description for an object during runtime. How does QTP handle it?
What You Will Learn:
QTP has a mechanism in place for cases like this. If the recorded description is unable to identify the specified object during a step, and a smart identification definition is defined (and enabled) for the object, QTP attempts to identify the object using “Smart detection”.
Let’s understand how this works with some examples. Every object has Primary Properties and Secondary properties.
Example 1: Object with the recorded description is not found.
On the page, there was a button with the following properties:
- Primary: Name
- Secondary: Abs x, y
While recording, the “Name” property was “Login ID”. Due to changes in the application, the “Name” property is now changed to “User ID”. In this case, QTP will find a button with a different description, and it should fail if it considers only the primary properties.
However, in cases like this, when the primary properties don’t match, QTP checks the secondary properties. If they match, it recognizes the object. In this case, it will recognize the button based on its X and Y coordinates.
Example 2: QTP was supposed to find a page X, and there are 2 pages with similar browser settings.
In this case, it uses the “name” or other properties to find the right page/pages and works accordingly.
The above 2 examples demonstrate cases where QTP utilizes the Smart Detection mechanism.
- Test results also show if the step employed Smart detection to run successfully.
- If QTP cannot find the object despite Smart Detection, then the test fails.
For most objects, QTP provides default base filter properties (Primary) and optional filter properties (Secondary) that it checks if we enable Smart detection for them. Users can also choose which properties to consider. To do so, go to “Tools -> Object Identification”.
Choose the relevant Environment and Object Class. Once selected, enable Smart Detection and click “Configure”.
Click Add or Remove.
Select properties as required:
Make your selection and click OK when done.
The above process ensures that next time QTP has difficulty identifying an object of this class, it will utilize smart detection to do so.
For most objects, “Smart detection” is turned on by default. You can see if this is the case for a certain object by accessing it in the OR under the “Additional details” section of its object properties. It is set to “True” if enabled and “False” if disabled.
You can also choose to enable or disable Smart detection entirely for a test run. Choose “File -> Settings -> Run -> Disable Smart Detection during the run session” option.
Consider this program,
SystemUtil.Run "iexplore.exe", "http://www.gmail.com" Browser("Gmail: Email from Google").page("Gmail: Email from Google").Sync Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Email").Set "swatiseela" Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Passwd").SetSecure "sfgs686898" Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebButton("Sign in").Click Browser("Gmail: Email from Google").Page("Gmail - Inbox").Link("Sign out").Click
In an ideal world, as soon as you click the “Sign in” button on the Gmail login page, the “Inbox” should be displayed without any delays. This means that the application is ready for the last statement in our example to be executed immediately after the second-to-last statement runs.
However, in reality, applications don’t always load at the same pace. If we do not instruct QTP to wait for a certain duration before it proceeds, specifically until an object reaches a certain state, the execution may result in errors.
A synchronization point is used to instruct QTP to wait until a particular object property achieves the specified value.
When a sync point is inserted, a “Wait Property” statement is added to the test.
Browser("Gmail: Email from Google").Page("Gmail - Inbox").Link("Sign out").WaitProperty "Visible", True, 20
So your updated program will look like this: (line #6 below)
SystemUtil.Run "iexplore.exe", "http://www.gmail.com" Browser("Gmail: Email from Google").page("Gmail: Email from Google").Sync Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Email").Set "swatiseela" Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Passwd").SetSecure "sfgs686898" Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebButton("Sign in").Click Browser("Gmail: Email from Google").Page("Gmail - Inbox").Link("Sign out").WaitProperty "Visible", True, 1000 Browser("Gmail: Email from Google").Page("Gmail - Inbox").Link("Sign out").Click
You can insert a synchronization point while recording using the menu option “Insert -> Synchronization Point”. Choose the Object where you want to insert the sync point.
Enter the value as required:
The following statement gets inserted:
Browser("Gmail - Inbox").Page("Gmail - Inbox").Link("Sign out").WaitProperty "visible", True, 10000
Executing a Test
#1) Automation -> Run or F5 is typically used to run the entire test.
#2) You can run a part of the test by choosing the “Automation -> Run Current Action” option.
#3) You can run a test from a certain point in your test by choosing the “Automation -> Run From Step” option.
#4) As soon as you choose any of the above ways to run a test, you will be prompted to choose the location where you want the test results to be stored. You can choose a folder by selecting the first option, in which case the results will be stored for every instance of the test run.
However, if you choose the next option, a temporary folder, the results will be overwritten and only the latest test run result will be stored in the chosen folder. In terms of memory usage, it is advisable to use the second option while testing your QTP test.
Unless you need results for every test run, do not choose the first option because it will consume a lot of space.
#5) Input parameters: If the test has input parameters, you can provide them in this tab.
#6) You can also execute multiple tests as a batch using QTP’s “Batch Runner” tool. It is an external tool, similar to the “Password encoder tool” discussed earlier.
In our previous articles, we discussed various topics such as data table iteration, checkpoints, smart detection, and general test step execution. The Test Results provide us with an overview of whether a step was successful or not.
Aside from that, the test results can include a screenshot of your AUT when a failure occurs, based on the settings set at “File -> Settings -> Run”. Testers can also print and export test results.
To make test results more understandable, users can add their comments into the test results.
For example, if a certain condition fails in your test, you might want to write in the test results that “Did not work for the value X”. This can be done using the “reporter.reportevent” statement.
The following is the syntax:
Reporter.Reportevent(Event Status,Reporter step name, details)
Event status: MicPass, MicFail, MicWarning, MicDetail. The next two parameters can be any text that provides further details.
If I use this statement and execute it:
reporter.ReportEvent micPass, “Swati’s First Step”, “Passed because I told it to pass …”
The test results will look like this:
Transactions in QTP are typically used when you need to measure the time taken to execute a certain section of the test.
It is also used when a QTP test is to be used by Load Runner or Business Process Monitor. In such cases, your test has to be recorded in terms of a transaction, and anything outside of it will be ignored.
You can start a transaction from QTP by using “Insert -> Start Transaction”. Give it a name, choose whether you want it before or after the current step, and click OK.
Services.StartTransaction “TransactionTest” – Gets inserted. Now, I’ll record a login into Gmail.com.
Once the recording is done, choose “Insert -> End Transaction”. Click OK.
Services.EndTransaction “TransactionTest” – gets inserted.
This is the code:
Now I will run this test and see how the test results appear. The results will show a summary of the time taken to finish the transaction.
Silent Test Runner
QTP provides the Silent Test Runner, which allows testers to execute their tests without launching QTP. It also helps simulate QTP runs from Load Runner to verify compatibility.
Please note that the Silent Test Runner will not work if QTP is already open and running another test.
To launch the Silent Test Runner, go to “Start -> Programs -> QuickTest Professional -> Tools -> Silent Test Runner”. Select the test and click “Run Test”.
This is how it appears during the test execution:
Once the execution is complete:
Test Run log:
The “Transaction Summary” will be displayed if the test contains at least one transaction.
We have reached the end of this tutorial and covered various miscellaneous topics in QTP. I hope you find this useful.
Please feel free to post your comments and questions.