[英]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.