I'm using WatiN testing tool. Can I pass a key stroke (i.e., pressing a enter key) to the application using WatiN scripts?
This option was available in WatiR. Is this option available in WatiN?
I'm using WatiN testing tool. Can I pass a key stroke (i.e., pressing a enter key) to the application using WatiN scripts?
This option was available in WatiR. Is this option available in WatiN?
the above answer works fine as long as the browser has focus, if it doesn't then SendKeys.SendWait triggers on whichever application has focus.
While being a bit clunky this will trigger a press of enter regardless.
There is a really good blog article about this at the Degree Dev Blog
It explains how you can add the Enter press as an extension method like this:
This makes it very easy to press the Enter key in a test.
EDIT: Upon further inspection, I found that the standard way of sending the ENTER key doesn't work in WatiN as it does in WatiR. You need to use System.Windows.Forms.SendKeys
Also, I recommend that you download the WatiN Test Recorder.
Here's the sample code.
You have to use
System.Windows.Forms
.Why not just do the following?
Worked for my a test I was developing using Watin
Try this:
Then, just call this method when you need to simulate the ENTER key being pressed.