本文介绍了您将如何使用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检查是否存在弹出窗口?
发布评论