views:

663

answers:

2

When the browser launch is initiated by SeleniumRC, a dialog box always comes to ask for username/password to login to our proxy server (however, it is prepopulated with username/password, all has to be done is just press the OK button).

selenium.open("/"); selenium.type("q", "selenium rc"); selenium.click("btnG"); selenium.waitForPageToLoad("10000"); assertTrue(selenium.isTextPresent("Results * for selenium rc")); // These are the real test steps //selenium.stop();

After the first command, the dialog box appears and I want to dispose that dialog box PROGRAMMATIC. Any help?

+3  A: 

I don't think you'll be able to address this just by using Selenium, that modal dialog is outside the JavaScript boundaries in which selenium works.

The two alternatives I can think of are:

  • Using WebDriver (soon to be merged into selenium 2.0): has native support over the browser, which allows you to do that kind of stuff.
  • Using an OS level automation library just for clicking that prompt and you go back to selenium with the rest. The libs available for this things are language dependent, so you will find a lot of different options as Robot for java or pyWinAuto for python.

Update: New alternative:

  • You can use autoIT as a simple and fast solution under windows.
Santi
A: 

WatiN can handle logon and other types of dialogs.

Adam Neal