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/[email protected]/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/[email protected]/components/driver-component.js -> file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/[email protected]/components/dispatcher.js:85:in `unknown'
from [remote server] file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/[email protected]/components/driver-component.js -> file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/[email protected]/components/dispatcher.js:516:in `unknown'
from [remote server] file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/[email protected]/components/driver-component.js -> file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/[email protected]/components/dispatcher.js:351:in `unknown'
from [remote server] file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/[email protected]/components/driver-component.js -> file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/[email protected]/components/webdriverserver.js:47:in `unknown'
from [remote server] file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/[email protected]/components/httpd.js:1935:in `unknown'
from [remote server] file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/[email protected]/components/httpd.js:2261:in `unknown'
from [remote server] file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/[email protected]/components/httpd.js:1168:in `unknown'
from [remote server] file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/[email protected]/components/httpd.js:1616:in `unknown'
from [remote server] file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/[email protected]/components/httpd.js:1464:in `unknown'
from [remote server] file:///var/folders/yx/bz_81fc143b4r9pyhks300m00000gn/T/webdriver-profile20120218-1562-7b7q8d/extensions/[email protected]/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
browser.confirm(true) {browser.button.click}
. I guess it overrideswindow.confirm
JavaScript function, similar tobrowser.execute_script("window.confirm = function() {return true}")
– Conventioner