TestWise IDE

Next Generation Functional Testing Tool


Popup handler (Pro edition)

Watir (one underlying test framework used in TestWise) is known for not being pop-up 'friendly' - it doesn't handle popups well. We tried most of various approaches others have used, but they didn't work as well as we hoped. There are all sorts of popups that could be encountered - JavaScript popups, IE Security Alerts, Upload/Download dialog, Basic Authentication and so on. A single un-handled popup will block the test execution - causing the tester much grief and wasted time.

Our solution: running a background process to handle popups, a simple and reliable approach. Here is how it works:

  nid = notify_execution_monitor_before_basic_auth("bob", "builder") # prepare to handle basic authentication pop with username/password
  open_browser # it will ask for user to login (basic authentication popup)
  notify_execution_monitor_cancel(nid) #operation complete, test can continue, notify the handler


Start up background process
C:\Program Files\TestWise\scripts\execution_monitor> startup.bat

You will see the text below, indicating the background popup clicking process up running

[05-11 09:39:14PM] Starting RWebSpec Monitoring v(0.2.5) on 4208

Run test

Let's illustrate with an example. In TestWise, open samples\demo\demo.tpr project, select file popup_handler_test.rb, run it.

the test script:

require 'rwebspec'
load File.expand_path(File.join(File.dirname(__FILE__), "execution_monitor_helper.rb"))

specification "Popup handler" do
  include RWebSpec::RSpecHelper
  include ExecutionMonitorHelper

  before(:all) do

  after(:all) do
    close_browser unless debugging?

  story "Click OK in JavaScript popup window to continue" do
    nid = notify_execution_monitor_before_popup
    click_link("Popup windows")
    click_button(" Buy Now ")
    assert_link_present_with_text("Popup windows")

  story "Basic Authentication" do
    nid = notify_execution_monitor_before_basic_auth("tony", "password")


You can see two popups were handled: JavaScript Popup and Basic Authentication dialog. Here is a screencast to see in action.

For basic authentication, if somehow previous tests already created the session, the dialog won't be shown. The above test still works!

List of popups handled in execution monitor v0.2.5
  • notify_execution_monitor_before_basic_auth
  • notify_execution_monitor_before_file_upload
  • notify_execution_monitor_before_security_alerts
  • notify_execution_monitor_before_popup

As different versions of IE might have popups with different titles, the execution monitor's target environment is IE8 on WinXP.

on Window 7

Prior to RubyShell v1.6.1, the AutoIt3, the library used to click buttons in popups, was not working well on Window 7 64-bit OS. An alternative approach is to use RAutomation's WinFFi adapter. You don't need to worry about this - just install RubyShell 1.6.1 or later version.

The steps are exactly the same, on starting the execution monitor, you get this:

Error no load AutoITX3 (not working on Win7), will use RAutomation instead
[05-15 08:24:12AM] Starting RWebSpec Monitoring v(0.2.6) on 4208

Here is a screencast of Popup handler on Window 7

Please note: Though this approach is in early release, handling of JavaScript and Basic Authentication popups are now working. RAutomation is patched to make it work with Basic Authentication dialog.