Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

This page is asking you to confirm that you want to leave

I am running the behat tests on my site installation. I am getting the following errors when running the tests. I switched into using firefox, because I had issues with the new chromedriver 2.10. Can I work around this one?

Error message:

Modal dialog present: This page is asking you to confirm that you want to leave - data you have entered may not be saved.

Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:11:15'
System info: host: 'jesus-ProLiant-MicroServer', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-32-generic', java.version: '1.6.0_32'

Session ID: 2d072ef8-60e8-494b-b389-96e954041fb0
Driver info: org.openqa.selenium.firefox.FirefoxDriver

Capabilities [{platform=LINUX, acceptSslCerts=true, javascriptEnabled=true, browserName=firefox, rotatable=false, locationContextEnabled=true, version=31.0, cssSelectorsEnabled=true, databaseEnabled=true, handlesAlerts=true, nativeEvents=false, webStorageEnabled=true, applicationCacheEnabled=true, takesScreenshot=true}]
like image 445
Potney Switters Avatar asked Mar 18 '23 14:03

Potney Switters


2 Answers

You are (officially) out of luck with this. Behat / Mink does not support dialogue handling and throws exceptions when finds one, because it can do nothing about it and it blocks the following steps. There is a long standing issue on github that explains the reasons and I agree with Alexander's last comment:

Nowadays browser dialogs are considered bad UX and are replaced by nice looking modal windows (at least on websites I was doing), which already can be handled.

Unofficially it's possible if you do a direct call on Selenium Driver, this gist is the best example of how to do it. You can find more about it if you search for "selenium modal window" without Behat references.

$this->getSession()->getDriver()->getWebDriverSession()->accept_alert(); // Ok
$this->getSession()->getDriver()->getWebDriverSession()->dismiss_alert(); // Dismiss
like image 170
Ian Bytchek Avatar answered Apr 25 '23 15:04

Ian Bytchek


I switched into using firefox, because I had issues with the new chromedriver 2.10. Can I work around this one?

I had similar issues when working with Behat/Mink/Selenium and chromedriver 2.10, an upgrade to chromedriver 2.17 fixed the issues for me.

[http://chromedriver.storage.googleapis.com/2.17/chromedriver_linux64.zip][1]

like image 23
DrColza Avatar answered Apr 25 '23 14:04

DrColza