SendKeys Syntax to Send Enter or Return

In Selenium IDE to input an Enter Key stroke into an element like a text box I used the format ${KEYS_ENTER}. This does not function in Katalon Automation Browser. I use SendKeys for the text I want to type followed by the above format. The Text without the KEYS command is entered but the keystroke is not executed.

I have tried the Keys.ENTER format that works in Katalon Studio, as bare text and wrapped with ${}. Both are added as text to the target.

As I work my way through implementing tests I had run previously in Selenium IDE I gain appreciation for the work put into this project. Thanks for your efforts.

2 Likes

yeees =) need at least storeEval - Command for Variables.

More information about how SendKeys for Keypress events were handled in Selenium IDE. Does Katolon Automation Recorder offer similar functionality? If not any plans to include something like this ? http://www.testingdiaries.com/selenium-ide-keypress-events/

With further testing I found this is only affecting a small subset of SendKeys key variables (KEY_ENTER, KEY_TAB, KEY_SPACE) in some AJAX components provided by Dev Express using the Chrome version of the Katalon Automation Recorder.

Using the Katalon Automation Recorder for Firefox and the same Test Suite, the ${KEY_ENTER} is being recognized. This as of the release on 11/28.

Hi. Thank you for the feedback. We’ve released version 3.4.7 with support for “sendKeys | css= | ${a single special key}” on Chrome. Please use CSS locator for these cases.

I want to inform that the CSS locator limitation has been removed. From now on you can use for example “sendKeys | | ${KEY_ENTER}” to press Enter key in Chrome.

SendKeys (locator) Keys.chord(Keys.ENTER) try this

These solutions do not work for me. I can trigger the blur event by:

    sendKeys | locator | ${KEY_ENTER}

which fires my ajax javascript correctly BUT a new tab is opened in Chrome displaying the Settings for Chrome and focus is set to the tab.

Any advice would be appreciated.

Apologies - I meant it takes me to the help page for settings, i.e.:

chrome://settings/help

Apologies 2! I have localised the problem to be the invocation on the previous step of a user extension I wrote to enter a day in the future as a date:

Selenium.prototype.doTypeTodayPlusDays = function(locator, text) {
    // All locator-strategies are automatically handled by "findElement"
    var element = this.page().findElement(locator);
    var today = new Date();
    var inDays = today.addDays(parseInt(text));
    var options = { day: 'numeric', month: 'short', year: 'numeric' };
    // Create the text to type
    var valueToType = inDays.toLocaleDateString("en-GB",options);
 
    // Replace the element text with the new text
    this.page().replaceText(element, valueToType);
};

Invoked as follows:

TypeTodayPlusDays | locator | 2

I appreciate that this is less of an issue to do with send keys and more a nuance of how user extensions work.

If I enter the date manually it seems to work correctly.

I have found a solution which is to invoke a javascript function directly in the value field:

type | locator | javascript{todayPlusDays(10)}

with a suitable modification to the function described earlier to make it a simple helper function rather than adding to the prototype.

I still do not understand why the prototype version did not work but I am happy to be moving forward:-)

1 Like

So I’ve had a similar problem here and could use some help. I’m using Chrome 66 and trying to get ${KEY_ENTER} to work. My tests say that KEY_ENTER was pressed, but the log is showing something different.

My request looks like:
sendKeys | | ${KEY_ENTER}

The log, however, looks like:
[info] Expand variable ‘${KEY_ENTER}’ into '’

Any idea what that null part would be? I know I’ve got my locator correct, I’m just having a hell of a time getting the KEY_ENTER event to fire.

1 Like

@Justin Hooks Did you get sorted? I have just encountered the same issue as you

any updates for this issue?

Hi, thank you for this powerful tool and your work.

I’m new in working with KAR (Chrome) and have a similiar issue. I have a textfield that need to perform a submit by pressing enter after the input to trigger a class (no other way accepted). I tried (besides two other threads from this forum) all syntax examples, changing value with target, tried to run it as a script, added “selenium-common-2.0a4”… however, the ${KEY_ENTER} don’t performs a submit. same thing happens with click command, it performs but don’t toggle the textfield how it would be better for following executes. Keys were send, but nothing happened. What do I don’t understand or how to execute the commands like real manuel actions? I’m talking about this:

<input onclick="$(this).class(‘x’,‘x’);/*function();*/return false;“a lot atttributs”>

regards

Justin Hooks said:

So I’ve had a similar problem here and could use some help. I’m using Chrome 66 and trying to get ${KEY_ENTER} to work. My tests say that KEY_ENTER was pressed, but the log is showing something different.

My request looks like:
sendKeys | | ${KEY_ENTER}

The log, however, looks like:
[info] Expand variable ‘${KEY_ENTER}’ into '’

Any idea what that null part would be? I know I’ve got my locator correct, I’m just having a hell of a time getting the KEY_ENTER event to fire.

I am facing the same issue:

commands:

log:

and Katalon Recorder does not press Enter. How can I solve the issue? Do I have to store KEY_ENTER first via storeEval? What is the step by step process? Thanks.

1.png

2.png

Erdem Uygun said:

Justin Hooks said:

So I’ve had a similar problem here and could use some help. I’m using Chrome 66 and trying to get ${KEY_ENTER} to work. My tests say that KEY_ENTER was pressed, but the log is showing something different.

My request looks like:
sendKeys | | ${KEY_ENTER}

The log, however, looks like:
[info] Expand variable ‘${KEY_ENTER}’ into '’

Any idea what that null part would be? I know I’ve got my locator correct, I’m just having a hell of a time getting the KEY_ENTER event to fire.

I am facing the same issue:

commands:

log:

and Katalon Recorder does not press Enter. How can I solve the issue? Do I have to store KEY_ENTER first via storeEval? What is the step by step process? Thanks.

What I found is that Google Chrome (Linux and Windows versions) does not recognize sendkeys command, but Firefox does. On the other hand, Google Chrome recognizes file upload, but Firefox can’t, I am really stucked at that point as I need both functions in one browser.

It is sad that there is no update for that issue

2 Likes

Any update on the issue in chrome? I am getting [] in chrome when passing enter key

1 Like

Having the same issue, can’t simulate hitting the enter key with Katalon Recorder — really limiting usefulness, which also impacts the ability to promote KDE internally.