Ruby Selenium::WebDriver::Error::UnhandleAlerError)在解除警报后

Ruby Selenium::WebDriver::Error::UnhandleAlerError)在解除警报后,ruby,firefox,selenium-webdriver,capybara,modal-dialog,Ruby,Firefox,Selenium Webdriver,Capybara,Modal Dialog,我们有一个类似这样的黄瓜场景: @selenium Scenario: I can be told that geolocation is unavailable # features/home_page.feature:57 Given I am a visitor

我们有一个类似这样的黄瓜场景:

  @selenium
  Scenario: I can be told that geolocation is unavailable                                            # features/home_page.feature:57
    Given I am a visitor                                                                             # features/step_definitions/authentication_steps.rb:5
    When I visit the homepage                                                                        # features/step_definitions/home_page_steps.rb:1
    And I have declined geolocation permissions                                                      # features/step_definitions/home_page_steps.rb:14
    And I click the geolocate button                                                                 # features/step_definitions/home_page_steps.rb:18
    Then I see an alert "Unable to determine your current location. Please type an address instead." # features/step_definitions/web_steps.rb:104
步骤
我看到一个警报“(.+?)”
被定义为:

Then(/^I see an alert "(.+?)"$/) do |content|
  page.driver.browser.switch_to.alert.text.should == content
  page.driver.browser.switch_to.alert.dismiss
end
出于某种原因,解除此警报是不够的。下一个场景总是失败,原因是:

 Modal dialog present (Selenium::WebDriver::Error::UnhandledAlertError)
 [remote server] file:///var/folders/x6/4vcz8vmj5ls2dbc9b3x2qxvh0000gp/T/webdriver-profile20130927-61014-emm2oz/extensions/fxdriver@googlecode.com/components/command_processor.js:10521:in `nsCommandProcessor.execute'
 [remote server] file:///var/folders/x6/4vcz8vmj5ls2dbc9b3x2qxvh0000gp/T/webdriver-profile20130927-61014-emm2oz/extensions/fxdriver@googlecode.com/components/driver_component.js:7510:in `Dispatcher.executeAs/<'
 [remote server] file:///var/folders/x6/4vcz8vmj5ls2dbc9b3x2qxvh0000gp/T/webdriver-profile20130927-61014-emm2oz/extensions/fxdriver@googlecode.com/components/driver_component.js:7668:in `Resource.handle'
 [remote server] file:///var/folders/x6/4vcz8vmj5ls2dbc9b3x2qxvh0000gp/T/webdriver-profile20130927-61014-emm2oz/extensions/fxdriver@googlecode.com/components/driver_component.js:7615:in `Dispatcher.dispatch'
 [remote server] file:///var/folders/x6/4vcz8vmj5ls2dbc9b3x2qxvh0000gp/T/webdriver-profile20130927-61014-emm2oz/extensions/fxdriver@googlecode.com/components/driver_component.js:10336:in `WebDriverServer/<.handle'
 [remote server] file:///var/folders/x6/4vcz8vmj5ls2dbc9b3x2qxvh0000gp/T/webdriver-profile20130927-61014-emm2oz/extensions/fxdriver@googlecode.com/components/httpd.js:1935:in `unknown'
 [remote server] file:///var/folders/x6/4vcz8vmj5ls2dbc9b3x2qxvh0000gp/T/webdriver-profile20130927-61014-emm2oz/extensions/fxdriver@googlecode.com/components/httpd.js:2261:in `ServerHandler.handleResponse'
 [remote server] file:///var/folders/x6/4vcz8vmj5ls2dbc9b3x2qxvh0000gp/T/webdriver-profile20130927-61014-emm2oz/extensions/fxdriver@googlecode.com/components/httpd.js:1168:in `Connection.process'
 [remote server] file:///var/folders/x6/4vcz8vmj5ls2dbc9b3x2qxvh0000gp/T/webdriver-profile20130927-61014-emm2oz/extensions/fxdriver@googlecode.com/components/httpd.js:1616:in `RequestReader._handleResponse'
 [remote server] file:///var/folders/x6/4vcz8vmj5ls2dbc9b3x2qxvh0000gp/T/webdriver-profile20130927-61014-emm2oz/extensions/fxdriver@googlecode.com/components/httpd.js:1464:in `RequestReader._processBody'
 [remote server] file:///var/folders/x6/4vcz8vmj5ls2dbc9b3x2qxvh0000gp/T/webdriver-profile20130927-61014-emm2oz/extensions/fxdriver@googlecode.com/components/httpd.js:1333:in `RequestReader.onInputStreamReady'
 /Users/ccashwell/.rvm/gems/ruby-1.9.3-p194@geostellar/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/response.rb:51:in `assert_ok'
 /Users/ccashwell/.rvm/gems/ruby-1.9.3-p194@geostellar/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/response.rb:15:in `initialize'
 /Users/ccashwell/.rvm/gems/ruby-1.9.3-p194@geostellar/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/http/common.rb:59:in `new'
 /Users/ccashwell/.rvm/gems/ruby-1.9.3-p194@geostellar/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/http/common.rb:59:in `create_response'
 /Users/ccashwell/.rvm/gems/ruby-1.9.3-p194@geostellar/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/http/default.rb:66:in `request'
 /Users/ccashwell/.rvm/gems/ruby-1.9.3-p194@geostellar/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
 /Users/ccashwell/.rvm/gems/ruby-1.9.3-p194@geostellar/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/bridge.rb:629:in `raw_execute'
 /Users/ccashwell/.rvm/gems/ruby-1.9.3-p194@geostellar/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/bridge.rb:607:in `execute'
 /Users/ccashwell/.rvm/gems/ruby-1.9.3-p194@geostellar/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/bridge.rb:356:in `deleteAllCookies'
 /Users/ccashwell/.rvm/gems/ruby-1.9.3-p194@geostellar/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/common/options.rb:67:in `delete_all_cookies'
 /Users/ccashwell/.rvm/gems/ruby-1.9.3-p194@geostellar/gems/capybara-2.0.3/lib/capybara/selenium/driver.rb:67:in `reset!'
 /Users/ccashwell/.rvm/gems/ruby-1.9.3-p194@geostellar/gems/capybara-2.0.3/lib/capybara/session.rb:75:in `reset!'
 /Users/ccashwell/.rvm/gems/ruby-1.9.3-p194@geostellar/gems/capybara-2.0.3/lib/capybara.rb:253:in `block in reset_sessions!'
 /Users/ccashwell/.rvm/gems/ruby-1.9.3-p194@geostellar/gems/capybara-2.0.3/lib/capybara.rb:253:in `each'
 /Users/ccashwell/.rvm/gems/ruby-1.9.3-p194@geostellar/gems/capybara-2.0.3/lib/capybara.rb:253:in `reset_sessions!'
 /Users/ccashwell/.rvm/gems/ruby-1.9.3-p194@geostellar/gems/capybara-2.0.3/lib/capybara/cucumber.rb:10:in `Before'
出现模式对话框(Selenium::WebDriver::Error::UnhandleAlerError) [远程服务器]file:///var/folders/x6/4vcz8vmj5ls2dbc9b3x2qxvh0000gp/T/webdriver-profile20130927-61014-emm2oz/extensions/fxdriver@googlecode.com/components/command_processor.js:10521:in`nsCommandProcessor.execute'
[远程服务器]file:///var/folders/x6/4vcz8vmj5ls2dbc9b3x2qxvh0000gp/T/webdriver-profile20130927-61014-emm2oz/extensions/fxdriver@googlecode.com/components/driver\u component.js:7510:在'Dispatcher.executeAs/中,您应该尝试使用
。接受
,而不是
。关闭
。我很幸运地使用了
。在这些弹出窗口上接受
,然后关闭
。因此,您要尝试的完整行是

page.driver.browser.switch_to.alert.accept

哪一行给出了这个错误。你能给出你运行代码的链接吗…?你使用TurboLink吗?或者AJAX可能有提示。这里不使用TurboLink或任何AJAX。