Tuesday, December 29, 2009

Difference Between Set and Dim

1.Dim can be used to store a value in a variable.
2.Dim is genarlly to initiate a variable

For example: Dim a
a 10

1.Set can be used to store a object or child object from AUT
eg. set a Browser(" ").Page(" ").childobject(obj)
obj is already described through descriptive programming & by using above script we can store child objects in a web page like webbutton webradio button web list link etc.
2. SET is used to assign a value to the initiated variable

Create an Action Template

To create an Action Template we have to follow below navigation
1.Open Notepad
2.Enter the details with comments
3.Save this notepad with .mst extension in C://ProgramFiles/MercuryInteractive/QTP/DAT/
4.CLick on Save with .mst extension
5.Open new script then the template should display.

Friday, May 22, 2009

For passing Shortkeys

set wsh = Createobject("Wscript.Shell")
wsh.SendKeys "{F2}"

Sending an Email

SendMail "gopve01@ca.com","hi","how r u",""

Function SendMail(SendTo, Subject, Body, Attachment)

Set ol=CreateObject("Outlook.Application")
Set Mail=ol.CreateItem(0)
Mail.to=SendTo
Mail.Subject=Subject
Mail.Body=Body
If (Attachment <> "") Then

Mail.Attachments.Add(Attachment)

End If
Mail.Send
ol.Quit
Set Mail = Nothing
Set ol = Nothing

End Function

Thursday, January 22, 2009

Locking PC after execution of Automation scripts

You can use the following QTP Script to lock your PC :

Set obj = CreateObject("WScript.Shell")
sCmnd = "%windir%\SYSTEM32\rundll32.exe user32.dll,LockWorkStation"
obj.Run sCmnd, 0, False