[Wtr-general] Set focus to original window

Alan Jahns ajahns at gmail.com
Mon Dec 4 15:25:40 EST 2006


I tried it at first with "ie" for both but then relized that mistake and
changed it to "ie2" for the new window.

Do I have to I have to use attach to shift focus back to the first window?
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?

Here is the script, its small so I think its ok to put it up here:

ie1 = Watir::IE.new
   ie1.goto(test_site)

   ie1.link(:text, "Sign in").click #this click causes the new window to
come up
   # logging in to new pop up window
   ie2 = Watir::IE.attach(:url, 'http://www.*******.com/check?signin=true')
   ie2.text_field(:index, 2).set("funkenstein")
   ie2.text_field(:index, 3).set("1212")
   ie2.checkbox(:name, "savepassword").clear
   ie2.button(:value, "Sign In").click

   NOTE: script just goes to the ELSE statement without giving the first
page a chance to reload and display login verification

   #verify user is signed in

    if ie1.contains_text("You are signed in as")
      puts "Test PASSED. Found the test string: You are signed in as"
   else
      puts "Test FAILED! Could not find: 'You are signed in as'"
    end

Thanks,
Alan Jahns

On 12/1/06, Danny Faught <faught at tejasconsulting.com> wrote:
>
> Alan Jahns wrote:
> > I have some simple if/else statements to check
> > if some text strings are on the original window, but it seems that it no
> > longer sees the original window. How would I make watir switch focus
> back?
>
> One likely mistake is to use the same variable, like "ie", for both the
> parent and the child window.  Make sure to use separate variables for
> each window that you want to keep track of.
>
> -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/078e627c/attachment.html 


More information about the Wtr-general mailing list