单击警报内的“确定"按钮(Selenium IDE)

编程入门 行业动态 更新时间:2024-10-26 08:33:08
本文介绍了单击警报内的“确定"按钮(Selenium IDE)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要使用 Selenium 命令单击警报窗口内的确定"按钮.我试过 assertAlert 或 verifyAlert 但他们没有做我想要的.

I need to click the 'Ok' button inside an alert window with a Selenium command. I've tried assertAlert or verifyAlert but they don't do what I want.

可以单击确定"按钮吗?如果是这样,有人可以为我提供 Selenium IDE 命令的示例吗?

It's possible the click the 'Ok' button? If so, can someone provide me an example of the Selenium IDE command?

推荐答案

尝试 Selenium 2.0b1.它的核心与第一个版本不同.根据文档,它应该支持弹出对话框:

Try Selenium 2.0b1. It has different core than the first version. It should support popup dialogs according to documentation:

从 Selenium 2.0 beta 1 开始,内置了对处理弹出对话框的支持.在您触发并打开弹出窗口的操作后,您可以通过以下方式访问警报:

Starting with Selenium 2.0 beta 1, there is built in support for handling popup dialog boxes. After you’ve triggered and action that would open a popup, you can access the alert with the following:

Java

Alert alert = driver.switchTo().alert();

红宝石

driver.switch_to.alert

这将返回当前打开的警报对象.有了这个对象,你现在可以接受、关闭、阅读它的内容,甚至可以输入提示.该界面同样适用于警报、确认、提示.有关详细信息,请参阅 JavaDocs.

This will return the currently open alert object. With this object you can now accept, dismiss, read it’s contents or even type into a prompt. This interface works equally well on alerts, confirms, prompts. Refer to the JavaDocs for more information.

更多推荐

单击警报内的“确定"按钮(Selenium IDE)

本文发布于:2023-11-27 15:49:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638630.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   单击   按钮   quot   Selenium

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!