Key press before a QTP/UFT action.
At times there are situations where we need to hold a key (or key combination) before performing another action say click, select etc.
Here is a code example to press Alt+Ctrl+Shift before
clicking an object.
Set deviceReplay =
CreateObject("Mercury.DeviceReplay")
deviceReplay.KeyDown 29 ‘ ASCII for Ctrl key
deviceReplay.KeyDown 56 ‘ ASCII for Alt key
deviceReplay.KeyDown 29 ‘ ASCII for Ctrl key
deviceReplay.KeyDown 56 ‘ ASCII for Alt key
deviceReplay.KeyDown 42 ‘ ASCII for
SHIFT key
Browser().Page().WebElement().Click
‘ Don’t forget to release the key oterwise it will continue to be pressed.
deviceReplay.KeyUp 29
deviceReplay.KeyUp 56
deviceReplay.KeyUp 42
deviceReplay.KeyUp 42
That’s it. Happy coding!!
No comments:
Post a Comment