-1

I'm using Selenium to search for element's and click them (localhost website) and sometimes the code runs perfectly and sometimes I get an error right after the website loads or while loading. Error:

"Message: System.InvalidOperationException : unknown error: Element <span _ngcontent-c8="" class="ui-link-button" fxlayout="row" fxlayoutalign="start center" ng-reflect-klass="ui-link-button" ng-reflect-ng-class="[object Object]" ng-reflect-layout="row" ng-reflect-align="start center" style="flex-direction: row; box-sizing: border-box; display: flex; max-height: 100%; place-content: center flex-start; align-items: center;">...</span> is not clickable at point (219, 113). Other element would receive the click: <ui-spinner _ngcontent-c0="" _nghost-c1="">...</ui-spinner>
(Session info: chrome=63.0.3239.84) (Driver info: chromedriver=2.34.522940
(1a76f96f66e3ca7b8e57d503b4dd3bccfba87af1),platform=Windows NT 10.0.14393 x86_64)"

My driver has implicit wait for 60 seconds so I don't think it because the site isn't loading fast enough.

   public class Driver
    {
        public static IWebDriver driver { get; set; }

        public static void WaitForElementUpTo(int seconds = 60)
        {
            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(seconds));
        }
    }

I'm using Chrome driver.

Ratmir Asanov
  • 6,237
  • 5
  • 26
  • 40
Udi
  • 49
  • 9
  • Wait for the element you want to click to be visible, seems another element receives the click `ui-spinner`, you need some wait. – lauda Jan 03 '18 at 09:38
  • I am waiting (60 seconds) – Udi Jan 03 '18 at 09:51
  • Please create a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) of your problem – Liam Jan 03 '18 at 09:56
  • Possible duplicate of [Selenium Web Driver & Java. Element is not clickable at point (36, 72). Other element would receive the click:](https://stackoverflow.com/questions/44912203/selenium-web-driver-java-element-is-not-clickable-at-point-36-72-other-el/44916498#44916498) – undetected Selenium Jan 03 '18 at 10:14
  • Have a look at https://stackoverflow.com/questions/11908249/debugging-element-is-not-clickable-at-point-error – racraman Jan 03 '18 at 10:54
  • The message is certainly implying that you didn't wait long enough..."Other element would receive the click: – Breaks Software Jan 03 '18 at 14:45

3 Answers3

0

Try using explicit wait wand wait till element is clickable

SachinB
  • 348
  • 6
  • 18
0
 Other element would receive the click: <ui-spinner _ngcontent-c0="" _nghost-c1="">...</ui-spinner>

This would suggest that you have a loading spinner blocking the click to your element. As others have suggested, use an explicit wait:

wait.Until(ExpectedConditions.ElementIsClickable(By.Id("abc")))
MonkeyTester
  • 139
  • 5
  • Thanks for the answer Momkey Tester. Im trying to pass an element that should be clickable after the spinner stops working (using xpath) but i get the same error (randomly). is there way to pause for lets say 15 seconds and resume (like Thread.Sleep(15)) – Udi Jan 04 '18 at 10:25
  • Well you could just use Thread.Sleep() if that is all you want to do, but using an explicit wait is the "correct" way to do it. – MonkeyTester Jan 04 '18 at 11:44
  • I think an Implicit wait will make the webdriver wait until the element is available, but it may still be in an unclickable state (i.e. if the spinner hasn't disappeared yet). – MonkeyTester Jan 04 '18 at 11:46
  • From the documentation: WARNING: Do not mix implicit and explicit waits. Doing so can cause unpredictable wait times. For example setting an implicit wait of 10 seconds and an explicit wait of 15 seconds, could cause a timeout to occur after 20 seconds. – MonkeyTester Jan 04 '18 at 11:47
  • WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromMinutes(1)); IWebElement el = wait.Until(ExpectedConditions.ElementIsClickable(By.Id("myid"))); – MonkeyTester Jan 04 '18 at 11:49
  • Tried what you have suggested but im still getting the same error. – Udi Jan 04 '18 at 12:31
  • Tried adding wait.Until(ExpectedConditions.InvisibilityOfElementLocated(By.Id("//* [@id=\"spinner12\"]/div"))); And it didnt work aswell – Udi Jan 04 '18 at 15:08
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/162590/discussion-between-monkeytester-and-udi). – MonkeyTester Jan 05 '18 at 11:24
0

Finally i used this function in order to wait for the spinner to nolonger exist and then continue with the scenario :

    WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60));
    wait.Until<bool>((d) =>
    {
        try
        {
            IWebElement element1 = d.FindElement(By.CssSelector(element));
            return false;
        }
        catch (NoSuchElementException)
        {
            return true;
        }
    });
}
Udi
  • 49
  • 9