[Wtr-general] Set focus to original window

Danny R. Faught faught at tejasconsulting.com
Mon Dec 4 15:43:27 EST 2006


On 12/4/2006, "Alan Jahns" <ajahns at gmail.com> wrote:
>Could it be that since after submitting the log in credentials the 2nd
>window closes and the first window takes a few secs to reload?

Yes, I think that's probably the problem - your code has a race
condition. There is a wait function that you normally don't have to
call directly, because after an action that you'd want to wait for it
to finish, Watir calls it for you. But in this case, since you have one
window causing a change in another window, you'd have to take care of
the synchronization yourself.

Even if you wait until the page finished loading, there's still a race
condition, because there's a chance (probably a small one) that you'd
call wait before the first page even begins to reload, and the wait
would return immediately because it's not loading anything yet. So in
addition to the wait, I would recommend putting your "You are signed in
as" test in a loop, so it tries several times over the course of
several seconds before giving up.

I'm not a seasoned Watir developer yet, but hopefully I've hit on the
issue here. By the way, I don't think that "focus" is what you're
looking for. Unlike many GUI test tools, in many cases IE doesn't
actually need focus or to be in the foreground in order for Watir to
work. I'd imagine that focus would be something you'd have to worry
about if you use Watir's generic GUI automation, though.

-Danny


More information about the Wtr-general mailing list