【问题标题】:Getting "Exception UnexpectedAlertPresentException: Alert Text: None" and then "Exception NoAlertPresent" when I try to handle that alert当我尝试处理该警报时,得到“异常 UnexpectedAlertPresentException:警报文本:无”,然后是“异常 NoAlertPresent”
【发布时间】:2018-08-07 11:07:06
【问题描述】:

我们正在使用以下内容编写自动化脚本:

  • 表现==1.2.5
  • 分裂==0.7.7
  • firefox 无头浏览器

当导航到特定页面时,我们正在执行以下代码:

browser = context.browser
selector_button_checkout = "//*[@id='cart']//div[contains(@class, 'button button-3 localizejs') and text()='CHECKOUT']"
with browser.get_iframe(0) as iframe:
    assert iframe.is_element_present_by_xpath(selector_button_checkout, wait_time=30)

我们收到此错误:

packages/selenium/webdriver/remote/errorhandler.py", line 237, in check_response
          raise exception_class(message, screen, stacktrace)
      selenium.common.exceptions.UnexpectedAlertPresentException: Alert Text: None
      Message:

Exception UnexpectedAlertPresentException: Alert Text: None
Message: 

Traceback (most recent call last):
selenium.common.exceptions.UnexpectedAlertPresentException: Alert Text: None
Message: 

实际上,网络上没有显示任何警报或提示,但无论如何我们尝试使用此处提供的 Splinter 文档来处理它http://splinter.readthedocs.io/en/latest/iframes-and-alerts.html

我们得到另一个例外是NoAlertPresentException,所以我们迷路了。

有什么想法吗?

【问题讨论】:

    标签: python browser-automation splinter python-behave


    【解决方案1】:

    这可能会有所帮助:How to handle an Alert with "UnexpectedAlertBehaviour" capability in Selenium?

    对我们来说,我们使用 FacebookWebDriver 进行了 Codeception,有时当您尝试单击或访问不存在或不可见的成员时,它会失败并出现上述错误。

    所以转到问题页面并检查该元素(css 或 xpath)是否可见、可点击等。您可以使用浏览器控制台,使用 $() 作为查询路径,使用 $x() 作为 xpath。

    【讨论】:

      猜你喜欢
      • 2018-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-09-29
      • 1970-01-01
      • 2017-12-24
      • 2011-08-03
      相关资源
      最近更新 更多