Hello friends,
I know I’m not the first one asking this. But I think I have a further problem on this topic.
I read that other members had the same issue that I have right know (with sendKeys backspace).
When I try to clear a TextField under Firefox (94.0.2) using the sendKeys method with backspace:
WebUI.sendKeys(testObject, Keys.chord(Keys.CONTROL, 'a'))
WebUI.sendKeys(testObject, Keys.chord(Keys.BACK_SPACE))
instead of totally removing the content it puts a weird symbol into the field:
So I tried using the clearText() method (from WebUiBuiltInKeywords), but it is not working as expected.
In my TestCase I have to validate, that after clearing a required field, the user gets a message, which says that it is required and can not be empty.
If I clear it by hand, everything works as expected, but if I execute the clearText()-method on the textfield it clears it but the expected message doesn’t show up and the TestCase fails.
This is the point where I couldn’t find any other experience about.
Is it a bug and should I open a Bug-Report? Or is it a problem with our (angular) front-end?
Btw. I also tried the java.awt.Robot class. But I don’t like it
static void clearText(TestObject testObject) {
WebUI.click(testObject)
WebUI.sendKeys(testObject,
Keys.chord(Keys.CONTROL, 'a'))
// System.setProperty("java.awt.headless", "false");
Robot robot = new Robot()
robot.keyPress(KeyEvent.VK_BACK_SPACE)
robot.keyRelease(KeyEvent.VK_BACK_SPACE)
}
When I run it on my Windows System and focus another Window while this test is running, it will execute the BACK_SPACE command on any other kind of text, and my TestCase fails again.
But yeah if I handle it carefully it works
Summary:
- sendKeys - BACK_SPACE → not working on firefox
- WebUI.clearText() → not working for me
- java.awt.Robot() → not a really safe solution
Any suggestions how I can solve this for now?
If not I will continue on using Robot, but hope there is a brain out there who can help me haha.
Thanks and have a nice day,
Simon