How to handle a Pop up which shows up randomly in any page while browsing website

While i run the test, the popup is shown randomly in any web page. So it cant able to close the popup that make the test failure.

Please help to resolve the issue.

While it’s essentially random, I believe it may not be reproduced after it’s appeared once (based on cookies, I guess).

You could visit the home page, wait for the popup to appear, clear it, then move on with your test.

Not ideal, but it’s all I can think of without modifying the AUT to suit testing (which is a bad thing to do).

How about creating a Custom Keyword that you pass your Test Object to for all your click statements? The Custom Keyword has a try / catch block for when your click event is “captured” by another element (I can’t remember what the event is called at this time). In the catch clause, you test for the presence of some of the pop-up text, like “Creates an account …Loyalty Rewards Program”, and if it’s found, then call another process to deal with it.

def void testClick(TestObject to) {
    try {
      WebUI.click(to)
    } catch (WhateverItIsCalledException ex) {
       if (WebUI.verifyTextPresent('Create an account and join our Loyalty Rewards Program.', false) {
   // deal with your pop-up

   // and lastly
         WebUI.click(to)
      }
   }
}
1 Like