How to Press Enter with WebUI?

Hello, im totally new to automation and to katalon, so im sorry if this is a well known question.

So, i made a script which:

  • Open Google
  • Write anything
  • Press Enter

When pressing enter, there are hella million ways according to google to make it press enter, also found several solutions here, but none of them worked for me, here is why.

using katalon studio i was able to enter this:

WebUI.sendKeys(findTestObject(‘Tutorial/Page_Google/input_q’), Keys.chord(Keys.ENTER))

It does work, however, as soon as the enter is pressed, as example if the word to search was “car”, it appear as “Car” with that unicode character next to the search.

here:

importing it from a the katalon firefox plugin works, as i replace the $ENTER with keynativepress, but using the studio to made the script from scratch, im unable to make it press enter without that unicode character.

What is the correct way to press ENTER, if possible without specifying a selected object.

1 Like

Alex Mora said:

Hello, im totally new to automation and to katalon, so im sorry if this is a well known question.

So, i made a script which:

  • Open Google
  • Write anything
  • Press Enter

When pressing enter, there are hella million ways according to google to make it press enter, also found several solutions here, but none of them worked for me, here is why.

using katalon studio i was able to enter this:

WebUI.sendKeys(findTestObject(‘Tutorial/Page_Google/input_q’), Keys.chord(Keys.ENTER))

It does work, however, as soon as the enter is pressed, as example if the word to search was “car”, it appear as “Car” with that unicode character next to the search.

here:

importing it from a the katalon firefox plugin works, as i replace the $ENTER with keynativepress, but using the studio to made the script from scratch, im unable to make it press enter without that unicode character.

What is the correct way to press ENTER, if possible without specifying a selected object.

With java Robot class you don’t need to specify object
try:

import java.awt.Robot as Robot

import java.awt.event.KeyEvent as KeyEvent

Robot rb = new Robot()

rb.keyPress(KeyEvent.VK_ENTER)

WebUI.delay(1)

rb.keyRelease(KeyEvent.VK_ENTER)

WebUI.delay(2)

1 Like

Alex Mora said:

Hello, im totally new to automation and to katalon, so im sorry if this is a well known question.

So, i made a script which:

  • Open Google
  • Write anything
  • Press Enter

When pressing enter, there are hella million ways according to google to make it press enter, also found several solutions here, but none of them worked for me, here is why.

using katalon studio i was able to enter this:

WebUI.sendKeys(findTestObject(‘Tutorial/Page_Google/input_q’), Keys.chord(Keys.ENTER))

It does work, however, as soon as the enter is pressed, as example if the word to search was “car”, it appear as “Car” with that unicode character next to the search.

here:

importing it from a the katalon firefox plugin works, as i replace the $ENTER with keynativepress, but using the studio to made the script from scratch, im unable to make it press enter without that unicode character.

What is the correct way to press ENTER, if possible without specifying a selected object.

I wondered what that little thing was  :slight_smile:

crokatalontest said:

Alex Mora said:

Hello, im totally new to automation and to katalon, so im sorry if this is a well known question.

So, i made a script which:

  • Open Google
  • Write anything
  • Press Enter

When pressing enter, there are hella million ways according to google to make it press enter, also found several solutions here, but none of them worked for me, here is why.

using katalon studio i was able to enter this:

WebUI.sendKeys(findTestObject(‘Tutorial/Page_Google/input_q’), Keys.chord(Keys.ENTER))

It does work, however, as soon as the enter is pressed, as example if the word to search was “car”, it appear as “Car” with that unicode character next to the search.

here:

importing it from a the katalon firefox plugin works, as i replace the $ENTER with keynativepress, but using the studio to made the script from scratch, im unable to make it press enter without that unicode character.

What is the correct way to press ENTER, if possible without specifying a selected object.

With java Robot class you don’t need to specify object
try:

import java.awt.Robot as Robot

import java.awt.event.KeyEvent as KeyEvent

Robot rb = new Robot()

rb.keyPress(KeyEvent.VK_ENTER)

WebUI.delay(1)

rb.keyRelease(KeyEvent.VK_ENTER)

WebUI.delay(2)

That doesn’t explain why the unicode character is being added - I’m also a new user and my very simple attempts are also failing because Katalon is adding a unicode character when I enter a Keys.RETURN or Keys.ENTER Send Keys command.
I don’t want to add a java class, just have the program repeat a basic keystroke without something being added - is this how it’s supposed to work or is it a bug in the current version?

According to Wiki:
http://unicodesymbols.wikia.com/wiki/%EE%80%80

That’s the Unknown Unicode Character. and yes honestly,adding the Robot class, is not a perfect solution to fix this, since we are adding something that possible is not needed, since the character its added as soon as WebUI digitally press enter.

1 Like

Besides robot class is there a fix for this? It seems to be since new version of katalon, I had a script running not showing the odd character in 5.4 and since updating to 5.4.1 it is now showing, what got changed?

I’am facing those chars when using WebUI.sendKeys with Keys.chord typing phone number digits in Firefox execution only. Any ideas how to prevent it? Thanks in advance!

I too get Unicode with Keys.chord pressed. Is there any way to solve this? with Java robot class I got a text “null” at the end next to the Unicode.

1 Like

The issue may be coming from your use of Keys.chord(). This is supposed to be used when trying to simulate pressing multiple keys at once, like ctrl + a, ctrl + alt + delete, etc. If the goal is simply to simulate an enter, just do:

WebUI.sendKeys(findTestObject(‘Tutorial/Page_Google/input_q’), Keys.ENTER);

I think there is no such method signature available in katalon for sendKeys to pass Keys.ENTER parameter.

You have to import it :smile:

Press ctrl + shift + o on your keyboard, and choose this one:

org.openqa.selenium.Keys

… Or you can copy paste this to the top of your script:

import org.openqa.selenium.Keys

Ya that is there :grinning:

what I meant is the katalon built in keyword sendKeys

  • com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.sendKeys(TestObject to, String strKeys)
    accept TestObject and String parameters

there is no method to accept parameters of type Keys I guess

so we can pass Keys.chord(Keys.RETURN) as second parameter
but we can’t pass Keys.RETURN

Please correct me if am wrong

Thanks

1 Like

Wow, you’re totally right: https://github.com/katalon-studio/katalon-studio-testing-framework/blob/64c7915b8d478adac844b7b7da6cd15b38aead4c/Include/scripts/groovy/com/kms/katalon/core/webui/keyword/builtin/SendKeysKeyword.groovy. My bad…

I guess I just assumed that it would work the same way that selenium would. In that case, I’d do exactly that, and just use selenium:

WebElement element = WebUiCommonHelper.findWebElement(findTestObject('Tutorial/Page_Google/input_q'), 30);
element.sendKeys(Keys.ENTER);

I should really open a feature improvement/suggestion for this. There’s no reason that WebUI shouldn’t have this signature available (no good ones that I can think of anyway :face_with_raised_eyebrow:)

3 Likes

I’ve opened a suggestion:

2 Likes

Thank you @Brandon_Hein :grinning:

1 Like