Easy ways to use the keyboard in QTP(QuickTest Professional): Typing and navigating app using keyboard keys


Hi. Today I will show you how to type and use the keyboard controls with QTP/UFT. This comes handy for various applications that don't work with standard QTP/UFT methods.

Follow the steps below:

1. Click Here. This will take you to the automation practice page.

2. Scroll down until you see the "Successfully fill out this form" form field

3. Copy and paste the following code in your script. It will click on the email sign up text field of this form. Browser("Index:=1").Page("title:=.*").WebEdit("html id:=et_pb_signup_firstname").Click

4. We will now use the keyboard keys function to fill out the form. Copy the function below and paste it in your script.

Sub fun_TypeKeyboardKeys(strKeyboardKeys)
Dim wShShell,i
Set wShShell = CreateObject("Wscript.shell")
wShShell.sendkeys strKeyboardKeys
Set wShShell = Nothing
End Sub

5. You can now call the function as in the example below. Just make sure to click on the email field first so QTP knows where to start filling out the form.

Browser("Index:=1").Page("title:=.*").WebEdit("html id:=et_pb_signup_firstname").Click

fun_TypeKeyboardKeys "Test User"
fun_TypeKeyboardKeys "{TAB}"
fun_TypeKeyboardKeys "qtptutorial.net@gmail.com"
fun_TypeKeyboardKeys "{TAB}"
fun_TypeKeyboardKeys "{ENTER}"

The first line enters the name. The second line tabs over to the next field. The third line enters the email. Then we tab over to the Sign Up button. Finally, we submit the form by click enter on the keyboard. Really cool right?

Leave your comments and questions below! We love all of your feedback!!


Pin It on Pinterest

Clef two-factor authentication