Ad Home

Theme images by kelvinjay. Powered by Blogger.

Travel

Header Ads

Java

Selenium

UFT

Framework

General QA Concept

BDD

» » » How To Use Sendkey Function in QTP or VBScript

Sendkey-- the term says us that this is related to some key which need to be sent..Now Questions are where ?? when?? how??
Consider a scenario when you need to delete few things from your drive or you need to select all the files or you need to take a screenshot automatically through scripting.
There might be scenario where QTP fails to record a step and still you need to automate that scenario.


How do you do through manually...yes by keying Delete key or Alt+A or by pressing PrtSc.
Right Now if the same has to done through QTP ,we need to educate QTP regarding the same..Well, most of the time ,we need to use sendkey function while doing an end to end Testing...I am not going in depth of idea...lets go directly to the point...I am incorporating some basic codes which can be used..

Lets check out how to write small function that do our work...




Sub ctrlA()
//This is for Ctrl+a command
set WshShell = CreateObject("WScript.Shell")
WshShell.Sendkeys "^"+"{a}"
set WshShell = Nothing
End Sub


Let's see some more example...


Sub shiftDel()
//this is for Shift delete command
set WshShell = CreateObject("WScript.Shell")
WshShell.Sendkeys "+"+"{DEL}"
set WshShell = Nothing
End Sub


Yes you got the idea right....Now u need the list of all keys which can be send during the runtime.
Click on the link:http://msdn.microsoft.com/en-us/library/8c6yea83(VS.85).aspx
to get the list of all keys that can be send.


Happy sending..:)

«
Next
Newer Post
»
Previous
Older Post

No comments:

Leave a Reply