Record enter key in web browser testing

LegacyForumLegacyForum Posts: 1,669 ✭✭
edited December 2016 in SOAtest
Here are the instructions to capture ENTER key in web browser testing

First, add the ability to play back pressing the ENTER key.

(1) Close SOAtest if it's open
(2) There are two copies of UserCustomizableOptions.js files - one for IE and one for Firefox - located under
<SOAtest Installation Directory>/plugins/com.parasoft.xtest.libs.web_VERSION#/root/browsers/ie
<SOAtest Installation Directory>/plugins/com.parasoft.xtest.libs.web_VERSION#/root/browsers/ff/extensions/[email protected]/chrome/content

where VERSION# refers to SOAtest version (ex: 6.2)

Add the following snippet at the beginning of UserCustomizableOptions.js file
_wk_BrowserDriver.prototype.doEnterKey = function(locator) {
var element = this.findElement(locator);
if (_wk_browserVersion.isIE) {
  _wk_HTMLUtil._nativeTypeChar(element, "\r", 0);
} else {
  _wk_HTMLUtil.triggerKeyEvent(element, "keydown", 13, true);
  _wk_HTMLUtil.triggerKeyEvent(element, "keyup", 13, true);
  _wk_HTMLUtil.triggerKeyEvent(element, "keypress", 13, true);

Now you can manually add tests to simulate pressing the ENTER key. However, usually you will not need to do so. SOAtest does not create a user action to press the ENTER key during recording. Rather, if you hit the ENTER key which is identical to clicking on a button, SOAtest will generate a test that clicks on the button. If there is no button but pressing ENTER submits the form (you must press the ENTER key when the focus is on an element within a <form>) then SOAtest records a Submit action. If SOAtest could not generate either a Click or a Submit action, then you will need to manually add a test to simulate pressing the ENTER key.

To manually add a test to press the ENTER key.

(1) Open up SOAtest.
(2) Right-click on the scenario into which you want to add the user action for pressing the ENTER key.
(3) From the context menu (right-click menu), choose Add New > Test... > Standard Test > Browser Testing Tool.
(4) SOAtest adds the new test to the end of the scenario. Drag and drop the new browser test into the desired position.
(5) Open the new browser test.
(6) Change to the User Action tab.
(7) Select "Other" in the "Action:" dropdown.
(8) For the "Action" text box, type EnterKey.
(9) Switch to the Pre-Action Browser Contents tab. Right-click on the element you want to have focus when you press the ENTER key and choose to Modify User Action to Use <tag> Element. Alternatively, you can manually create the element locator in the User Action tab.

When you play back the scenario, SOAtest will simulate pressing the ENTER key on the desired element.
Sign In or Register to comment.