如何使用“UnexpectedAlertBehaviour”处理警报硒的能力?

编程入门 行业动态 更新时间:2024-10-27 22:25:14
本文介绍了如何使用“UnexpectedAlertBehaviour”处理警报硒的能力?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在selenium framework 2.25中,我看到我们有UnexpectedAlertBehaviour枚举类型,但我不知道如何使用它。

In selenium framework 2.25, I see that we have the UnexpectedAlertBehaviour enum type, but I don't know how to use it.

推荐答案

我在你的问题上找到了这部分文件:这对其他人也很有用:

I found this portion of documentation on your issue: This may be useful for other people as well:

v2.25.0

=======

WebDriver:

WebDriver:

  • 添加了用于处理BASIC和DIGEST身份验证的API

  • Added API for dealing with BASIC and DIGEST authentication

对话框。目前尚未在任何驱动程序中实现。

dialogs. Currently not implemented in any drivers.

警告用户IE驱动程序将不再使用

Warn users that the IE driver will no longer use the DLL in the

下一个版本。

不推荐使用浏览器的特定WebElement子类。

Deprecated browser specific WebElement subclasses.

已添加支持requiredCapabilities到远程webdrivers

Added support for "requiredCapabilities" to the remote webdrivers

并在firefox

驱动程序中实现对这些驱动程序的基本支持。如果未能满足所需的能力,将导致抛出

driver. Failure to fulfull a required capability will cause a

SessionNotCreatedException。

SessionNotCreatedException to be thrown.

添加了确定未处理的警报应如何处理的功能。这由unexpectedAlertBehaviour功能处理,可以是accept,dismiss或ignore之一。 Java代码应该使用UnexpectedAlertBehaviour 枚举。这仅在Firefox中实现。

允许在Firefox中配置本机事件和

Allow native events to be configured in Firefox and

(实验性)。

将支持的Firefox版本更新为17。

Updated supported versions of Firefox to 17.

.....

提供的整个清单此处

这是来源

package org.openqa.selenium; public enum UnexpectedAlertBehaviour { ACCEPT ("accept"), DISMISS ("dismiss"), IGNORE ("ignore") ; private String text; private UnexpectedAlertBehaviour(String text) { this.text = text; } @Override public String toString() { return String.valueOf(text); } public static UnexpectedAlertBehaviour fromString(String text) { if (text != null) { for (UnexpectedAlertBehaviour b : UnexpectedAlertBehaviour.values()) { if (text.equalsIgnoreCase(b.text)) { return b; } } } return null; } }

我看到你使用unexpectedAlertBehaviour来决定警报是否是未经处理,如果是这样,你将决定如何处理它。

As I see you use unexpectedAlertBehaviour to decide whether alert is unhandled and if it is so, you'll decide how to handle it.

我想它应该是(我的假设):

I suppose it should be something like (my assumption):

try{ alert.accept(); } catch(org.openqa.selenium.UnexpectedAlertBehaviour){ ///...blablabla }

更多推荐

如何使用“UnexpectedAlertBehaviour”处理警报硒的能力?

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

发布评论

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

>www.elefans.com

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