Encrypting a String in QTP

Encrypting a String in QTP

Hi All,

Here we go !!!!

QTP has an utility Object called as "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.

Way1:
syntax : Crypt.Encrypt(Your String)An example:
str="ExpertQTP"
var=Crypt.Encrypt(str)
msgbox var

The output of the above code would be "4ac6e9ba26cad2886bf331a767bfa1ce055f68e66bed5d61"
As you can see, this string is encrypted which is quite obvious.
Note:
Recording on password protected fields automatically encrypts your string for example

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

Way2:
Another way , how we can encrypt a string is by using "Mercury.Encrypter"Set var=CreateObject("Mercury.Encrypter")
Msgbox var.Encrypt("QTP")
Set var=Nothing 'Release the Object reference

Way3:
Using "Password Encoder".
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.

Wednesday, October 21, 2009

Count number of lines in Text File

Hi ,
Here I am provding the code for finding the number of lines in a Text file.
Code :
Const ForReading = 1
Set fso = CreateObject( "Scripting.FileSystemObject" )
Set textFile = fso.OpenTextFile( "your file path "
, ForReading )
textFile.ReadAll
Print "Number of lines: " & textFile.Line

textFile.Close

Thursday, September 17, 2009

Creating MS Word document using QTP

Hi ,
Let us create a very simple document in MS Word using the script.
Check the below script:
Dim obj_MSWord
Set obj_MSWord = CreateObject("Word.Application")obj_MSWord.Documents.Add
obj_MSWord.Selection.TypeText "This is a simple text"
obj_MSWord.ActiveDocument.SaveAs "D:\qtpkingblogspot.doc"
obj_MSWord.Quit
Set obj_MSWord=Nothing

Monday, June 29, 2009

Create TABLE in MS ACCESS Database thru script

Hi All,
Here i am providing the way of creating the table in MS Access database.
Script:
Set oConn = CreateObject( "ADODB.Connection" )
oConn.Open "QT_Flight32"
oConn.Execute "CREATE TABLE EventTable(" & _ "EventKey COUNTER ," & _ "Category TEXT(50) ," & _ "ComputerName TEXT(50) ," & _ "EventCode INTEGER ," & _ "RecordNumber INTEGER ," & _ "SourceName TEXT(50) ," & _ "TimeWritten DATETIME ," & _ "UserName TEXT(50) ," & _ "EventType TEXT(50) ," & _ "Logfile TEXT(50) ," & _ "Message MEMO)"

oConn.Close




Output:

Sunday, May 24, 2009

Script for Highlighting the Objects

Hi All,

Hope most of you people might be knowing how to highlight an Object in Object Repository using "Highlight in Application" button.
Here i am providing a way of Highlighting the Objects of specific Class programmatically(thru script).

' script :
systemutil.Run "http://www.qtpking.blogspot.com/"
Dim obj Set obj=Description.Create
obj("micclass").value="Link"
Set x=browser("QTP for you ...").Page("QTP for you ...").ChildObjects(obj)
For i=0 to x.count-1
x(i).highlight
Next


'Note: Add 'Page' object into Obj.Repo. before execution
Just execute the above script & watch the output.....:)

Sunday, March 22, 2009

Self Closing Message Box

Hi All,
As we all know that manual intervention is mandatory when we are using message boxes.
Until & unless we click "OK" messagebox will not closed.

Here i am providing a function through which mesage box closes automatically (without manual intervention)

' Function Defination
Function Selfclose_msgbox(msgboxtitle,boxcontent)
Dim x,y
Set x=CreateObject("WScript.Shell")
y=x.popup(boxcontent,2,msgboxtitle,4+32)
Set x=Nothing
Set y=Nothing
End Function

' Function Declaration/Calling :
Call Selfclose_msgbox("country Name","which country you are from")

Output will be :





This message box will be closed in 2 seconds automatically.

Export QTP Result Reports into PDF

Hi All ,


Here iam providing a way for exporting QTP results into PDF.



QTP 9.x and earlier versions provides the native support for exporting your test results to HTML. What will you do if you need to export it in a pdf format?Solution for exporting our results to PDF format:

1. Download PDF Creator (http://www.download.com/PrimoPDF/3000-10743_4-10264577.html?part=dl-10264577&subj=dl&tag=button) from PrimoPDF (http://www.primopdf.com/)
2. Run the set up program, follow the instructions on the screen and install Primo PDF creator.
3. PrimoPDF is installed and can be accessible from File > Print (printer) option Menu.
4. Click OK and you will get this screen.
5. Select the radio button "EBook". Use Save As button to save the pdf in your desired location. Click OK
6. Your report in pdf format is ready.

Have a nice day...

Monday, March 16, 2009

Send Keyboard Input to Application

Hi All,

Sending Keyboard Input to an Application :
1st Way:
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")

WshShell.Run "calc.exe"
WshShell.AppActivate "Calculator"
WshShell.SendKeys "1{*}"
Wait (3)
WshShell.SendKeys "2"
wait(3)
WshShell.SendKeys "~"
wait(3)
WshShell.SendKeys "*3"
wait(3)
WshShell.SendKeys "~"
wait(3)

2nd way:
For i=1 to datatable.GetRowCount
datatable.SetCurrentRow(i)
window("Notepad").WinEditor("Edit").Type datatable("text",1)
Next

3rd Way:
Use Mercury Device Replay feature
The Device Replay feature is used to perform mouse and keyboard actions against screen co-ordinates that are provided. The Device Replay functions are not automatically recorded, but must be programmed manually in the Expert View.
Create the Device Replay Object.
Call the desired Device Replay function.
When done with the Device Replay object, release it.

Example:
Set ws=createObject("Wscript.Shell")
ws.Run "Notepad.exe"
Set obj = CreateObject("Mercury.DeviceReplay")
Window("Text:=Untitled - Notepad").Activate
obj.PressKey 63

The PressKey method uses the ASCII value for the key.
63 is the ASCII value for F5.
ASCII values for other keys:
F1 - 59
F2 - 60
F3 - 61
F4 - 62
F5 - 63
F6 - 64
F7 - 65
F8 - 66
F9 - 67
F10 - 68
F11 - 87
F12 - 88

Thursday, March 12, 2009

QTP 9.5 & 10.0 New Features

Hi Folks,
Here iam providing the new features implemented in following QTP 9.5,10.0 versions.
QTP 9.5 New Features:
1) Process Guidance Panes
2) Missing Resources Pane
3) Test Flow Pane
4) Understanding the Resources Pane
5) Running Tests with the Maintenance Run Wizard
6) Available Keywords Pane
QTP 10.0 New Features :
1)Centrally Manage, Share Testing Assets, Dependencies & Versions in QC 10.00
2) Improve Portability by Saving Copies of Tests Together with Their Resource Files
3) Develop Your Own Bitmap Checkpoint Comparison Algorithm
4) Centrally Manage Your Work Items and ToDo Tasks in the To Do Pane
5) Improve Test Results Analysis with New Reporting Functionality
6) Test Standard and Custom Delphi Objects Using the Delphi Add-in and Delphi Add-in Extensibility

Have a nice day Folks.......






Sunday, February 22, 2009

Get Column Count,Col names of DataTable

HI All,
Here i am posting the ways of retreiving the column count & column names used in datasheets of datatable.
Implement the given ways accordingly........Have a Nice day.

'**************************************
To Retrieve the Column count Data Table :
'**************************************
Syntax :
Col_count= Datatable.GetSheet("SheetName").GetParameterCount
Example1:
Col_count= Datatable.GetSheet("Action1").GetParameterCount
msgbox "No. of columns used in "&Environment("ActionName")&" are : " &Col_count
'*****************************************
To Retrieve the Column Names of Data Table :
'*****************************************
Syntax :
Datatable.GetSheet("SheetName").GetParameter(Column Number).Name
Example1 :
Col_Name=Datatable.GetSheet("Action1").GetParameter(1).Name
msgbox " Column name is : "&Col_Name

Create List Box in VB script

Hi All,
JUST COPY PASTE BELLOW CODE IN QTP AND EXECUTE ....
Function Create_List_Dialog(Title, message, List)
On Error Resume Next
msg = message
for i = lbound(List) to ubound (List)
newmess = msg & vbCrLf & cstr(i + 1) & " - " & List(i)
msg = newmess
next
flag = 0
do while flag = 0
Ret = InputBox(msg,Title,"1")
Ret = CInt(Ret)
Create_List_Dialog = List(Ret-1)
flag = 1
If Create_List_Dialog = "" Then
flag = 1
End if
Loop
End Function

'USAGE of the above code:
domains = Array("Yahoo Mail","G Mail","Rediff Mail","Hot Mail","Sify Mail","EXITFROMTEST")
OUTPUT = Create_List_Dialog("MAIL LOGIN", "SELECT APPLICATION", domains)
msgbox OUTPUT
'Find the Output of the above code:

No comments:

Post a Comment