2

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)

2
  • stackoverflow.com/questions/48665001/… this link will help you to resolve this Commented Jun 26, 2020 at 10:54
  • Yes saw that but i believe my case is slightly different as i'm not sure what is obstructing it Commented Jun 26, 2020 at 10:56

1 Answer 1

0

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)
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you. So i no longer get any error messages but it doesn't seem to click the button correctly. As normally when the button is clicked it takes you to the next page but nothing happens and it completes the execution. @Norayr
In this case, you can use the click with JSExecutor, which I mentioned in my answer

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.