0

1.Newsletter pop up shows up on my site.

2.This newsletter pop up modal can show up on any page within 3 minutes so I can not time it.

  1. This was making my automation script (using geb-spock) fail.

  2. In order to now show the newsletter pop up modal, I added a below cookies.

driver.manage().addCookie(new Cookie("signupNoThanks", "optedNoThanks"));

Error message

 `selenium.ElementClickInterceptedException` error i.e `Element <element1> is not clickable at point (1085,112) because another element <Newletter pop up modal> obscures it`

I tried to print the cookies and I can see it in the logs

[![Cookies log ss][1]][1]

Can anyone suggest what's wrong on the Firefox browser, cookies added by me works perfectly fine on chrome but fails some automated test cases sometimes on firefox. Is firefox blocking us because of some security reasons? [1]: https://i.stack.imgur.com/lS1r7.png

Shubhendu Pandey
  • 175
  • 1
  • 1
  • 6
  • Your setup code does not help much to pinpoint the root cause of the problem. The cookie seems to be there, what makes you think it is not? Do you see on screenshots that the modal is there despite the cookie? You did not describe that. Furthermore, did you try locally with Firefox? Maybe it is Firefox, not BrowserStack. Please learn what an [MCVE](https://stackoverflow.com/help/mcve) is and how to ask good questions. Nobody can read your mind, so you need to describe your problem clearly and ideally make it reproducible. – kriegaex Sep 23 '20 at 01:22

2 Answers2

0

The error does seem to be specific to cookies, as you are able to see the cookies in the log. The error 'Element is not clickable' is a generic error you can read more about it on Selenium Web Driver & Java. Element is not clickable at point (x, y). Other element would receive the click

Try the following ways to resolve this error

  • Try using a different selector like XPath to locate the element.
  • The element is not visible in the Viewport, could you try scrolling to the element before clicking on it?
  • Use Actions class to perform the click.
HN17
  • 24
  • 1
  • The problem with the pop up is that it is random, sometimes it appears and sometimes it doesn't and also we don't know when it will show up, pop can show up within 3 minutes. – Shubhendu Pandey Sep 23 '20 at 05:24
0

You could create an extension method for clicks used throughout the project and wrap it in a try catch for element intercepted exception. You could then accept the popup and continue on as normal without caring about it.

(below code is c#):

public static class SeleniumExtensions
{
   public static void ClickElement(this IWebElement element)
   {
      try
        {
          element.Click();
        } catch (ElementClickInterceptedException ex)
        {
          Console.WriteLine("Click was intercepted, attempting to dismiss pop up: ", ex);
          //Code to click or dismiss your popup goes here

          //retry click
          element.Click();
        }
    }
}

Then throughout the project instead of using the default selenium click use:

element.ClickElement();
Rushby
  • 869
  • 9
  • 18