Reputation: 3531
In a web interface, I've got a text field. When user enters text and accepts with enter, application performs an action.
I wanted to test the behavior with Selenium. Unfortunately, invoking 'keypress' with chr(13) insert representation of the character into the field.
Is there a way other then submitting the form? I'd like to mimic intended user interaction, without any shortcuts...
Upvotes: 9
Views: 18462
Reputation: 21519
This Java code works for me:
selenium.keyDown(id, "\\13");
Notice the escape. You probably need something like chr(\13)
Upvotes: 10
Reputation: 8069
It's been a while since I've had to do this, but I seem to recall having to use a javascript snippet to execute the carrage return as opposed to using the Selenium keypress function.
Upvotes: 0
Reputation: 485
Though I haven't tested this I imagine you can use "\r\n" appended to a string to simulate a new line. If not look for the languages equivalent to "Environment.NewLine;" ?
Upvotes: 0