« Return to Thread: implementing support for showModalDialog

Re: implementing support for showModalDialog

by Dan Fabulich :: Rate this Message:

Reply to Author | View in Thread

Matthew Purland wrote:

> Hi,
>
> My organization is in dire need to have the functionality of showModalDialog.  We would like to use Selenium, however the web application we are developing heavily written to use showModalDialog.  I have taken it upon myself to try to add this feature to Selenium.
>
> Are there any developers here that may have any ideas of what the ideal
> situation to implement it would be?  I have considered using ActiveX and
> similar approaches as Watir uses.

Let me make a couple of observations here.

1) Selenium Core works by having two Windows open, one of which (the
TestRunner window) invokes JS functions on the other (the Application
Under Test).  showModalDialog makes that strategy unworkable, because when
a modal dialog has appeared, the TestRunner window is paused, unable to
execute, until the modal dialog has closed.

2) Recent versions of Selenium RC provide a new mechanism for running
Selenium tests called "proxy injection" mode.  The idea is that we provide
an HTTP proxy that automatically modifies all incoming HTML before it
arrives in your browser.  This allows us to "inject" Selenium code into
all HTML windows, including modal dialogs.  Since the "brains" of Selenium
RC are in the Selenium Server, you should be able to use Selenium RC (with
proxy injection) to test modal dialogs.

Note that Selenium RC does not normally run in proxy injection mode; you
have to turn it on from the command line separately.

3) If you search around in the Selenium Core code you may find some
leftover stubs of showModalDialog support (which don't work).  The basic
idea here was to do something similar to what we already do with pop-up
windows.

Specifically, in order to keep track of (ordinary) pop-up windows created
by the AUT, we intercept all calls to window.open, replacing that function
with our own function that keeps a record of opened windows (and then
opens the window, as you requested).

In the case of modal dialogs, we did something kinda weird (and which
didn't really work, if I understand it correctly) where we replaced calls
to .showModalDialog with our own function that opened another "mini
instance" of Selenium within a modal dialog.  You'd see another miniature
version of Selenium (with another embedded iframe) in your floating modal
dialog; we'd then begin executing a single simple test inside that modal
dialog, typically enough to click "OK" or whatever to make the modal
dialog go away.  It looked strange and felt like a hack to me.

With that said, I guess it'd be possible to resuscitate this strategy and
make it work again, if it ever worked to begin with, and if that's good
enough for you. :-)

-Dan

---------------------------------------------------------------------
To unsubscribe, e-mail: selenium-dev-unsubscribe@...
For additional commands, e-mail: selenium-dev-help@...

 « Return to Thread: implementing support for showModalDialog