New Browser Windows

New Browser Windows

This is basically a new window that contains HTML. They can be opened in many ways, but the following HTML is typical:

<a href = http://www.google.com target="_blank">Get Google in a new window</a>

It would appear like an existing browser window, but may not have the address bar or other toolbars.

You would use the Watir attach method to access it, like so:

ie2 = Watir::IE.attach(:url, 'http://mytestsite')
ie3 = Watir::IE.attach(:title, 'Test New Window')

You can use a regular expression on URL or title like this:

ie4 = Watir::IE.attach(:url, /mytestsite/)
ie5 = Watir::IE.attach(:title, /Test New/)

Note: be careful to not assign the new window to your ie variable. Give the attached window variable a different name, like ie2.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Aug 28, 2008

    Wesley says:

    The best benefit of Watir::IE.attach maybe, we don't need to initialize our IE w...

    The best benefit of Watir::IE.attach maybe, we don't need to initialize our IE window once the windows exists.
    We just need locate the tab, then practice on the page.
    We can locate any tab we want.

    #Get the title and url of the tab existent.
    Watir::IE.each do |tab|
    puts tab.title
    puts tab.url
    end

    For blank page, we may locate it use:
    ie6 = Watir::IE.attach(:title, //)
    ie6.goto("test site")

    or
    ie7=Watir::IE.attach(:url,/about:blank/)
    ie7.goto("test site")

    I think it is really useful, saving my time of testing my script.

  2. Aug 26, 2009

    ]{n says:

    Is there a safariwatir equivalent of the attach method?

    Is there a safariwatir equivalent of the attach method?

  3. Jan 28, 2011

    Irfan Ahmed says:

    Hi, I am using linux..I am using firewatir...But recently I am having a problem ...

    Hi, I am using linux..I am using firewatir...But recently I am having a problem with login with facebook feature..because there is a pop_up browser windows and I need to enter the email id and password in that pop up to authenticate my facebook account! But I don't know how to do that with firewatir..If possible then please help me.

    Thanks, Irfan

  4. Jan 31, 2011

    Zeljko says:

    Irfan, we do not offer support via comments here, please take a look at http://w...

    Irfan, we do not offer support via comments here, please take a look at http://watir.com/support/