Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

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. // (if you're using Java)


share|improve this answer

I believe we have to use AUTOIT tool for it.

share|improve this answer
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

Your Answer


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.