Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/378.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何检测浏览器上是否打开了任何javascript警报框?如果是,如何使用ruby和selenium关闭它_Javascript_Ruby_Selenium - Fatal编程技术网

如何检测浏览器上是否打开了任何javascript警报框?如果是,如何使用ruby和selenium关闭它

如何检测浏览器上是否打开了任何javascript警报框?如果是,如何使用ruby和selenium关闭它,javascript,ruby,selenium,Javascript,Ruby,Selenium,当使用selenium功能从一个页面导航到另一个页面时,有时会出现带有ok和cancel选项的确认框。那么如何检测这个盒子并消除它 提前谢谢 wait = Selenium::WebDriver::Wait.new alert = wait.until { page.driver.browser.switch_to.alert } alert.accept # to accept alert alert.dismiss # to dismiss alert 希望有帮助 切换到警报窗口时,您必须

当使用selenium功能从一个页面导航到另一个页面时,有时会出现带有ok和cancel选项的确认框。那么如何检测这个盒子并消除它

提前谢谢

wait = Selenium::WebDriver::Wait.new
alert = wait.until { page.driver.browser.switch_to.alert }
alert.accept # to accept alert
alert.dismiss # to dismiss alert

希望有帮助

切换到警报窗口时,您必须尝试/捕获。