14

I'm trying to submit one form on wordpress plugin using selenium + python. When I press publish button , it is giving an error.

ElementClickInterceptedException: element click intercepted: Element type="submit" name="publish" id="publish" class="button button-primary button-large" value="Publish"> is not clickable at point (728, 15). Other element would receive the click: ...

I have tried following solutions: Used action driver, but it didn't work. Used webdriverwait() function, it didn't work. Used Xpath, CSS selector, ID - It's giving same error in all three.

 `    browser.find_element_by_css_selector("""#save-post""").click()

    WebDriverWait(driver, 90).until(EC.element_to_be_clickable((By.ID, "save-post"))).click()
`

Note that when I run that specific line in python console, it is working. But while running the full script, it is showing error.

There are so many similar questions on portal but none of them worked. Kindly help me to solve this issue.

Nirav says
  • 141
  • 1
  • 1
  • 3

1 Answers1

25

Ok, the answer is in error message - "Other element would receive the click: ..." I had the same problem when I just started using selenium.

Couldn't figure out what's the problem. "Other element would receive the click: ..." means there is other element above(overlapping) your element(pop up window, page is grayed out or disabled while loading, Some JS running etc., so when Selenium trying to click on your element its actually clicking on that blocking element.

Selenium is running really fast and clicking before its become clickable, that's why u are not able to click on it - "when I run that specific line in python console, it is working" Try to click after time.sleep() 5-10 sec or run script with debug mode.

If this is the case then you can use wait or add condition before find your element to check that element that prevent from clicking on you element is not there then u click on your element.

IPolnik
  • 619
  • 5
  • 13
  • 3
    in some cases the sleep will not help because there is an element intentionally overlaying the element to intercept the click. In that case you can try clicking the overlapping element first. (this element may do something and then send the click to the item you are originally trying to click... so sometimes that is all that is necessary) – pcalkins Jun 26 '19 at 20:25
  • 1
    I agree, but based on what he is saying - "when I run that specific line in python console, it is working". Sleep or wait condition should work in this case. Because when he is debugging, execution speed is slower and at the moment when he is clicking blocking element already not there. I would suggest, find that element that getting click first using debugging in browser(dev tool), then write simple while loop(checking if blocking element is presents wait 1-2 sec) with timeout(throw exception if its still there after sometime, just in case). – IPolnik Jun 26 '19 at 20:42
  • 1
    @IPolnik thank you. but can you tell me how can I find which element is blocking it ? – Nirav says Jun 28 '19 at 03:22
  • Unfortunately, I can't tell you, but if u can share this web page with me, I can take a look. – IPolnik Jun 28 '19 at 15:12
  • It's Wordpress website. I am trying to post a post. Can you look now? I can not share webpage because it needs an admin credentials.@IPolnik – Nirav says Jun 29 '19 at 03:10
  • 2
    @Niravsays In my case, the error message gave me the exact element intercepting the click "Other element would receive the click: `
    – Claire Sep 14 '19 at 08:44
  • 2
    Try scrolling into the element and then attempt to click it – Srinivasan Ramu Feb 25 '20 at 19:19
  • @IPolnik you mention a possible cause of the 'click being intercepted' exception is the element grayed out/disabled. How would I deal with this exception for a greyed out element (in DOM, aria-disabled="true" )? Is there a specific workaround? – Anne Bailly Jan 15 '22 at 20:48
  • 1
    I tried scrolling the element to view, added a time sleep of 5 seconds, and then finally click. Worked well for me :) – Libin Thomas Oct 11 '22 at 15:43