Python Selenium UnexpectedAlertPresentException [英] Python Selenium UnexpectedAlertPresentException

查看:330
本文介绍了Python Selenium UnexpectedAlertPresentException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Selenium Webdriver使用python和生菜运行基本的CRUD测试.

I am running basic CRUD tests with python and lettuce using selenium webdriver.

我所有其他测试运行正常,但是当我单击删除"时,出现一个模式对话框,要求用户确认他们要删除该用户.弹出窗口出现的那一刻,我在下面得到了例外.我浪费了2个小时试图使它正常工作.我想有一个简单的解决方法.

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)

steps.py中引发错误的行是这个.

The line in steps.py that is throwing the error is this.

  world.browser.find_element_by_link_text("Delete User").click()

该元素的html是这个.

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>

推荐答案

您需要

这篇关于Python Selenium UnexpectedAlertPresentException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆