Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

I am working on the test automation that uses WebDriver (Selenium 2) and Java. The AUT is web-based application. A modal dialog pops up that requires user authentication before the user can access the Web app's login page.

I have searched extensively and am unable to get any working solution.

Relevant Search results
The following thread addresses how to handle alerts and prompts:
http://code.google.com/p/selenium/issues/detail?id=27

The following blog post attempts to address a few related issues:
http://seleniumdeal.blogspot.com/2010/04/working-with-modal-dialogs-and-selenium.html

But neither of them provides an implemented solution to the problem.

What's happening:
When driver.get("login page") is executed, the browser attempts to open the page, but a modal dialog appears which asks for the user authentication (login & pwd). The WebDriver keeps waiting until I manually authenticate or click Cancel.

The execution never goes to the next step. So whatever I attempt after "driver.get()" is never executed until manual intervention.

Note: I am using Firefox 4

EDIT: The blocker to all the solutions is to the following - (from WebDriver's get() method's documentation: This is done using an HTTP GET operation, and the method will block until the load is complete for driver.get(). Due to this block, the control of execution never goes to the next step i.e. Any statement written after the driver.get() will not get executed until load is complete.

share|improve this question
    
This thread is dedicated to supporting "timeout on page load": code.google.com/p/selenium/issues/detail?id=687 –  Suchit Parikh Jun 8 '11 at 22:29
    
Have you considered finessing the problem by passing the username/password in an HTTP request or setting the appropriate cookie? –  user246 Jun 9 '11 at 13:15
add comment

2 Answers

There is a java.awt.Robot class for interacting with non-HTML dialogs. I've used that for dealing with file dialogs and download dialogs.

share|improve this answer
    
That's one of the solutions in selenium 1. The other is using AutoIt scripts. I haven't dived into seleninum 2 (webdriver) very much. The point in this issue is where to inject the condition checkings for the presence of the modal dialog, as the webdriver.get() is not asynchronous. Any code after the method are not executed until get() returns. So setting a timeout and catching it for dialog checking could be one option. –  Michael Yang Jun 9 '11 at 12:57
    
Before calling driver.get(), one could create a second thread to interact with the blocking dialog. –  user246 Jun 9 '11 at 14:07
    
@Michael - Setting a timeout doesn't really work as this feature is faulty in WebDriver (selenium issue id # 687). @user246 - I will attempt your approach and comment back how it works out. –  Suchit Parikh Jun 9 '11 at 18:38
add comment

I use a waitfortextpresent command in selenium IDE in similar cases. so that it will wait for a text on the modal dialog and enter the credentials on that. Perhaps a similar command might help in webdriver

share|improve this answer
    
I don't think you can waitfortextpresent in seleniumIDE, unless the dialog you were referring to is a mocked html dialog. –  Michael Yang Jun 9 '11 at 12:53
    
I cant find anything in the documentation that limits it to html. in the selenium.org –  Theo Jun 10 '11 at 8:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.