[Wtr-general] Set focus to original window
Alan Jahns
ajahns at gmail.com
Mon Dec 4 16:10:13 EST 2006
Well thanks a lot, you led me to the fix. It does seem to be a timing
problem, I started googling to figure out how to do a loop as you suggested
and while doing that found the sleep command, so I tried something like:
ie2.button(:value, "Sign In").click
# take a nap to wait for first page to load
sleep(25)
and that did the trick, I've added a check to verify the username on the
parent page and it picks it up. I'll continue to look for a more robust
solution but this will have the script working in the meantime.
Thanks!
Alan Jahns
On 12/4/06, Danny R. Faught <faught at tejasconsulting.com> wrote:
>
> 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
> _______________________________________________
> Wtr-general mailing list
> Wtr-general at rubyforge.org
> http://rubyforge.org/mailman/listinfo/wtr-general
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/wtr-general/attachments/20061204/cd173114/attachment.html
More information about the Wtr-general
mailing list