views:

121

answers:

0

Any idea how I can fire the blur even just after the focus event, such that it doesn't occur "loosly coupled" (the actions are send one-by-one to the selenium server). Let me explain:

In Selenium RC you fire the blur and focus through fireEvent(locator, "blur") and fireEvent(locator, "focus"). However, after the blur event is send to the browser the focus event doesn't directly follow the blur event in the javascript command stack. This is a problem is in the following case: detecting the blur of a group of widgets, like a group of textboxes.

What I do: all text boxes share the same listener and when a blur occurs I simple run an additional command that checks if a focus event was captured by one of the textboxes, if so, you ignore the blur. This additional command that I run in javascript is automatically executed after all waiting commands are run, in this case, a focus command is one of these waiting commands.

Back to Selenium RC: after the blur event is fired by the Selenium server, it waits for the next command, in this case the focus event and will fire it. However, as you can understand, in the mean time, the addiontal command already has been fired and no new focus event has been detected. As such, a group-blur is detected and handled, in this case however the blur is incorrectly handled as the focus isn't fired directly after the blur, such as a browser would do....

I hope you understand my problem as it's a bit hard to explain. Any idea's on how to solve this? so I can test the correct behavior? (no my validation takes place too early as a group-blur isn't correctly captured)

I think the way to solve this: send a piece of javascript to the Selenium server that will be evaluated and will fire both events after eachother. Or not?... And you how would I do this?