Ruby on rails 3 使用Capybara webkit测试javascript警报

Ruby on rails 3 使用Capybara webkit测试javascript警报,ruby-on-rails-3,cucumber,capybara-webkit,Ruby On Rails 3,Cucumber,Capybara Webkit,我正在使用水豚、硒、webkit和黄瓜。 如何在无头浏览器中关闭弹出窗口?默认情况下,它始终接受“ok”。我的测试用例在selenium中运行得很好(我使用此代码page.driver.browser.switch_to.alert.discouse),但在headless browser中失败 这是我的测试用例 Feature: Deleting keywords In order to use the app I need to be able to delete keywords

我正在使用水豚、硒、webkit和黄瓜。 如何在无头浏览器中关闭弹出窗口?默认情况下,它始终接受“ok”。我的测试用例在selenium中运行得很好(我使用此代码
page.driver.browser.switch_to.alert.discouse
),但在headless browser中失败

这是我的测试用例

Feature: Deleting keywords
  In order to use the app
  I need to be able to delete keywords

  Background:
    Given the database contains no test data
    Given there are accounts and users
    And I am on the homepage
    And I am signed in as "user"

  Scenario:  Successfully deliting keyword 
    When I create the following keywords:
      | keyword   | descrip   | title    |
      | kitty  | hello  | Fluffy   | 

    Then I should see "Keyword created."
    When I follow "Keywords"
    Then I should see "kitty"
    When I attempt to delete the keyword "kitty"
    And I dismiss popup 
    Then there should be 1 keyword
    Then I should see "kitty"

谢谢你的帮助,我终于解决了。在删除之前,我必须移动“取消弹出窗口”步骤,这样当我尝试从“索引关键字”页面中删除关键字“kw1”并取消弹出窗口时,我的步骤定义如下

When(/^I attempt to delete the keyword "(.*?)" from the index\-keywords page and dismiss the popup$/) do |keyword|
  page.driver.dismiss_js_confirms!
  delete_keyword_from_keywords_index_page(keyword)
end
可能重复的