Ranadheer Reddy Ranadheer Reddy - 1 year ago 339
C# Question

Press Enter Key in Selenium RC with C#

How to press Enter using Selenium RC using C#?

I am working with a

In which I have to type some name and I have to press Enter to search.

There is no
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

Answer Source

This can be achieved by Keys (click here to get C# docs on it) - 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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download