Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3339420
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:29:24+00:00 2026-05-18T00:29:24+00:00

I am implementing a project with Selenium 2, which currently doesn’t support confirm dialog

  • 0

I am implementing a project with Selenium 2, which currently doesn’t support confirm dialog boxes very well.

There is a workaround to this limitation, you just overwrite the window.confirm to return the value which you need to return for the specific test case.

The following strings can be set and then executed:

public static final String CONFIRM_DIALOG_BOX = 
    "window.confirm = function(msg) { return true; }";

public static final String CANCEL_DIALOG_BOX = 
    "window.confirm = function(msg) { return false; }";

This seems pretty straightforward as a template method, however I have multiple test cases on the same page object where I need to confirm / deny after interacting with the page. Thus having a single method to do those all of these tests at once doesn’t work.

Injecting a command to run into the test method could make sense, but my end goal here is to allow our less technical staff to create tests by writing some strings into XML and then executing it with Spring Expression Language; this removes some of the “easiness” out of writing the tests.

Major caveat is that this test suite is actually an application due to requirements and not a set of test cases which are individually run. It would be much easier if they were small test cases as I could just extends an abstract test case and utilize the same setup and teardown routines.

What I’m ultimately looking for is something along this template method, but I need to be able to support multiple test cases on a single page object.

public final void executeTest(boolean confirmDialogBoxResponse) {

    // store normal functionality and allow us to return 
    // window.confirm to normal state upon completion of test.
    prepare(confirmDialogBoxResponse);

    testMethod(); // What about params to these methods?

    /* Adding an interface to the method would be nice, but 
     * would make things a bit more cumbersome for our
     * less technical staff, which would allow me to replace
     * the above with this:
     *
     *    executeTest(TestCommand command, confirmDialogResponse);
     *         command.execute(); // Still have params issue
     */

    // restore window.confirm to normal state -- if we cancel we stay 
    // on same page, and need to restore things as they were, the majority
    // of our confirm cases take you to new pages whereby window.confirm 
    // will be restored for us
    if (!confirmDialogResponse) {
        restore();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T00:29:25+00:00Added an answer on May 18, 2026 at 12:29 am

    Have you looked at the Selenium Issue #27 recently (comment#46)? It has some patches attached that provides support for alert and confirm?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently working on a Google Maps project and am implementing a search function.
I'm working on a project for school, and I'm implementing a tool which can
I am working on implementing Zend Framework within an existing project that has a
I am having problems with implementing Observer pattern in my project. The project has
Implementing Equals() for reference types is harder than it seems. My current canonical implementation
Implementing a 'sandbox' environment in Python used to be done with the rexec module
When implementing a needle search of a haystack in an object-oriented way, you essentially
When implementing Quicksort, one of the things you have to do is to choose
I implementing a EventQueue and get notified when AWTEvents are send. I wait till
When implementing a singleton in C++, is it better for GetInstance() to return a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.