Reputation: 3376
i am using caoybara , selenium and cucumber . i wana click an alert box with 'ok' button. help me out this code is not clicking the button:
page.evaluate_script('window.confirm = function() { return true; }')
page.click("Ok")
Upvotes: 3
Views: 3912
Reputation: 4568
Jon's didn't work for me probably because I'm using a newer version of capybara (2.1.0)
This worked for me:
page.evaluate_script('window.confirm = function() { return true; }')
Upvotes: 0
Reputation: 11705
Get a reference to the alert using the following:
alert = page.driver.browser.switch_to.alert
And then
alert.accept
To hit 'Ok'
Upvotes: 12