[Wtr-general] Set focus to original window

Danny R. Faught faught at tejasconsulting.com
Mon Dec 4 16:39:09 EST 2006


On 12/4/2006, "Alan Jahns" <ajahns at gmail.com> wrote:
>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)

I was hoping you wouldn't find that.  :-)  The hacker in me wants to
point out that using sleeps to synchronize are both too slow and still
don't technically remove the race condition.

But the engineer in me says, hey, great, that will probably work in most
or all of the cases you need it for, and the slower it is, the more
likely it'll work.

You pick which one you want to listen to.  :-)  Here's pseudocode for
how I would approach it -

..child window initiates content change in parent window
found = 0
for i in 1..10
  ie.wait
  if desired content found in parent
    found = 1
    break
  end
end
if found == 1
  hurrah!

-Danny


More information about the Wtr-general mailing list