I am running basic CRUD tests with python and lettuce using selenium webdriver.
All of my other tests run fine, but when I click "Delete", there is a modal dialog which asks the user to confirm that they want to delete that user. The moment the popup appears, I get the exception below. I have wasted 2 hours trying to get this to work. I would imagine there is a simple fix.
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 164, in check_response
raise exception_class(message, screen, stacktrace)
UnexpectedAlertPresentException: Message: u'Modal dialog present' ; Stacktrace:
at nsCommandProcessor.prototype.execute (file:///tmp/tmpeV2K89/extensions/fxdriver@googlecode.com/components/command_processor.js:11520:13)
The line in steps.py that is throwing the error is this.
world.browser.find_element_by_link_text("Delete User").click()
And the html for that element is this.
<a href="/users/5910974510923776/delete" onclick="return confirm('Are you sure you want to delete this user?');">Delete User</a>
d.switchTo().alert().accept();
(please find equivalent binding in python). If its a modal dialog then i guess u can try finding the locator of ok. – Vivek Singh Feb 8 '15 at 18:07driver.switch_to_alert.accept()
or evendriver.switch_to.alert.accept()
. I've found slightly differences on both mehods so thought that's important to advice for anyone struggling around that. The same thing applies to thedriver.switch_to.window()
method. – m3nda May 24 '16 at 1:11