How to press Enter using Selenium RC using C#?
I am working with a SearchBox
using Selenium
.
In which I have to type some name and I have to press Enter to search.
There is no Submit
button. So, I must use Enter.
I tried something like this
selenium.KeyPress("quicksearchtextcriteria", "13");
But doesn't work.
Please Help.
Note: I made a collection of possible ways to do this. See here: press enter key in selenium
We can type Enter/Return key in Selenium. We shall use the sendKeys method and pass Keys. ENTER as an argument to the method. Also, we can use pass Keys.
You can simulate hit Enter key by adding "\n" to the entered text. For example textField. sendKeys("text you type into field" + "\n") .
You can easily issue a key press by using the send_keys command. This can be done to a specific element, or generically with Selenium's Action Builder (which has been documented on the Selenium project's Wiki page for Advanced User Interactions). Either approach will send a key press.
This can be achieved by Keys
, and Enter
.
Example in Java as I don't know C#:
import org.openqa.selenium.Keys;
//...
// this sends an Enter to the element
selenium.type("locator", Keys.ENTER);
// or even this - this sends the "Any text" and then confirms it with Enter
selenium.type("locator", "Any text" + Keys.ENTER);
From the Keys
enum.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With