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'm using Selenium web driver with Java language. When there are two buttons in a popup i.e. ok and cancel , it can be easily handled with web driver using the following code:

Alert alert = driver.switchTo().alert();
alert.accept(); // or alert.dismiss(); depending upon the action you want to perform.

But what to do when there are more than two buttons, i.e. there are 3 to 4 buttons in the pop up ( e.g. like ok, cancel, try again, ignore/continue)? How can we click on whichever button that we want?

Thank you very much for your help in advance.

share|improve this question
add comment

3 Answers 3

You could probably use the sendkeys function from the alert class to either press the shortcut key to select the item you want or tab to the correct item and press enter. Unfortunately it doesn't seem like the Selenium Alert class allows you to click a specific item, which would be much more useful...

share|improve this answer
    
This seems to be a nice idea. Will try it out. –  Tom Jul 9 '12 at 7:23
add comment

Can you use the Selenium AdvancedUserInteractions?

Are you using CSS style sheets and/or page objects? It's very simple to select a single option from multiple choices using either of those and defining the buttons as WebElements.

element1.click() // (if you're using Java)
element2.click()

etc.

share|improve this answer
add comment

I believe we have to use AUTOIT tool for it.

share|improve this answer
1  
Welcome to SQA, user1924504. Could you elaborate on this restriction? What factors cause you to use it? Is it the only option available, or are there other factors in your workplace that mandate it? –  corsiKa Dec 24 '12 at 17:10
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.