Three UFT/QTP Input Methods

There are three ways to use keyboard input in QuickTest Professional and Unified Functional Testing: Type, SendKeys and Device Replay. Why, you might ask, use the Type or Sendkeys method at all? While you wouldn’t want to automate a whole script using SendKeys only, sometimes you may, on occasion, need to automate a section of an application where there is no object recognition.

For example, some unsupported grids or tree views in Quick Test Pro can be navigated using a combination of the HOME, END and arrow keys. Also — I’ve seen applications where some fields need to have a keyboard event occur to trigger some other behavior (like tabbing of a field) using the objects standard Set method –- which would not work in this case.

1. QTP’s TYPE METHOD

Most objects support the TYPE method. Type will enter the specified string into an object or perform a certain keyboard combination against an application. For example:

To tab off an object you would use the following syntax:

SwfObject(“swfname:=Blank”).Type micTab

To enter text:

SwfObject(“swfname:=Blank”).Type “This is my string”

To send an enter keystroke:

SwfObject(“swfname:=Blank”).Type “ “

You can also send a combination of keystrokes at one time. The following holds down the CTRL and the Shift Keys, then presses the “L” key and releases the CTRL and Shift keys:

*Important to remember: If you send a down keystroke, be sure to follow it with its corresponding up stroke, as seen in the above example. Problems can arise by sending a micCtrlDwn and forgetting to release it using micCtrlUp. So, rule of thumb — if you are pressing a key, make sure to also release it.

Also Occasionally you may have issues with event not being triggered when using one of these methods. In that case check out my post of how to use the FireEvent method.

There are instances in which QTP’s Type method does not trigger certain events, or is unable to mimic certain keystrokes. In these cases, VBScript SendKeys method can be used. To use the SendKeys you need to first set the WshShell object:

*A few important tips: Unlike the QTP TYPE method, you will need to use curly braces for arguments like a TAB or Up arrow key strokes. Also — SendKeys has the following special characters: Alt(%), Ctrl(^), Shift(+) and Enter(~) keys.

So, to send a CTRL and press the A key you would send:

mySendKeys.SendKeys("^A")

If you need to perform the same keystroke multiple times, you can create a compound string argument. This will allow you to perform a specific keystroke and repeat it any number of times. To select, say, the 10th row in a grid control you might use:

Leave a reply:

Farhana Ashraf » Sorry not sure why this is happening. What happens if you do a quick QTP record against the object does QTP recognize it? Also Here are some additional points to keep in mind when working with Mozilla Firefox:

You must be logged-in with Administrator privileges (or have write permissions to the browser’s installation folder) on the QuickTest Professional computer when launching Mozilla Firefox with QuickTest Professional for the first time. Adding QuickTest Professional support for Mozilla Firefox requires a file to be created in the browser’s installation folder.

You can record tests on Microsoft Internet Explorer and run them on Mozilla Firefox. You cannot record tests on Mozilla Firefox if using versions lower than QuickTest 11, for which there are two ways to create tests to run on Mozilla Firefox on such lower versions:

Record the test on Microsoft Internet Explorer. Use the keyword-driven methodology: create an object repository for your application using the Object Repository window (local object repository) or Object Repository Manager (shared object repository), and then add steps using the Keyword View or Step Generator. When you use the keyword-driven methodology, you can add objects using Mozilla Firefox if you want; you do not have to use Microsoft Internet Explorer.

Tabbed browsing is not supported by QuickTest Professional for any browser type. In Mozilla Firefox, you must specifically configure your browser to open a new browser window instead of a new tab. This configuration is dependent on the nature of your application and therefore configuration instructions are not provided. In most cases, you can add objects to the object repository and run tests on the active browser tab, even if there are additional tabs currently open.

Leave a reply:

I have Q I am working on hotkeys on web application with QTP 10, IE 6. My Code works in IE 6, but not working in IE6. I get error “Object is not supported …. Here is the snippent of the code.. what could be wrong… Set WshShell = CreateObject(“WScript.Shell”) vhwnd=Browser(“Main Browser”).GetROProperty(“hwnd”) Window(“hwnd:=”&vhwnd).activate —– This is where it is giving error WshShell.SendKeys “%1”

Leave a reply:

Hi Joe, thank you for the great website. Super helpful. I’m wondering if you can help answering my question. Is there a way to limit the duration QTP click on a button? (Kim’s question is on holding sendkeys for 3 secs, mine is kind of the opposite). So I have the following code: JavaWindow(“API GUI”).JavaList(“LBS:”).Select “basic” JavaWindow(“API GUI”).JavaButton(“Submit”).Click

When QTP’s executing Submit code, it seems to be holding down the Submit button for too long, ends up mimicking a second click on the button after getting a response back.

Leave a reply:

Anita » Hi Anita – that is some odd behavior. I’m not aware of any setting in QTP that limits the amount of time a click is performed on a button. What happens if you use the fireevent instead to do the click? Does it behave the same way?

Leave a reply:

Leave a reply:

Hi Joe, FireEvent for Java seems to have micMouseClick vs. “onclick” or “ondblclick”. Syntax for it is: object.FireEvent EventType, EventArguments() where EventType is micMouseClick and EventArguments is: (per Help) Required. An array of Variant values. Any parameters of the event’s constructor except for the source and EventID. You can pass any Java constant that is used as one of the event’s constructor parameters using its string instead of its value. Enter the values in a comma separated list. If no additional parameters are required, you do not need to supply a value for the EventArguments argument.

I don’t understand what it means or how to use this eventArguments. I tried the below and it doesn’t work :( JavaWindow(“WPP for HLAPIs v1.3:_2”).JavaList(“LBS:”).Select “basic” JavaWindow(“WPP for HLAPIs v1.3:_2”).JavaButton(“Submit”).FireEvent micMouseClick, 0

Would you be able to explain a bit more on how to use FireEvent with micMouseClick? thanks!

Leave a reply:

Leave a reply:

Anita » Sorry I assumed the java fireevent would be the same as a web objects fireevent — I’m not sure what the exact event arguments should be. I need to research it. In the meantime how about trying JavaButton.Object.doClick() instead of FireEvent. For example:

Leave a reply:

Thanks Joe! It works with Object.doClick(). Out of curiosity, what’s QTP doing differently between JavaWindow(“WPP for HLAPIs v1.3:_2″).JavaButton(“Submit”).Object.doClick() and JavaWindow(“WPP for HLAPIs v1.3:_2″).JavaButton(“Submit”).Click ?

Leave a reply:

Dear Joe, I try to set data in webedit field but it gets cleared after tabout to next object. Tried with sendkeys, type, Device replay. but no luck. could you please provide solution below url http://www.mscgva.ch/schedule.html while entering Port of Load and Port of discharge

Leave a reply:

Ganesh Kodali » Hi Ganesh – what data are you using for Port of Load and Port of discharge? This looks like a web application issue not a QTP issue. Make sure you are using valid data. When I manually enter bogus port names the text is cleared but if I enter a valid port like KANDLA,INDIA it works for me.

Leave a reply:

Hi Joe No doubt I am using correct data, but Web application works only with data fetched. If I enter Chennai application fetches “CHENNAI, INDIA (INMAA)” , should be selected and then proceed to next Singapore application fetches “SINGAPORE, SINGAPORE (SGSIN)” finally to click search Using QTP tried with webedit, sendkeys, type, Device replay to set data directly as “CHENNAI, INDIA (INMAA)”, “SINGAPORE, SINGAPORE (SGSIN)” it displays Please enter Port of loading or Port of discharge.http://www.mscgva.ch/schedule.html Here issue is with web application its not straight forward for us to handle. Is there any tricky solution to handle. Whatever we do manually should be able to do using QTP.

Leave a reply:

Hi Joe, Thanks for creating an awesome website. I am trying automate a machine in which normal enter key and numpad enter key have different functions. If I record, both the enter keys show the same recorded VBScript code. Have you found out any way it can be done??

Leave a reply:

Hello Joe, When I record java application in QTP11.0 for scripting (with java addin), the right mouse click contents are not selecting, it will open the right click but it does not select the the required field. Kindly let me how to select it. And another question is in the java scripting at QTP 11.0 , the java page opening but it not recording the object in the page, like selection radio button and java button.I try to spy those two tabs but spy is identifying. Thanks

Leave a reply:

Is it possible to check which mnemonic is underlined after pressing the “Alt” key? In one of our scenarios, we need to verify whether character “b” is underlined when we press “Alt” key for a checkbox control. Any idea?

Leave a reply:

I’m not sure when you spy on the control after pressing an Alt key is there any property that changes? If so you can check for that property in your test to confirm that the Alt occurred. I don’t know if there is an ASCII character you could look for that represents an underline character. Anyone else have any suggestions?

Leave a reply:

I am writing a QTP function to send emails through Outlook 2007. I am unable to send the email programmatically using Outlook object because I am getting security Dialog Popup. Keyboard shortcut to send Email from Outlook is Alt+s. How to press Alt+s using Presskey method.

Leave a reply:

Please HELP!!!!! I’ve been using in IE8 Grid a .fireevent “ondblclick” and a .set methods to enter data in a grid. A IE had a lot of isues in many ways, we’ve migrated to Firefox 12. Trying to call the same funtion, neither the .fireevent and .Set methods worked.

Have tried several ways to set the information using:

“set mySendKey = CreateObject(“WScript.shell”) var1 = “Datatable (“parameter1”, “global”) mySendKeys.SendKeys (var1)” And “myDeviceReplay.SendString var1” without any success. In both cases the var1 is entered VERY FAST! and only remains on the object the last 3 letters of such variable. have tried one by one on a loop with “wait 1”

Leave a reply:

Hi, I am using following command :- set WshShell = CreateObject(“WScript.Shell”) WshShell.SendKeys “{ENTER}” WshShell.SendKeys “+:techstack” I observed it is not writing ‘+’ symbol, the data written by script is “:techstack” instead of “+:techstack” Please help me with this issue. Thanks, Pooja

Leave a reply:

I am using Jenkins slave and trying to run the scripts in a remote machine. I am having issue in executing the SendKeys or DeviceReplay steps (to enter data in a WebElement). There are executing only when i am logged into the Remote. Is there any other alternative?

Copyright text 2017 by Joe Colantonio/TestTalks br> br>Disclaimer All the contents of the Blog, EXCEPT FOR COMMENTS, constitute the opinion of the Author, and the Author alone; they do not represent the views and opinions of the Author’s employers, supervisors, nor do they represent the view of organizations, businesses or institutions the Author is a part of. Privacy Policy
- Designed by Thrive
Themes | Powered by WordPress