Modal Dialogs
Background Information
These are only supported by Internet explorer, so tend not to appear all that often. They contain html, but need to be accessed in a certain way.
The following html code would open google in a modal dialog.
window.showModalDialog('www.google.com')
The following dialog was created using the script on http://msdn2.microsoft.com/en-us/library/ms536759.aspx
Note the title of the window - Web Page Dialog - this is a way of determining if you are dealing with a modal dialog or a regular browser window. With a modal dialog, you wont be able to give focus to your main browser window.

Using Watir to Control Modal Dialogs
There is a specific class to handle modal dialogs, called modal_dialog. An example script is below:
require "rubygems" require "watir" b = Watir::Browser.new() b.goto("http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/showModalDialog2.htm") b.button(:value,"Push To Create").click_no_wait puts b.modal_dialog(:title, "showModalDialog Method Sample Target Page").exists? puts b.modal_dialog(:title, "showModalDialog Method Sample Target Page").title b.modal_dialog(:title, "showModalDialog Method Sample Target Page").close
Please note: The click_no_wait method does not currently work using Ruby 1.8.6.27, so use 1.8.6.26 instead (see http://jira.openqa.org/browse/WTR-320).
Also, if using Internet Explorer 8, you will need to make changes to the modal_dialog.rb file in your gems directory, see: http://jira.openqa.org/browse/WTR-414.
Comments (1)
Feb 10
Raveendran says:
Hi, If the Modal Dialog window has some code looks like CODE Side: <html...Hi,
If the Modal Dialog window has some code looks like
CODE Side:
<html><head>
<script> SOME ACTIONS </script>
</head></html>
View Side :
It has lot of tree related links(Not pure a href link. Also i couldn't able to view the source for that texts and links)
My Question is
1. Can I able to access the links within the Modal dialog box ?
If yes, then please guide me
If no, Please add this point in wiki and mention the details
Awaiting your reply,
Thanks