Modal Dialogs - convio/watirmark GitHub Wiki

Modal dialogs can be a bit of a pain to deal with and in webdriver you need to switch your window use in Page.browser. To make this easier to use, simply wrap the code that should be excercised in a modal dialog as follows:

with_modal_dialog do 
  ConstituentOptions.new.create
end

This code will switch Page.browser to the last window opened by the browser, execute the code and then reset the window to the previously focused window