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

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