简体   繁体   中英

How to automatically handle alerts with Splinter in Python

I am using the Python wrapper for Selenium, Splinter, to make purchases on an online store. Randomly, the browser throws an UnexpectedAlertPresentException. I don't know where in my process this error will be thrown, and it seems ridiculous to check for this alert and dismiss it all the time. Is there a way to specify to the driver that alerts should be automatically dismissed?

You can override the window.alert method using browser.execute_script. See for eg. http://itreallymatters.net/post/1482786902/testing-webpages-with-javascript-popups-correctly#.VUvFhNS1Gko

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM