2013-09-23 28 views
0

我正在使用水豚,硒,webkit和黄瓜。 如何在无头浏览器中关闭弹出窗口?它总是默认接受“OK”。我的测试案例工作很好硒(我使用此代码),但无头浏览器失败。用水豚webkit测试javascript警报

这是我的测试案例

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" 

感谢您的帮助

+0

可能重复[如何测试与黄瓜的确认对话框?](http://stackoverflow.com/questions/ 2458632 /如何做测试-A-确认的对话中,用黄瓜) –

回答

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