0

我正在使用水豚、硒、webkit 和黄瓜。如何在无头浏览器中关闭弹出窗口?它总是默认接受“ok”。我的测试用例非常适合 selenium(我使用此代码page.driver.browser.switch_to.alert.dismiss),但对于无头浏览器失败。

这是我的测试用例

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"

感谢帮助

4

1 回答 1

0

最后我解决了。我必须在删除之前移动关闭弹出步骤,所以When I attempt to delete the keyword "kw1" from the index-keywords page and dismiss the popup我的步骤定义现在是

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
于 2013-09-24T14:01:28.317 回答