Home > Software design >  Python & Selenium: ElementClickInterceptedException: Message: element click intercepted error
Python & Selenium: ElementClickInterceptedException: Message: element click intercepted error

Time:05-15

I use Selenium in Python for scraping.

The following error is displayed when I try to click button tag.

ElementClickInterceptedException: Message: element click intercepted: Element <button id="pos-list" >...</button> is not clickable at point

HTML

<div id="order-bar">
    <div id="order-bar-menu">
        <button id="order-list" >orderlist</button>
        <button id="pos-list" >positionlist</button>
        ...

Python

pos = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, '//*[@id="pos-list"]')))
print(pos.text)
pos.click()

print(pos.text) is printed as positionlist I expected.

How can I click this button element?

It would be appreciated if you could give me some hint.

CodePudding user response:

Try:

pos = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, '//*[text()="positionlist"]')))
pos.click()

OR

pos = WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.XPATH, '//*[@id="order-bar"]/div/button')))
pos[1].click()

OR js execute and click()

pos = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, '//*[@id="pos-list"]')))
driver.execute_script("arguments[0].click();", pos)
  • Related