2 Answers
2

Many months ago, I ran into similar behavior in WatiN where all the Javascript events don't necessarily get called via the test methods. There were two ways I figured to get around it. One was to call a Javascript event explicitly, something like MyTextField.FireEvent("onchange"). The other way was to just call the "enabling" javascript" method directly, something like MyPage.Eval("myjavascriptEnableFunction").

Neither solution is ideal as it does not mimic user behavior, but it was the best I could find.

Without more information, it is hard to determine the exact solution to your problem. However, I think Selenium does support what you require. I have experienced this exact problem in the past.

First, when text is entered into a text box, quite a few events are fired. Focus, Change, KeyDown, KeyPress, KeyUp. Selenium's 'Type' command does not fire these events, it just puts the text in the field.

In order to properly simulate the user's action, you need to find out which events are important to the text box in question, and add in at least one line to fire that event. If you are using Selenium IDE, it may be enough to simply fire the KeyPress event after the Type step (FireEvent "keyPress" or KeyPress). I use RC for my tests, so I wrote a method to simulate keystrokes for each character entered. You can do the same by writing a custom Type command that fires the events.

Finally, the comment about having to do something outside the user actions is not quite true. When a user acts, many different actions occur by the browser. If anything, Selenium chooses not to do all those actions, so we are left picking up the slack.