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/[email protected]/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>
Selenium 3 is incompatible with Python 3.9 #8762.
In selenium you can get and set cookies with the methods get_cookies() and add_cookie(). Related course: Selenium Web Automation Course & Examples.
New Selenium IDE It ignores the trailing and leading spaces. First of all we need to identify the element with help of any of the locators like id, class, name, xpath or css and then apply getText() method on it to get the text content of the element.
You need to switch to the alert and accept it:
world.browser.find_element_by_link_text("Delete User").click() alert = world.browser.switch_to.alert alert.accept()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With