Handle Random Popup | Selenium Forum
M
Posted on 29/08/2015
Hi Ashsish Sir,
I need help sir.The application I am working on is kind of e-commerce application. My issue is - the website displays an popup (This popup is Feedback/Customer experiece). The issue is this popup is random in nature,this popup is displayed randomly at any page or for any step.
Can you please help how to handle this popup. In one of the website i saw the following solution . But I am not able to implement this.

Solution: Webdriver provides WebDriverEventListener interface so that you can register your listener with WebDriver and execute custom code based on the events fired by WebDriver.

public class PopUpListener implements WebDriverEventListener {
//Override all the methods present in WebDriverEventListener interface

public void afterClickOn(WebElement element,
WebDriver driver){
//code here to dismiss popup

}
}


Register the listener with webDriver

WebDriverEventListener popupListener = new PopUpListener ();
WebDriver driver = new EventFiringWebDriver(new FirefoxDriver())
.register(popupListener);

M
Replied on 30/08/2015

Please let me know if you see any website outside which is having the same scenario


M
Replied on 30/08/2015

I will look at couple of sites and will try to post.


M
Replied on 04/09/2015

what kind of pop up are you getting?

window/alert/confirm/prompt


but basic approach is make 2 functions 1 to check

if the there are more then 1 window
if yes call
call another function which handles it.