i am using capybara , selenium ,webkit,and cucumber.
How I can dismiss the popup in headless browser? It always by default accept "ok". My test case works great selenium(I use this code page.driver.browser.switch_to.alert.dismiss
) but fails for headless browser.
This is my test case
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"
Thanks for help
Finally I solved it. I have to move dismiss popup step before delete so something like When I attempt to delete the keyword "kw1" from the index-keywords page and dismiss the popup
and my step definition is now
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