Selenium Webdriver with Python: element is not clickable and cannot read property 'click' of null

when I run this command, I get the error:

driver.find_element_by_link_text("Confirm").click()

selenium.common.exceptions.WebDriverException: Message: unknown error: Element <a href="javascript:void(0);" class="c-button u-fontSize13 c-button--blue transparent-button js-connect-button js-request-connection" data-href="https://angel.co/user_graph_requests" data-invited-id="5911955">...</a> is not clickable at point (67, 581). Other element would receive the click: `<div class="mfp-container mfp-ajax-holder mfp-s-loading">...</div>`

      

After looking for answers to this problem, I changed the code above:

element = driver.find_element_by_link_text("Confirm").click()
driver.execute_script("arguments[0].click();", element)

      

For the first click it worked and then it printed this error:

selenium.common.exceptions.WebDriverException: Message: unknown error: Cannot read property 'click' of null

      

HTML code:

<a href="javascript:void(0);" class="c-button js-close s-vgLeft0_5 c-button--blue" data-modal="true" data-url="https://angel.co/user_graph_requests/102006082/verify">Confirm</a>

      

+3


source to share


4 answers


So this worked for me:

driver.find_element_by_link_text("Confirm").send_keys('\n')

      



Thanks everyone :)

+1


source


Try to find the class:
driver.find_element_by_class("c-button js-close s-vgLeft0_5 c-button--blue").click()



0


source


If you look at the error message, you can see that another element is intercepting the click. I don't know for sure without looking at the page, but it usually looks like a bootloader screen, popup, etc. that appears temporarily and then disappears. There is also a hint of one of the DIV interception classes mfp-s-loading

, which makes me think it is some sort of loading popup. The problem here is that the script continues and tries to click the link faster than the popup downloads and uploads. What I usually do in a situation like this is to wait until the popup is invisible and then click on the link.

The HTML of the popup is in the error message,

<div class="mfp-container mfp-ajax-holder mfp-s-loading">...</div>

      

So, you can find an element using a CSS selector, for example div.mfp-s-loading

, to make it invisible, then try clicking.

0


source


Sometimes using Xpath is easier Try: driver.find_element_by_xpath (XPath) .click ()

where Xpath should point to the object you plan to push

0


source







All Articles