ElementClickInterceptedException - Failing test case some times | Selenium Python Forum
S
Sambhav Puri Posted on 06/11/2020

Hi,

While executing a test case I have noticed some times my test case gets failed due to the following reason:

selenium.common.exceptions.ElementClickInterceptedException: Message: Element <input id="abcTab" name="tabname" type="submit"> is not clickable at point (x,y) because another element <div id="xyz"> obscures it

 

I tried creating a function isElementClickable with below logic to wait until the object is clickale. And, in genkeywords i am calling this function in getElement function along with isElementPresent and isElementVisible functions before performing any action. Still the problem persists. Can you suggest what I can do to resolve it.


try:
element = WebDriverWait(self.driver, 10).until(
EC.element_to_be_clickable(("xpath", "some text")))

return element

except Exception as e:
print(e)


0
09914040666 Replied on 07/11/2020

Hey

Kindly share your code zipped so that I can check.


S
Sambhav Puri Replied on 26/11/2020

Hi Jaspreet. Please find attached the code.


0
09914040666 Replied on 08/12/2020

Hey

The exception that you are getting comes up when you are trying to click on some element but there is some other element which is expecting the click before rest of the actions. It could be anything, a unexpected popup, or a notification which is blocking the code this is totally random. The getElement() function is doing work of checking the presence and visibility check and if they are true, then element is extracted. 

You can do few things, like you can add the commands to disble notifications on browsers, or check the presence of random pop up. Also, as you are using it with getElement() instead of calling it with isElementPresent() and isElementVisible(), call it inside the the check after the result for isElementPresent() and isElementVisible() hascame. Like this

Responsive image

 

Note : element_to_be_clickable() is just going to work in case of an element is visible and enabled such that you can click it. Do make sure you are using it on right place otherwise you are surely going to get exceptions.


Related Posts