Showing posts with label QTP 10. Show all posts
Showing posts with label QTP 10. Show all posts

Execution flow of Function Libraries

Function Libraries - An area where most interviewers focus on. The reason for this is that if you have worked on QTP, you just cannot miss using function libraries. If you didnt, then there definitely is something wrong in your framework. Functions and reusable actions help you achieve code modularization which is a very important aspect in test automation development.

I was not thinking of explaining the function libraries and how to associate them but rather on something very interesting related to the execution flow. You can already get a lot of information on what a function library is and how to work with them. So whats the fun if I was going to repeat the same thing, right !!!!! Thats the reason why I did not want to concentrate on that topic, however if you do want me to post a thread on the details, please do let me know.

OK..so what was I meaning by execution flow. Ideally and practically, a function library would contain function definitions, external function declarations and/or global constant declarations. However you must understand that theoretically and technically, it could actually contain any valid VB script syntax. So, to show the execution flow, I am going to do something here which we would not normally have in a function library but this is just to explain one particular concept here.

First I am going to create a function library called as Lib1 and this contains just the statement
MsgBox "Within Function Library 1"

This is what I said above that we wont put a MsgBox in a function library and this is purely for illustration purpose. Next I am going to create a test and associate this function library within that test.



















My test contains nothing but another MsgBox statement






So we are ready... Lets run the script now and see what happens...
We first got








And then...








So what does this mean. When an action is run, the first thing that happens is that function library is executed first and only then the code within the action is being executed. So far so good but lets try to make it more interesting. Lets create another function library called Lib2 and associate that too with this test. Lib2 contains another MsgBox statement
MsgBox "Within Function Library 2"


 
















Now lets run our action and see what we get but before that I want you to anticipate what the outcome would be and then check the result. Which MsgBox came first ???








And then








And then








I am sure most of you would have expected the Function Library 1 MsgBox to appear first, right ? But no, the order of execution of the Function libraries are Bottom-Up and NOT Top-Down. Well, you can change the order of the function libraries and see what happens. But dont you think this is sort of wierd !!! From a user point of view, it looks like the library on the top would be executed first. So I am not sure if this is a bug in QTP or is this as per design.

Well, it doesnt really matter so long as we know what the order of execution is. I hope you all enjoyed this interesting fact and understood the execution flow of function libraries. See you soon !!!



I dont want to have any sort of copyright or copyleft in this site but if you are reusing this code in any other site, I would appreciate you to provide this page as a link so that others get a more descriptive explanation of this concept. Your suggestion and comments are always welcome. Cheers !!!
As always,
Your friend in need,

George, Reju

Read Users' Comments (1)comments

The Power of Extern


One of the very powerful tools in QTP - the Extern object. Thinking why this is so powerful !!!! The Extern object is one of the techinques of "extending" the capabilities of QTP. Understand that QTP, by itself, has numerous functionalities like Data Tables, Checkpoints, Synchronization points etc..etc.. But have you not ever come across a situation where you found that QTP could not do something on your test application !! I am sure you would have !!!!

OK...lets try this... Lets open the windows explorer...





How do we get the column width for the "Name", "Date modified" or "Type" column. QTP will be able to identify the area marked in red and so you can perform all the available methods QTP gives to you for the WinListView but is there a method to actually get the width of a column ? H-m-m not really... and that is where the Power of Extern comes into the picture. But first what is this Extern Object ???


The Extern object enables you to declare calls to "external" functions from an "external" dll or dynamic-link library.


OK...that would have been a pretty complex statement for beginners so lets try to simplify this statement.... DLL is a Microsoft implementation of a concept called as shared libraries. I dont want to deviate too much from our current topic but as of now just understand this, DLLs would export some functions which we will be able to use later on. Some of these functions can be called from the user level and others only at the kernel level. Different programming languages provide different techniques for achieving this and in QTP it is through the Extern object. I guess that should be sufficient for now and when we see the example below, we are going to get a real good idea of this concept.

So how are we going to find the width of the columns above. We know that QTP's WinListView object does not have any capability of its own to give us this information but there is someone else - user32.dll. This is a file residing in C:\Windows\System32 and it has a function called as SendMessage which we are now going to use in QTP.... now its getting interesting right... alright so lets get into it.

We first need to declare the function because QTP does not know about this function yet and this is how we are going to declare it

Extern.Declare micLResult, "SendMessage", "user32.dll", "SendMessage", micHwnd, micUInteger, micWParam, micLParam


Now you must be wondering how I knew the prototype of this function, right ? Just go to MSDN... SendMessage function description

At this point, QTP knows that there is a function called as SendMessage and will now allow us to use this. However SendMessage is not just for getting the column width, it has numerous other uses which you can research on your own time but what I am going to show is just the mechanism to get the column width.

The first argument to the SendMessage function is the handle to the object and in this case its the WinListView object.

The second argument is the message to be sent and in this case it should be LVM_GETCOLUMNWIDTH. As of now, just understand that the decimal value for this is 4125.

The third argument is the index of the column which starts at 0.

The fourth argument should always be 0.

Dont get too overwhelmed at this stage !! We are not trying to explain what SendMessage is but rather the Power of Extern object which helps in using external functions. A developer in your team could provide you a dll as well and you can make use of the functions in that dll if you know the function prototype. OK... so lets move ahead..

We are all set now to get the column width and here is how our program is going to look like.



The third argument is the column index. So in this example, it would give the column width of the first column which is "Name". If you change it to 1, it would give the column width of the second column which is "Date modified".

Well, we just experienced the Power of the Extern object which "extends" the capability of QTP. We were able to do something which the WinListView object was not capable of. A very powerful tool which you would definitely need as you do more advanced programming.


I dont want to have any sort of copyright or copyleft in this site but if you are reusing this code in any other site, I would appreciate you to provide this page as a link so that others get a more descriptive explanation of this concept. Your suggestion and comments are always welcome. Cheers !!!
As always,
Your friend in need,

George, Reju

Read Users' Comments (4)

Check for Updates Returns - Error: 13001 Product Not Registered with the FLEXNet Connect


Hey....have you seen this error lately... I never saw this until last month. I was always able to search for updates and install it. But suddenly things changed and I started to see this wierd error..


OK....what actually happened. FlexNet Connect (C) is an application by Flexera Software that keeps the application connected to users by electronically delivering applications, software updates, and messages directly to their systems. But HP no longer uses FLEXNet to distribute critical product patches. As of Dec 22, 2009, this service has been unavailable.
HP has mentioned that a fix for this would be available by the first half of 2010.  So if you want to download the release update for QTP 10, you would need to go here.

But unfortunately, you would have to wait till HP comes with a patch for this. Till then, good luck !!!


Update on 07/08 - Here is an update from one of my readers - Motti Lanzkron ... Thanks Motti...

Hi,

I ran across your post
http://learnqtponline.blogspot.com/2010/01/check-for-updates-returns-error-13001.html and wanted to leave a comment but when the captcha came up there wasn't a way to enter the text.
Here's what I wanted to say:

QTP has stopped using the Flexera solution and is now using HP Update, you can get a patch that configures QTP to use the new update mechanism here:

http://h20230.www2.hp.com/selfsolve/document/FID/DOCUMENTUM_QTP_00667
Note that HP Update is *not* aware which product launched it and will suggest all the relevant HP updates for your computer.

I dont want to have any sort of copyright or copyleft in this site but if you are reusing this code in any other site, I would appreciate you to provide this page as a link so that others get a more descriptive explanation of this concept. Your suggestion and comments are always welcome. Cheers !!!
As always,
Your friend in need,

George, Reju

Read Users' Comments (4)

QTP 10.00 Release Update

HP has released an update for QTP 10.0 (Patch QTP_00626) which is a cumulative patch that updates your QuickTest installation with the latest files from a set of patches and hotfixes.
Release Date: Oct 15, 2009


Refer the patch information page here.


The detailed release notes of this patch can be viewed in the Release Notes Page.


Core Patches and Hotfixes

The following patches and hotfixes apply to the QuickTest core application:
  • QTP_00579 - Add Recovery Scenario-Function Library Dependency
  • QTP_00584 - Improve Performance of Loading Multiple Function Libraries Using QuickTest
  • QTP_00588 - Enable Running WinMenu.Select Steps on Context Menus in Windows with an Invisible Parent
  • QTP_00589 - Ensure DataTable.ImportSheet Returns Correct Error Code
  • QTP_00594 - Prevent Loss of Environment Variables that were Loaded in an Automation Script
  • QTP_00596 - Prevent Unexpected Icons from Appearing in Expert View of Large Tests with Breakpoints
  • QTP_00599 - Improve Performance of Running Function Library Functions
  • QTP_00600 - Performance and Stability Fixes for the QuickTest Debug Viewer
  • QTP_00602 - Support the Quality Center Resources Folder for the Application.Folder.Add Automation Method
  • QTP_00603 - Do Not Filter Invisible Windows
  • QTP_00604 - Prevent QuickTest Crash Due to Corruption of Internal Configuration File
  • QTP_00606 - Support Relative Paths for the ObjectRepositories.Find Automation Method
  • QTP_00607 - Improve Performance of Browsing Network Folders using QuickTest Dialog Boxes
  • QTP_00608 - Save the Correct Version of Resources When Using the 'Save Test With Resources' Feature
  • QTP_00610 - Prevent Incorrect Deletion of Folder Paths when Running an Application.Folder.Add Automation Method
  • QTP_00611 - Prevent QuickTest Crash/Freeze After Rapidly Performed User Operations
  • QTP_00613 - Ensure that Steps can Run on Returned Child Objects after an Exist Step Runs on that Object
  • QTP_00616 - Languages supplement for text recognition
  • QTP_00617 - Prevent QuickTest from Crashing When an ExecuteFile Statement calls Function Library with Syntax or Logical Errors
  • QTP_00621 - Enable Relative Paths for Function Calls in Recovery Operations
  • QTP_00625 - Increase Value Length Limitation When Storing Function Libraries in QuickTest
  • QTP_00629 - Ensure that QuickTest Tests Run from Quality Center Do Not Fail When a Single Step Takes a Long Time
Java Hotfix
  • QTPJV_00008 - Java Add-in Memory Leak and Support Next-Generation Browser Plug-in for Windows XP

.NET Patches and Hotfixes

The following patches and hotfixes apply to the QuickTest .NET Add-in:

  • QTPNET_00014 - Prevent Internet Explorer Crash On GridView with Text-Only Cells
  • QTPNET_00024 - Prevent Application or QuickTest Crash when .NET Add-in Extensibility is Used

 Oracle Hotfix
  • QTPORACLE_00005 - Enable Neutralizing Menu Listeners To Improve Performance Opening E-Business Suite Forms

 PowerBuilder Patches and Hotfixes

The following patches and hotfixes apply to the QuickTest PowerBuilder Add-in:
  • QTPPB_00006 - QuickTest Testing Support for PowerBuilder 11.5
  • QTPPB_00007 - Enable PBDataWindow.GetCellData While Object is Disabled
  • QTPPB_00008 - Increase String Length Maximum in DataWindow.GetCelldata() Method
  • QTPPB_00009 - Remove Obsolete DataWindow.ButtonClick Method

Siebel Patch
  • QTPSBL_00002 - Improve Performance on Siebel Apps

 Terminal Emulator Hotfix
  • QTPTE_00008 - Ensure TeTextScreen.GetText Method Captures All Text For Emulators in Text Mode
Visual Basic Hotfix


  • QTPVB_00002 - Prevent QuickTest from Crashing when Working with Windows Containing Many VbLabel Objects

Web Patches and Hotfixes


The following patches and hotfixes apply to the QuickTest Web Add-in:  
  • QTPWEB_00020 - Performance Improvement for Running Initial Steps on Modal Dialog Boxes 
  • QTPWEB_00026 - Resolve Conflict between QuickTest and McAfee Host Intrusion Prevention
  • QTPWEB_00028 - Cumulative Hotfix For Web Extensibility Performance
  • QTPWEB_00030 - Solve Problem with Active Screen Capture for Some Web Pages
  • QTPWEB_00031 - Prevent Internet Explorer from Crashing When Secondary Browser Windows Close
  • QTPWEB_00037 - Support for Internet Explorer 8
Registry Settings and Other Manual Changes


After installing this release update, you may also need to add or modify a registry setting or make other manual fixes to enable or modify the functionality provided in the following patches and hotfixes:

  • QTP_00599 - Improve Performance of Running Function Library Functions
  • QTP_00600 - Performance and Stability Fixes for the QuickTest Debug Viewer
  • QTP_00603 - Do Not Filter Invisible Windows
  • QTP_00629 - Ensure that QuickTest Tests Run from Quality Center Do Not Fail When a Single Step Takes a Long Time
  • QTPJV_00008 - Java Add-in Memory Leak and Support Next-Generation Browser Plug-in for Windows XP
  • QTPORACLE_00005 - Enable Neutralizing Menu Listeners To Improve Performance Opening E-Business Suite Forms
I dont want to have any sort of copyright or copyleft in this site but if you are reusing this code in any other site, I would appreciate you to provide this page as a link so that others get a more descriptive explanation of this concept. Your suggestion and comments are always welcome. Cheers !!!
As always,
Your friend in need,

George, Reju

Read Users' Comments (0)

Smart Identification - Pretty Smart !!!


Hey, today lets get into this concept of Smart Identification with an example. The QTP help documentation gives a pretty neat explanation of this concept, but you know what ... you will understand it better when you first see what it is and then read the help !!! A picture says a 1000 words .. so lets see what this smart identification really is !! You need an example, right ? Ok.. so here we go.

Lets first get prepared. Make sure that your browser has tabbed browsing. In IE8 you go to Tools->Internet Options->General->Tabs->Settings and make sure that you have the check box for "Enable Tabbed Browsing" checked. Next, lets make the home page set to blank. Again .. go to Tools->Internet Options->General->Home Page->Use blank. Lets close Internet Explorer. OK.. we are ready !!

Open QTP and load the Web Add-in. Go to Automation->Record and Run Settings. In the Web tab, make sure that "Record and run test on any open browser" radio button is selected. Now open IE. IE should now be opened and you should be seeing the page about:blank. Go to www.google.com. Now lets start recording and hit the Record button in QTP. Now enter site:learnqtponline.blogspot.com at the search box and click the button "Google Search". Hope you are with me until now. Stop the recording. If everything went well, this is what you should see in your script..



Lets go to IE and click on the back button. This should take you back to the Google page. Lets run this script now and look at the results.




So far, so good. Now what we will do is close IE and open it once again. Nothing special, just want to get into the reset mode :) So now you have the about:blank page opened again. Go to www.google.com again and this time we will open one more tab (not another browser..remember we enabled tab browsing earlier !!) and in this tab also we will go to www.google.com. Note that you have your second tab focussed and lets leave it like that. Shall we run our script now ? Ok..lets do it !! Lets run our two line test.
What happened ? Did it just go to the first tab and execute the test ? What is our results showing ?


Ok...so now we got an example and let me explain from here.
First let us look at a couple of windows
Below is the local object repository


Below is the window you see when you go to Tools->Object Identification

And below is the window you see when you click on the "Configure" button next to the "Enable Smart Identification" checkbox.

In the object identification window, we see that for the browser object, we do not have any mandatory or assistive properties to identify the Browser object. As a result, if you look at the local object repository, you see just the same. So what happened when we created a new tab and went to www.google.com and reran the test. QTP saw two browser objects but was unable to decide which browser object it was supposed to go to. Note that the Browser object had the Enable Smart Identification mechanism set to True and so the Smart Identification mechanism kicked in when a conflict aroused.
Now we are going to see what this mechanism actually is. For that we will analyze two windows, the results window of the second test and the window "Smart Identification properties - Browser" as you see on the top. The first part of this mechanism is that QTP will see if there are any Base Filter Properties. Since we dont have any in this case, Smart Identification mechanism  moves on to look at the Optional Filter Properties. It will take the first property which is "name" and filter the objects. QTP sees that both the browser objects (both tabs) still had the same value for the name property which is "Google". Smart Identification mechanism next includes the "title" property as well. QTP still sees that both objects have the same title property value "Google". Next the Smart Identification mechanism includes the openurl property and tries to filter and now QTP sees that the first tab had the openurl value of "about:blank". If you noticed, the openurl or the value you see at the address bar when you clicked on the new tab was "about:Tabs". Since we have now got a unique object, QTP is able to perform the operation and the Smart Identification Mechanism will ignore all the other Optional Filter Properties. Observe above that I have mentioned that "Smart Identification mechanism includes the .... property" . So the previous properties would also be present along with the newly included property for the filtering.
But we didnt see any name, title or openurl property in the local object repository, right ? Then how did QTP know this ? Try clicking on the + sign in the object repository.

So why was this not shown ? Thats because QTP didnt need it earlier but now it needed it when it kicked in the Smart Identification AND SO this is one of the main reason that Smart Identification may not be something that you would want to enable !! Oh my God...did I just say that ? Well yes, its because when you enable Smart Identification, you never know which property QTP is going to use to "smartly" detect the object. Your test script could end up entering values in the wrong field or testing the wrong object just because QTP "smartly" identified your object. So though this technique may be considered a good feature in some cases, I have never enabled this to True as it gives me more control on my test because if an object was unable to be identified I would like to know why it was not identified. If I enabled this, I would just ignore the results and assume everything went well. Believe me, I have gone through this a couple of times. However as I have mentioned earlier also, a feature is always good to have. You never know when you will need it.

Hope this example helped you in understanding this concept. Suggestions are always welcome.

I dont want to have any sort of copyright or copyleft in this site but if you are reusing this code in any other site, I would appreciate you to provide this page as a link so that others get a more descriptive explanation of this concept. Your suggestion and comments are always welcome. Cheers !!!
As always,
Your friend in need,

George, Reju

Read Users' Comments (0)

Load actions dynamically in QTP 10 using LoadAndRunAction


So here we have a new feature in QTP 10. We can load actions dynamically at run time in QTP 10 instead of associating all the actions in the main test script. This is accomplished with the statement LoadAndRunAction, a new feature introduced in QTP 10.
But first of all, lets back up a little. Until version 9.5, you only had one option if you wanted to call external actions in a main action. Of course, you would have to use the RunAction statement but you also had to include the action in your script


Now QTP 10 provides the feature where you can avoid the insertion step by simply calling LoadAndRunAction and provide the test name and action name as mandatory arguments. You can optionally also pass the iteration and parameters arguments.

Looks good ... Ya sure.... but wait !!! There is a cost associated to this - the cost of performance !!! Yes... here is an example. I wrote 5 actions and called them Test1 through Test5. These actions had just one statement like Print "In ". So each action had Print "In Test1", Print "In Test2" etc...

Next, I created two main scripts. The first main script had all the 5 actions already loaded.


The second main action made use of the LoadAndRunAction statement and so did not have the actions loaded already.


Ok... so we are all ready now. I ran both these scripts multiple times just to get an average performance. So here is the result...
The script which already had the actions loaded took an average time of 0.6 seconds for the complete execution and each action took on an average 0.12 seconds to complete the individual execution.
The script which made use of the LoadAndRunAction statement took an average time of 1.2 seconds for the complete execution and each action took an average 0.24 seconds to complete the individual execution.
Understand that this is a very small script and we see that the script using LoadAndRunAction took double the time to execute when compared to the actions that were already loaded. Also the QTP documentation also clearly mentions this "Run performance can be affected because the action is loaded and run during the run session (and not when the test is opened)."
So my suggestion is use this statement only if you are absolutely sure that you do need it and you are not affecting the performance of your test.

Nonetheless, its always good to have new utilities.. you never know when you would need them !!!
I dont want to have any sort of copyright or copyleft in this site but if you are reusing this code in any other site, I would appreciate you to provide this page as a link so that others get a more descriptive explanation of this concept. Your suggestion and comments are always welcome. Cheers !!!
As always,
Your friend in need,

George, Reju

Read Users' Comments (2)

Visitors

Website Counter