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)

PythonCoder4_09
  • 67
  • 2
  • 10
  • https://stackoverflow.com/questions/48665001/can-not-click-on-a-element-elementclickinterceptedexception-in-splinter-selen this link will help you to resolve this – Justin Lambert Jun 26 '20 at 10:54
  • Yes saw that but i believe my case is slightly different as i'm not sure what is obstructing it – PythonCoder4_09 Jun 26 '20 at 10:56

1 Answers1

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)
Norayr Sargsyan
  • 1,737
  • 1
  • 12
  • 26
  • 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 – PythonCoder4_09 Jun 26 '20 at 12:07
  • In this case, you can use the click with JSExecutor, which I mentioned in my answer – Norayr Sargsyan Jun 26 '20 at 12:11