简体   繁体   English

如何使用Selenium Firefox WebDriver处理多个弹出窗口

[英]How to handle multiple pop-ups with selenium firefox webdriver

I have a situation as shown on SS below. 我的情况如下面的SS所示。

多个弹出窗口问题

I am testing some web app with selenium (java) and in one moment I got 4 pop-ups at the same time. 我正在用selenium(java)测试一些Web应用程序,有一次我同时获得4个弹出窗口。 I want to dismiss them all, but actually I can't get 3 of them. 我想解雇所有这些人,但实际上我无法得到其中的3个。

I was searching how to handle multiple pop ups, and found this topic: How to handle multiple alert popup confirmation in selenium? 我正在搜索如何处理多个弹出窗口,并找到了以下主题: 如何处理硒中的多个警报弹出窗口确认? - but that is not what I'm searching for. -但这不是我要寻找的。

First time driver.switchTo().alert() is returning an alert and I can dismiss it. 第一次driver.switchTo()。alert()返回警报,我可以将其关闭。 But second time, it is null and impossible to switch on remaining pop ups. 但是第二次,它是无效的,不可能打开剩余的弹出窗口。

I also tried things from this topic ( https://sqa.stackexchange.com/questions/8416/how-to-switch-handle-close-particular-popup-window-when-multiple-popups-are-ope ) with driver.getWindowHandles(), but it returns only one handle, so there is no multiple windows to switch. 我还尝试了使用驱动程序从该主题( https://sqa.stackexchange.com/questions/8416/how-to-switch-handle-close-particular-popup-window-when-multiple-popups-are-ope )进行操作.getWindowHandles(),但它仅返回一个句柄,因此没有多个窗口可以切换。

So, my problem is that I can't get remaining three pop ups and dismiss them, any hints or someone had same problems? 因此,我的问题是我无法剩下三个弹出窗口并关闭它们,是否有任何提示或有人遇到相同的问题?

Thanks. 谢谢。

尝试获取该弹出窗口的文本,字符串str = driver.switchTo()。alert()。getText(),然后尝试从第一个弹出窗口切换到另一个弹出窗口

I had a similar problem and had to solve it using autoit instead of selenium. 我有一个类似的问题,必须使用autoit而不是硒来解决。 Try this (with page_title being the title of the popup window and assuming you are on a windows machine) : 试试看(使用page_title作为弹出窗口的标题,并假设您在Windows计算机上):

from win32com.client import Dispatch
autoit = Dispatch("AutoItX3.Control")

def _window_movement_windows(page_title):
        autoit.WinSetOnTop(page_title, "", 1)
        autoit.WinActivate(page_title, "")
        autoit.WinWaitActive(page_title)

Here's how to install and use AutoIt : Calling AutoIt Functions in Python 这是安装和使用AutoIt的方法: 在Python中调用AutoIt函数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Selenium 2.0(WebDriver)处理Windows弹出窗口? - How to handle windows pop ups using selenium 2.0 (webdriver)? 通过Selenium Webdriver(3.x)处理自定义弹出窗口(不是默认窗口) - Handling custom pop-ups (not the default windows one) through selenium webdriver (3.x) 无法使用 Robot 类处理 Windows 10 弹出窗口 - Unable to handle Windows 10 pop-ups using Robot class 处理在Java / Selenium中停止处理的浏览器弹出窗口 - Handling browser pop-ups that stop processing in Java/Selenium 如何使用带有Java的Selenium Webdriver处理允许弹出的Firefox插件 - How do I handle allow pop-up of plug-in for firefox using Selenium Webdriver with Java 使用Selenium Webdriver下载excel时如何处理firefox中的下载弹出窗口 - How to handle download pop-up in firefox, while downloading excel using Selenium Webdriver 在eclipse插件中动态更改弹出窗口 - Changing pop-ups dynamically in eclipse plugin 是否可以使用 Java 中的 JOptionPane 同时显示多个弹出窗口? - Is it possible to have multiple pop-ups present at the same time using the JOptionPane in java? 如何处理硒webdriver中具有空白ID的弹出窗口? - How to handle pop up windows with blank id in selenium webdriver? 如何在 selenium webdriver 中处理 Javascript 警报/弹出窗口 - How to handle Javascript Alert/pop up window in selenium webdriver
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM