Ruby · watir · watir-webdriver

Watir WebDriver — Handling New Window


1. You are in Parent Page.
2. Clicking link “Open” in Parent page.
3. It opens new window
4. You need to do actions  there and come back to your parent window


To Click the Link

require 'rubygems'
require 'watir-webdriver' :ff

To handle the New window and performing some actions within that window,

ff.window(:title,/TITLE of the new window/i).use do
puts ff.title #returns the new window title

within a loop The button belongs to Newly opened window.

puts ff.title #returns the parent window title


4 thoughts on “Watir WebDriver — Handling New Window

  1. Hello,
    I am about to start web automation of my project from scratch.

    I am confused if I should use watir-webdriver or selenium-webdriver.
    I have read about both of them, but I am not able to decide which one I should go ahead with.

    I have quite some experience in watir, but if selenium-webdriver is better than watir-webdriver I would like to explore it.

    I see that you have been working on both.
    Could you please advice me on which one I should use?
    Your help is much appreciated.


  2. I dont know what to say. This blog is fantastic. Thats not really a really huge statement, but its all I could come up with after reading this. You know so much about this subject. So much so that you made me want to learn more about it. Your blog is my stepping stone, my friend. Thanks for the heads up on this subject.
    my website is about family vacation ideas.

  3. Hi, I’m running cucmber scripts and using watir-webdriver. Would you know why I’m getting errors that indicate that “Selenium::Webdriver” when I’m using watir-webdriver? I had installed selenium-webdriver in my PC at some point in the past.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s