您将如何使用Selenium Webdriver检查是否存在弹出窗口?

编程入门 行业动态 更新时间:2024-10-25 05:28:18
本文介绍了您将如何使用Selenium Webdriver检查是否存在弹出窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在应用程序上运行链接测试,其中一个链接会弹出一个登录弹出窗口.有没有办法检查?我尝试将其视为警报,但没有用.

I am running link tests on an application and one of the links brings up a login popup window. Is there a way to check for that? I tried treating it like an alert but it didn't work.

try { WebDriverWait wait = new WebDriverWait(driver, 2); wait.until(ExpectedConditions.alertIsPresent()); Alert alert = driver.switchTo().alert(); alert.accept(); reportAlertPresent = true; }

推荐答案

如果弹出窗口位于iframe中,则

If your popup is inside an iframe then,

WebElement frameID = driver.findElement(By.(locator)); driver.switchTo().frame(frameID);

如果它是一个窗口,则可以使用窗口句柄.以下链接可能会有帮助

If it is a window, you can use window handles. the below links might help

www.thoughtworks/products /docs/twist/2.3/help/how_do_i_handle_popup_in_selenium2.html

如何处理Selenium WebDriver中的弹出窗口使用Java

更多推荐

您将如何使用Selenium Webdriver检查是否存在弹出窗口?

本文发布于:2023-11-27 16:04:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638675.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:您将   如何使用   是否存在   弹出窗口   Selenium

发布评论

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

>www.elefans.com

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