0
votes

I'm writing a basic automated test in python using selenium. I can navigate through several pages but when i get to this one particular page i'm unable to click on the button.

Code where my test is failing

driver.find_element_by_id('//*[@id="save"]').click()

Element when i inspect over the button i'm trying to click

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

Error message below

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)
3
It should .find_element_by_xpath('//*[@id="save"]') not .find_element_by_id('//*[@id="save"]') - frianH
Still an issue even with it updated to xpath - PythonCoder4_09

3 Answers

0
votes

You need to consider a couple of things here. As per the HTML of the element:

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

The WebElement is a React element. So click on the element you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

  • Using CSS_SELECTOR:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input#save[name='save'][value='View Report']"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@id='save' and @name='save'][@value='View Report']"))).click()
    
  • Note : You have to add the following imports :

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

References

You can find a couple of relevant discussion in:

0
votes

Element probably is covered by header or footer when selenium scroll to it. Try before your click scroll page up.

 JavaScriptExecutor.ExecuteScript("window.scrollTo(0, 0);");
0
votes

first, get your windows size:

driver.get_window_size()

if your window size less than your clickable area (clickable at point (width=1750, height=770)), you need to resize your selenium driver's windows size;

driver.set_window_size(1750,800)