单击警报内的“确定”按钮(Selenium IDE) [英] Click in OK button inside an Alert (Selenium IDE)

查看:120
本文介绍了单击警报内的“确定”按钮(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();

Ruby

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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆