Handle Random Popup

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())

Default Asked on August 30, 2015 in Selenium WebDriver.
Add Comment
  • 1 Answer(s)


    My answer is in Java using try/catch statement as you are not sure where the pop up comes please call the method in catch statement and this solves your problem..

    Default Answered on August 31, 2015.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.