1

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)
2
  • It should .find_element_by_xpath('//*[@id="save"]') not .find_element_by_id('//*[@id="save"]') Commented Jun 26, 2020 at 8:23
  • Still an issue even with it updated to xpath Commented Jun 26, 2020 at 8:53

4 Answers 4

9

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

Sign up to request clarification or add additional context in comments.

Comments

1

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)

Comments

0

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:

5 Comments

I get the following error after trying the xpath option WebDriverWait(driver, 20).until(EC.element_to_be_clickable((by.xpath, "//input[@id='save' and @name='save'][@value='View Report']"))).click() AttributeError: 'bytes' object has no attribute 'element_to_be_clickable'
@PythonCoder4_09 It's not by but it's By
So i updated my code to WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.xpath, "//input[@id='save' and @name='save'][@value='View Report']"))).click() Still get the same error AttributeError: 'bytes' object has no attribute 'element_to_be_clickable' @DebanjanB
Sorry i forgot to import one of the packages. Been corrected now but i still get this issue when i run the xpath or css selector selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element is not clickable at point (482, 946) (Session info: chrome=83.0.4103.116) @DebanjanB
@PythonCoder4_09 Can you update the question with the complete error stack trace please?
0

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

2 Comments

Would this come after i use the xpath to find the location?
Scroll before locate element

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.