【问题标题】:How to detect if there any javascript alert box is opened on browser? if yes, How to close it using ruby and selenium如何检测浏览器上是否打开了任何 javascript 警告框?如果是,如何使用 ruby​​ 和 selenium 关闭它
【发布时间】:2016-06-06 00:31:42
【问题描述】:

在使用 selenium 功能从一个页面导航到另一个页面时,有时会出现确认框并带有确定和取消选项。那么如何检测该框并将其关闭。

提前致谢!

【问题讨论】:

  • 切换到警报窗口时必须尝试/捕捉。

标签: javascript ruby selenium


【解决方案1】:
wait = Selenium::WebDriver::Wait.new
alert = wait.until { page.driver.browser.switch_to.alert }
alert.accept # to accept alert
alert.dismiss # to dismiss alert

希望对你有帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-03-31
    • 1970-01-01
    • 2023-03-14
    • 1970-01-01
    • 2018-06-04
    • 1970-01-01
    • 2022-11-29
    • 2015-04-09
    相关资源
    最近更新 更多