I have searched many, many places for a solution to my problem, but haven't found it. I figured that by now, Selenium would have provided a straight forward and simple solution to handling modal windows/dialogs from Internet Explorer using Java.
The web application that I am testing has the following characteristics:
- It is ONLY supported by Internet Explorer (no way around this)
- Main page accepts a userid and password, with a "Login" button
- Upon login and on page load, there is a pop up "Welcome - What's new" window with a checkbox to "Don't display this again" and an "OK" button to dismiss the window.
- I cannot do anything to the parent window until I dismiss the pop up window
- Right-click is disabled on the pop-up window (however, I can see the source code by opening the F12 tools before login and window pop-up)
This is what I've tried:
getWindowHandles()always returns 1 for the parent window, so this makesdriver.switchTo(handle)not-applicable- It is not an alert, so
driver.switchTo().alert()oraccept()do not work findElement(By whatever)will NOT find any elements in the pop up window (like the "OK" button or the checkbox, etc.)Robotclass is the only thing that I have seen work, where I can send keypresses to navigate to the "OK" button and click it to dismiss the window...
Here is my issue:
- Since there is a checkbox to "Don't show this again", there are users for which this modal pop up window will display and some for which it won't. I need to account for both cases
- I need to find a 100% sure way to know whether the pop up is displayed or not. If I have this information, I can make use of the Robot class (although "dirty") to perform actions on the pop up if needed
- I tried finding out if the parent window elements are enabled using
isEnabled(), but even though items are not manually "clickable" while the modal pop up window is displayed,isEnabled()always returns TRUE--so this does not work--is there a better way to check for this for the "blocked" elements in the background?
My questions:
- How do you check for the existence of a modal pop up that does not display 100% of the time? (on Internet Explorer 10, using Selenium with Java)
- Besides using Robot class, how do you interact with the actual Elements in a modal pop-up dialog (for example, dynamic Radio Buttons that don't always display the same options to the user)?
Thank you.