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 trying to navigate the command on the alert box, but I am not able to do it in Web Driver with JAVA. Please help me with it. Apart from this I would also like to know how to tackle with the confirmation box and Warnings prompts displayed.

share|improve this question
    
Could you give us a bit more information to go by, please? How have you tried to access the alert box? What is the failure message? What's the code of the page generating the alert? Right now there isn't enough information for the Selenium folks to give you much help. –  Kate Paulk Mar 5 at 12:05
    
There is several different types of alerts. There can be pop up alerts, iframe alerts and many many other ways to alert the end user. The way that the alert is displayed will change the way that the alert is handled. –  PaulDonny Mar 5 at 14:11

1 Answer 1

up vote 2 down vote accepted

If this is a Javascript alert box, this is relatively straightforward; you can switch to it with driver.switchTo().alert(); in Java. If you save the return value of that as an Alert object, you can interact with it, like alert.accept(). See the javadoc for more information.

Since you're asking, however, I suspect it's not so simple. If this is not really an alert, but a popup that the browser has generated, such as a Basic Authentication prompt, you cannot interact with it using WebDriver, as WebDriver can only interact with things that exist in the DOM. You will have to use another Java library, such as Robot, to interact with popups at this level.

share|improve this answer
    
Thanks Yamikuronue... –  Swap Mar 5 at 14:30
    
@Swap if you are satisfied with this answer, please click the check button to indicate that you've accepted it. –  user246 Mar 5 at 15:01

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.