Python Selenium ElementClickInterceptedException

Viewed 186

I already tried several methods to click on a link on a specific website, with the help of Selenium. All of them resulting in following error message:

ElementClickInterceptedException: Message: element click intercepted: Element LMGP06050001 is not clickable at point (159, 364). Other element would receive the click: ... (Session info: chrome=89.0.4389.90)

What am I doing wrong?

The goal is to reach following site and grab several data from there: https://www.lipidmaps.org/data/LMSDRecord.php?LMID=LMGP06050001

Below my code so far:

from time import sleep
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

PATH = "C:\\Users\\xxxxxx\\anaconda3\\chromedriver.exe"
browser = webdriver.Chrome(PATH)

browser.get("https://www.lipidmaps.org/data/structure/LMSDSearch.php?Mode=ProcessClassSearch&LMID=LMGP0605")

link = browser.find_element_by_link_text("LMGP06050001")
browser.implicitly_wait(5)
link.click()
1 Answers

Reason you have faced that issue because cookie pop up appeared and you need to accept the cookie first.

Use WebDriverWait() and wait for element_to_be_clickable()

browser.get("https://www.lipidmaps.org/data/structure/LMSDSearch.php?Mode=ProcessClassSearch&LMID=LMGP0605")

#Accept to cookie
WebDriverWait(browser,20).until(EC.element_to_be_clickable((By.CSS_SELECTOR,"button#cookie_notice_accept"))).click()

WebDriverWait(browser,20).until(EC.element_to_be_clickable((By.LINK_TEXT,"LMGP06050001"))).click()

you need to import below libraries

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
Related