【问题标题】:Ruby Capybara handling alert/loading screenRuby Capybara 处理警报/加载屏幕
【发布时间】:2016-05-11 19:16:42
【问题描述】:

我们正在使用 Ruby Cucumber 框架。

下面是点击按钮的代码

 click_on(button_text)

但是当它点击我们应用程序中的一个按钮时,会出现一个加载屏幕。

它会抛出错误消息

unexpected alert open
 (Session info: chrome=50.0.2661.94)
 (Driver info: chromedriver=2.12.301325 (962dea43ddd90e7e4224a03fa3c36a421281abb7),platform=Windows NT 6.1 SP1 x86_64) (Selenium::WebDriver::Error::UnhandledAlertError)

请告诉我如何处理它

【问题讨论】:

    标签: rubygems cucumber capybara browser-automation


    【解决方案1】:

    “unexpected alert open”通常表示页面上打开了一个模态警告框,而不是 JS 驱动的加载指示器。您确定它没有打开确认、提示或警报吗?如果是,那么您可以像处理它一样

    accept_alert do
      click_on(button_text)
    end
    

    【讨论】:

      【解决方案2】:

      我尝试了所有选项,例如 accept_alert、page.driver.wait_until(page.driver.browser.switch_to.alert.dismiss) 等

      但是有些等待 15 秒的方法对我有用。

      【讨论】:

        猜你喜欢
        • 2022-01-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-01-02
        • 2014-03-07
        • 2018-10-13
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多