http://quicktesthp.blogspot.com

QTP VBScript new series + Interview Question Bank on QTP for enrichment of Knowledge in QTP

This Site has been brought to you by HP Certified Expert of QTP.

Exciting new articles for October:

1) QTP Tip:Deselect all Radio Buttons

2) HP QTP Crypt Object

3)Adding Hyperlinks in Excel Spreadsheet

Best of Luck Friends ! ! !

Expert QTP
expert.qtp@gmail.com

All Articles are Copyright Protected. These are Free for Reading & Personal Use. Reproduction in Any Form without the Permission is Illegal & Strictly Prohibited.

Copyright © 2009 ExpertQTP

Google Search

Friday, November 28, 2008

Ways to manipulate conventional logic of naming objects in QTP

Here I am presenting a workaround to manipulate or overriding the Naming Conventions generally assigned by QTP to the test objects.

Did you ever notice that QTP gives a random name to the objects after recording which even seems vague at times.

Let me show you an example to demonstrate my point. I tried recording on the Google home page and got this code from QTP after recording after writing some text in the Google search box:

Browser("Google").Page("Google").WebEdit("q").Set "This is the sample text"

As you can see from the above code, the name which has been assigned to the WebEdit box is "q". How many of you agree that this "q" seems a valid name? Though this "q" is the name of the search box which has been hard coded by the Google developers. I have extracted the following code from the Google’s webpage to illustrate my point:

input maxlength=2048 name=q size=55 title="Google Search" value=""

I believe that QTP doesn’t name the test objects properly. There is certainly a way by which we can instruct QTP to name the text objects as per our chosen properties.

The following are the steps for the same:

1. Close your HP QTP software.

2. Navigate to Start->Run.

3. Type "regedit" and press enter to open the Registry Editor.

4. Inside your "Registry Editor" navigate to HKEY_CURRENT_USER -> Software -> Mercury Interactive -> QuickTest Professional -> MicTest -> Test Objects.

Here, you can see so many keys like WebEdit, WebElement etc etc. Yes, you guessed right. These are in fact all the built-in keys classes of QTP. Expand any key of your choice for editing.

In this tutorial, I will select WebEdit class which is very frequently used in QTP. You will see a key named "tag query name" as highlighted in the following screenshot which has the value "logical name". You will see the same value for "tag query name" key for all the inbuilt classes.



Now double click the "tag query name" key. You will see the following screenshot. Provide any name of your choice. I provided "QTP Expert" and press enter.




Close the Registry Editor and open your HP Quicktest Professional (QTP) software. Open google.com webpage again and record again. [ Make sure you open the google webpage only after opening QTP]. You will see a code something like this:

Browser("Google").Page("Google").WebEdit("WebEdit").Set "This is the sample text "

I hope, you must have noticed the difference after tweaking the registry editor.

This technique doesn’t seem to be used too often, however it is possible to override the standard naming convention of objects through QTP by doing some minor changes in Registry Editor.

KeyWords: QTP, Quicktest, Object Naming

No comments:

 
Copyright © 2009 ExpertQTP