是否有特定的功能来处理Serenity BDD中的警报(Is there a specific function to handle alert in Serenity BDD)

编程入门 行业动态 更新时间:2024-10-25 16:17:06
是否有特定的功能来处理Serenity BDD中的警报(Is there a specific function to handle alert in Serenity BDD)

是否有任何函数/类来处理浏览器中的警报或任何其他类型的弹出窗口。 我正在处理一个警报弹出窗口,我知道我可以通过使用driver.switchto().alert();来处理它driver.switchto().alert(); 并执行进一步的操作。 由于Serenity BDD非常适合处理元素,因此可以使用任何特定功能来处理警报(仅限于使用宁静的BDD功能)。

Is there any function/class to handle alert or any other types of popups in a browser. I am dealing with an alert popup I know I can handle it by using driver.switchto().alert(); and perform further actions. Since Serenity BDD is quite tailored to handle elements is there any specific function to handle alerts (only by using serenity BDD functions).

最满意答案

这就是Serenity PageObject的getAlert()方法的样子:

public Alert getAlert() { return driver.switchTo().alert(); }

这是driver对象引用的内容:

private WebDriver driver;

正如您可能已经猜到的那样, WebDriver类型/对象来自Selenium。 因此,回答你的问题,是的,Serenity中有一种方法可以获取警报弹出窗口,但它是对Selenium的直接引用。

This is what Serenity PageObject's getAlert() method looks like:

public Alert getAlert() { return driver.switchTo().alert(); }

And this is what driver object references:

private WebDriver driver;

As you might have guessed it already, the WebDriver type/object comes from Selenium. Hence to answer your question, yes there is a method in Serenity to grab alert popups, but it's a direct reference to Selenium.

更多推荐

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

发布评论

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

>www.elefans.com

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