0

I have a situation as shown on SS below.

Multiple pop ups problem

I am testing some web app with selenium (java) and in one moment I got 4 pop-ups at the same time. I want to dismiss them all, but actually I can't get 3 of them.

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. 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.

So, my problem is that I can't get remaining three pop ups and dismiss them, any hints or someone had same problems?

Thanks.

MiniH
  • 25
  • 2
  • 6
  • Did you try to switch to `defaultContent` after dismissing first alert with `switchTo().alert()`? – Fenio Feb 28 '18 at 07:58

2 Answers2

0

Try to get text of that pop up, String str = driver.switchTo().alert().getText() then try to switch from first pop to another

Vidhya Hari
  • 13
  • 1
  • 8
0

I had a similar problem and had to solve it using autoit instead of selenium. Try this (with page_title being the title of the popup window and assuming you are on a windows machine) :

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

Chuk Ultima
  • 987
  • 1
  • 11
  • 21
  • Thanks. Yes, it is windows. I found java example and this is working for me. But if possible, I would like to avoid using third party tools. Still, thank you! I appreciate it. – MiniH Feb 26 '18 at 13:24