ElementClickInterceptedException Selenium unable to click button Python

Viewed 2499

I'm writing a selenium test that clicks on a specific button on a page. There are no other buttons present on the page but it seems like it's been obstructed so the codes unable to find it.

  • I've tried to maximum the page in the hope it can find the button but it's unable to do so

My code

driver.maximize_window()

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@id='save' and @name='save'][@value='View Report']"))).click()

copy of the element

<input type="submit" value="View Report" id="save" name="save" data-reportid="108">
    

Error

selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element is not clickable at point (1750, 770). Other element would receive the click: ... (Session info: chrome=83.0.4103.116)

1 Answers

I think that another element may be overlapped your element, and you should wait for the invisibility of this layer. The layer can be a loading frame or anything else.

WebDriverWait(driver, 20).until(EC.invisibility_of_element((By.CSS_SELECTOR, "selector_for_ovelapped_layer")))

and then click the element you needed

Also, you can use Actions:

element = driver.find_element_by_xpath("//input[@id='save' and @name='save'][@value='View Report']")
webdriver.ActionChains(driver).move_to_element(element).click(element).perform()

And you can do this with JSExecutor:

element = driver.find_element_by_xpath("//input[@id='save' and @name='save'][@value='View Report']")
driver.execute_script("arguments[0].click();", element)
Related