Watir Webdriver attach window

While porting a watir based automation framework to watir-webdriver, I came across an issue that most have come across, that being : "In Watir and Selenium Webdrivers, there is no longer an attach method to attach to existing browsers. "

But an in-depth analysis of the rspec for watir-webdriver brought a simple method to the lime light.

browser.windows #=> [#, #]
browser.windows.first.current? #=> true
browser.window(:title => "foo").use
browser.window(:url => /bar/).use { ...code... }

As the above code makes it clear, it's easy to switch between windows, even though the 'attach' method is missing in the webdriver.

Alternatively one can also use


But that would get complicated with too many popups to handle. Interestingly there is one issue still lurking around in the Selenium world!

Share this