How to emulate a Ctrl + (keystroke) in AJAX TruClient

  • KM00470352
  • 08-Jul-2013
  • 31-Oct-2013

Summary

How to emulate a Ctrl + (keystroke) in AJAX TruClient

Question

How to emulate a Ctrl + (keystroke) in AJAX TruClient

Answer

You can replace the keypress step with a generic object action, change the step action to evaluate javascript and paste the code below in the step arguments. In this case we are using G as key stroke as shown charCode, replace this with the needed keystroke.

var Ci = Components.interfaces;
var keyCode = 0, charCode = 0, modifiers = 0;
modifiers
= Ci.nsIDOMNSEvent.CONTROL_MASK;
charCode = 'g'.charCodeAt(0);
var utils = this.object.ownerDocument.defaultView.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
utils.sendKeyEvent("keypress", 71, charCode, modifiers, true);

image text