How to handle Pop Ups with Watir.
Pop Ups
Watir works fine with ordinary web pop up windows. Use Watir::IE.attach. However, this command does not support modal web pop up windows. These are web pages that pop up and block access to the original page until you've closed them.
Watir includes support for these. Use Browser.modal_dialog to access them (more information on how to do this is on the Modal Dialogs page).
Watir provides a means of easily automating testing of web applications. One part of this automation is dealing with the various types of pop ups that Internet Explorer displays. Handling these pop ups has always been painful. This document tries to remove some of the pain, by describing what many of the pop ups are, why they appear and how to handle them.
JavaScript generated popups such as Alert boxes, Windows Security popups, and other popups that are not contained in a web browser are not accessible the same way HTML pages are. There has been some experimental code packaged with Watir to deal with popups with limited success. A good popup handling solution is being worked on and will be included in a future Watir release. In the mean time, AutoIT is installed with Watir. Look at popups_test.rb in the unit tests directory, and use Watir Search for more information. If, after learning from the examples here, you want to experiment with AutoIT, there is a potentially time-saving tool that will display the Controls (buttons, text fields, etc.) available to be used in your AutoIT script called AutoIt Window Info Tool (au3info) which comes with the full AutoIT installation.
Watch for a Watir solution in a future release.
Types of pop ups:
Comments (1)
Aug 15, 2010
Jared Quinert says:
Another approach I've tried is to use Sikuli to manipulate the popups. This is o...Another approach I've tried is to use Sikuli to manipulate the popups. This is only for watir-webdriver at the moment though (unless you want to hack around with the Ruby-Java bridge. I didn't). It could also be used for Flash objects. http://www.software-testing.com.au/blog/2010/08/16/automating-flash-ajax-popups-and-more-using-ruby-watir-and-sikuli/