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

Thursday, October 22, 2009

QTP Tip: Deselect all radio buttons

Yesterday I got an email from one of my esteemed readers who asked "Is there any way to deselect all radio buttons using HP QTP?" I thought why one would do that but since it has been asked, it has to be answered.

Before answering the above question let me explain that, radio buttons work in groups unlike checkboxes. It means, in a group only a single radio button can be selected. Afterwards, its not possible to deselect all radio buttons in that group. Even manually it can not be done.

Inititally the task seems impossible but its not :)

It is definitely possible to deselect all radio buttons using QTP but it can only be achieved with the help of Document Object Model or DOM.

The QTP Script for the same goes here:

Set Obj = Browser("Google").Page("Google").object.getElementsByTagName("INPUT")

For each RadioBtn in Obj
If lcase(RadioBtn.type) = "radio" Then RadioBtn.checked = False
Next

To know more about the Document Object Model in QTP, see here : http://msdn.microsoft.com/en-us/library/ms533043(VS.85).aspx

Also read about the Object property in WebRadioGroup Object in QTP help for more information.

Note:

Document Object model is supported by Internet Explorer browser only & not for Firefox as the underlying COM technology is not supported by Firefox. Hence, for Firefox browser, QTP will not be able to access the radio buttons using Document Object Model.

Also working with Document Object Model inside HP Quicktest Professional is faster in terms of performance as no object identification is involved.




Read more...


Sunday, October 4, 2009

QTP: Adding Hyperlinks in Excel Spreadsheet

I was playing with the excel application along with QTP when suddenly I thought of adding a hyperlink inside an Excel spreadsheet from Quicktest. Task seemed a bit tricky initially but I took up the challenge and finally created a script.

The QTP script to accomplish the same goes here:

'Create an object reference to Excel. Also you can see "Excel.exe" 'process gets created in the Task Manager
Set objExcel = CreateObject("Excel.Application")

'Make the invisible Excel application visible
objExcel.Visible = True

'Add a workbook to the blank excel sheet
Set objWorkbook = objExcel.Workbooks.Add

'Get the handle of first sheet
Set objWorksheet = objWorkbook.Worksheets(1)

'Enter the value in A1 cell inside your first worksheet
objWorksheet.Cells(1, 1) = "QTP Expert"

'Create a range encompassing only the single cell A1
Set objRange = objExcel.Range("A1")

'Add a hyperlink to that range. Here range is only a single 'cell so hyperlink would be created
Set objLink = objWorksheet.Hyperlinks.Add _
(objRange, "http://www.quicktesthp.blogspot.com")

________________________________________________________________
If you like this Article, I would suggest you to subscribe my RSS feed. This way you will get all new future articles directly into your mailbox.
________________________________________________________________


Read more...


Saturday, October 3, 2009

HP QTP Crypt Object

As the name implies, the "Crypt" object in HP Quicktest Professional is for encrypting the strings which can only be understood by QTP's "SetSecure" method. "Encrypt" is the only method supported by the QTP "Crypt" object.

The syntax is:

Crypt.Encrypt(Your String)

An example for the same would be:

'The string "ExpertQTP" would be encrypted

var=Crypt.Encrypt("ExpertQTP") msgbox var

The output of the above code would be "4ac6e9ba26cad2886bf331a767bfa1ce055f68e66bed5d61". As you can see, this string is encrypted which cant be understood by anyone.

Please Note: Recording on password protected fields automatically encrypts your string for example

Browser("micclass:=Browser").Page("micclass:=Page").
WebEdit("name:=Password").SetSecure "4ac6e9ba26cad2886bf331a767bfa1ce055f68e66bed5d61"


Now lets see how to decrypt our string. Sounds Interesting.. Alright!! Lets read more.

Open your Internet Explorer browser and navigate to Google homepage. Copy and paste the below mentioned script in your QTP editor and run it.

Browser("micclass:=Browser").Page("micclass:=Page").
WebEdit("name:=q").
SetSecure "4ac6e9ba26cad2886bf331a767bfa1ce055f68e66bed5d61"

The output of the above code would be:

As you can see, you can even use SetSecure method on non password fields as well.

Another example of Crypt usage would be to create a function inside a Library and call inside your QTP Script.

pwd="QTPExpert"
Print Crypt_Func(pwd)

'The below function is there in the Library

Function Crypt_Func(password)
Crypt_Func=Crypt.Encrypt(password)
End Function

I am going to present you another example how we can encrypt a string: Using "Mercury.Encrypter"

Set var=CreateObject("Mercury.Encrypter")
Msgbox var.Encrypt("QTP")
Set var=Nothing 'Release the Object reference

Do you think of any other method or Utility to encrypt Strings? If your answer is No, then let me tell you there is a small utility program provided by QTP for encrypting strings. Its "Password Encoder".

How do I access this "Password Encoder" now? Thats simple!!
Navigate to Start-> All Programs-> QuickTest Professional-> Tools-> Password Encoder

Provide your string inside the "Password" field and click on the Generate button. Your encrypted string would be displayed inside the "Encoded String" field.

________________________________________________________________
If you like this Article, I would suggest you to subscribe my RSS feed. This way you will get all new future articles directly into your mailbox.
________________________________________________________________


Read more...


 
Copyright © 2009 ExpertQTP