tags:

views:

279

answers:

2

How to record ENTER button that we use through the keyboard in QTP for applications

+2  A: 

I assume you want to replay an Enter key, in most cases when QTP does not record an action it's much better to add the step manually than trying to force QTP to record it.

If the test object in question supports Type you can use that:

Window("Calc").Type micReturn

Otherwise you can use the DeviceReplay object as described in this article

Set dr = CreateObject("Mercury.DeviceReplay")
dr.PressKey 28 ' 28 = Return (Enter)
Motti
A: 

Another option to replay an Enter button press would be to simply use the SendKeys Method of the Windows Script Host object. The code would look something like this:

Dim WshShell
Set WshShell = CreateObject("WShell.script")
WshShell.SendKeys "{ENTER}"
Set WshShell = Nothing