2

If there is an element that is overlapped by another element (like on this internal Selenium test page), I get an ElementClickInterceptedException. It looks like I cannot check this beforehand, only after the exception is thrown via the exception message.

It's not about making the click pass (I can simply force it via JavaScript or wait if the overlap is only temporary), but about checking for the overlap to prevent the invocation of WebElement#click(). Is this possible?

beatngu13
  • 7,201
  • 6
  • 37
  • 66
Creepow
  • 21
  • 1
  • 2
  • Did you try action class? – KunduK Nov 04 '19 at 16:27
  • If you mean something similar to `action.moveToElement( element ).click().perform();` then yes. It works just like js to make the click pass, but how would this help with getting to know if there is an overlapping element? Am i missing on something? – Creepow Nov 04 '19 at 17:20
  • 1
    There is no option in selenium till today to verify whether element overlapping or not. – KunduK Nov 04 '19 at 20:50
  • 1
    @DebanjanB that comment probably isn't very helpful to the OP. How should he look for the z-axis, what should be checked? – beatngu13 Nov 05 '19 at 08:25
  • @beatngu13 Agree, with the current amount of information provided it's near impossible to construct any canonical answer. But in those cases _Z axis_ holds the key. A [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) is needed. – undetected Selenium Nov 05 '19 at 08:47
  • 1
    @DebanjanB OP asks about a general approach to check for overlapping elements _before_ executing a click. Could you elaborate how he can use the z-axis to achieve this? – beatngu13 Nov 05 '19 at 20:57

1 Answers1

2

You can't check beforehand but what you can do is add a try-catch to a click method and catch the ElementClickInterceptedException and retry the click until the exception is no longer thrown or a timeout occurs.

JeffC
  • 22,180
  • 5
  • 32
  • 55