PythonCoder4_09
PythonCoder4_09

Reputation: 67

Selenium element is not clickable at point issue- Python

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)

Upvotes: 1

Views: 10123

Answers (4)

Pstr
Pstr

Reputation: 857

I had the same problem. Selenium was not clicking a text field that I needed it to click and raising the same ElementClickInterceptedException.

What worked for me was changing the approach:

The element IS THERE. It is already loaded. I made sure of it by using (in my example):

WebDriverWait(driver, 60).until(EC.element_to_be_clickable((By.ID, "code")))

Ok, so then the problem is that Selenium is failing to click on it. We can use a different strategy: Using JS!

After you have the element clickable with the .until() above, remember to store the field in a variable, either by using the method above:

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

(without calling .click()

or by finding it:

button = driver.find_element_by_xpath("//input[@id='save' and @name='save'][@value='View Report']")

and then the golden part: clicking on it through JS:

driver.execute_script('arguments[0].click()', button)

Worked for me, see if it helps you

Upvotes: 9

Ugur Okur
Ugur Okur

Reputation: 11

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)

Upvotes: 1

tkratowski
tkratowski

Reputation: 1

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);");

Upvotes: 0

undetected Selenium
undetected Selenium

Reputation: 193058

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:

Upvotes: 0

Related Questions