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

  • Home
  • SEARCH
  • 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 7525327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:30:48+00:00 2026-05-30T03:30:48+00:00

I have a page with something like this: <input type=button onclick=confirm(‘confirm popup’); value=click />

  • 0

I have a page with something like this:

<input type="button" onclick="confirm('confirm popup');" value="click" />

When I go to the page and click the link:

require "watir-webdriver"
browser = Watir::Browser.new
browser.goto "page.html"
browser.button.click

confirm popup appears. I can dismiss it with this:

require "watir-webdriver/extensions/alerts"
browser.confirm(true) {browser.button(:value => 'Confirm').click}

but the I get this error message:

[remote server] file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/fxdriver@googlecode.com/components/command_processor.js:10302:in `unknown': Modal dialog present (Selenium::WebDriver::Error::UnhandledAlertError)
    from [remote server] file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/fxdriver@googlecode.com/components/driver-component.js -> file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/fxdriver@googlecode.com/components/dispatcher.js:85:in `unknown'
    from [remote server] file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/fxdriver@googlecode.com/components/driver-component.js -> file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/fxdriver@googlecode.com/components/dispatcher.js:516:in `unknown'
    from [remote server] file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/fxdriver@googlecode.com/components/driver-component.js -> file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/fxdriver@googlecode.com/components/dispatcher.js:351:in `unknown'
    from [remote server] file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/fxdriver@googlecode.com/components/driver-component.js -> file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/fxdriver@googlecode.com/components/webdriverserver.js:47:in `unknown'
    from [remote server] file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/fxdriver@googlecode.com/components/httpd.js:1935:in `unknown'
    from [remote server] file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/fxdriver@googlecode.com/components/httpd.js:2261:in `unknown'
    from [remote server] file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/fxdriver@googlecode.com/components/httpd.js:1168:in `unknown'
    from [remote server] file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/fxdriver@googlecode.com/components/httpd.js:1616:in `unknown'
    from [remote server] file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/fxdriver@googlecode.com/components/httpd.js:1464:in `unknown'
    from [remote server] file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/fxdriver@googlecode.com/components/httpd.js:1333:in `unknown'
    from /Users/zeljko/.rvm/gems/ruby-1.9.3-p125/gems/selenium-webdriver-2.19.0/lib/selenium/webdriver/remote/response.rb:52:in `assert_ok'
    from /Users/zeljko/.rvm/gems/ruby-1.9.3-p125/gems/selenium-webdriver-2.19.0/lib/selenium/webdriver/remote/response.rb:15:in `initialize'
    from /Users/zeljko/.rvm/gems/ruby-1.9.3-p125/gems/selenium-webdriver-2.19.0/lib/selenium/webdriver/remote/http/common.rb:59:in `new'
    from /Users/zeljko/.rvm/gems/ruby-1.9.3-p125/gems/selenium-webdriver-2.19.0/lib/selenium/webdriver/remote/http/common.rb:59:in `create_response'
    from /Users/zeljko/.rvm/gems/ruby-1.9.3-p125/gems/selenium-webdriver-2.19.0/lib/selenium/webdriver/remote/http/default.rb:64:in `request'
    from /Users/zeljko/.rvm/gems/ruby-1.9.3-p125/gems/selenium-webdriver-2.19.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
    from /Users/zeljko/.rvm/gems/ruby-1.9.3-p125/gems/selenium-webdriver-2.19.0/lib/selenium/webdriver/remote/bridge.rb:590:in `raw_execute'
    from /Users/zeljko/.rvm/gems/ruby-1.9.3-p125/gems/selenium-webdriver-2.19.0/lib/selenium/webdriver/remote/bridge.rb:568:in `execute'
    from /Users/zeljko/.rvm/gems/ruby-1.9.3-p125/gems/selenium-webdriver-2.19.0/lib/selenium/webdriver/remote/bridge.rb:314:in `executeScript'
    from /Users/zeljko/.rvm/gems/ruby-1.9.3-p125/gems/selenium-webdriver-2.19.0/lib/selenium/webdriver/common/driver.rb:209:in `execute_script'
    from /Users/zeljko/.rvm/gems/ruby-1.9.3-p125/gems/watir-webdriver-0.5.3/lib/watir-webdriver/browser.rb:129:in `execute_script'
    from /Users/zeljko/.rvm/gems/ruby-1.9.3-p125/gems/watir-webdriver-0.5.3/lib/watir-webdriver/extensions/alerts.rb:39:in `confirm'
    from popup.rb:7:in `<main>'

What am I doing wrong?

Environment:

  • Mac OS X 10.7.3
  • Firefox 10.0.2
  • Ruby 1.9.3p125
  • selenium-webdriver 2.19.0
  • watir-webdriver 0.5.3
  • 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-30T03:30:49+00:00Added an answer on May 30, 2026 at 3:30 am

    I’ll refer you to this answer https://stackoverflow.com/a/8172888/409820 where I explained about using methods like browser.confirm. The examples of which are a bit confusing since they come straight from the tests, and if you don’t understand the context that there were multiple buttons on the test page, and the one that causes a confirm dialog has a value of ‘confirm’ then the ‘inner’ command wrapped by the method doesn’t make a lot of sense.

    The commands in the loop (or block ) following the confirm method is the command that causes the popup to occur.

    Hence a better example of how to use those methods would have been something like

    alert_message_text = browser.confirm(true) do
      #watir code that causes confirm popup goes here
    end 
    

    or

    alert_message_text = browser.confirm(true) {#code that causes confirm popup}
    

    in other words the way this works using .confirm(response) {block} is a lot like telling watir “ok the command I am giving you in the block will cause a confirm dialog to appear, and when it does I want you to take the action specified by response“

    So where you are going wrong is the command inside the block, you need to move the ‘browser.button.click’ or something similar inside the block. Your code would then end up looking something like this

    require "watir-webdriver"
    require "watir-webdriver/extensions/alerts"
    
    browser = Watir::Browser.new
    browser.goto "page.html"
    browser.confirm(true) {browser.button(:value => 'click').click}
    

    I changed your click action to be a bit more specific, identifying the button based on the value attribute in the HTML you provided. If you were sure it was always going to be the first button on the page you could change the last line to

    browser.confirm(true) {browser.button.click}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a button like this: <input type=button name=btn id=btn value=Proceed/> After all processes
I have dynamic page under {foreach} tag something like this. <div id=c1> {foreach} <input
I have the following code, which works fine: <input type=button name=btnHello value=Hello onclick=Test();/> and
I want to have on my page something like This page last refreshed on:
I have a page that is accessed via a URL like this: http://power-coder.net/Test/something.php?id=3#Page1 I
I would like to have an aspx page that contains something like.... <form id=form1
I have a page with urls with descriptions listed one under another (something like
I have a simple htmlinputbutton of type submit in my aspx page. <input id=Submit1
I used to have my permalinks to standard format, something like http://example.com/?page_id=2 . Now
I have a page using something along the lines of <meta http-equiv=refresh content=0;url=http://example.com/ />

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.