Element not interactable error clicking on Google Search button on Google homepage using Selenium Python

jyoti katkar
import time
from selenium import webdriver
driver = webdriver.Chrome("../drivers/chromedriver.exe")
driver.get("https://google.com")
driver.find_element_by_name("q").send_keys('Google')
driver.find_element_by_name("btnK").click()
time.sleep(3)
driver.close()
driver.quit()
print("Test completed")

This is the code and I am getting an error like:

selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
  (Session info: chrome=87.0.4280.66)
DebanjanB

To click on Google Search button, as the element is within a <form> you can use the following Locator Strategies:

  • Using submit():

    from selenium import webdriver
    
    options = webdriver.ChromeOptions() 
    options.add_argument("start-maximized")
    driver = webdriver.Chrome(options=options, executable_path=r'C:\WebDrivers\chromedriver.exe')
    driver.get("https://google.com")
    element = driver.find_element_by_name("q")
    element.send_keys('Google')
    element.submit()
    driver.quit()
    print("Test completed")
    
  • Using send_keys(Keys.RETURN):

    from selenium import webdriver
    from selenium.webdriver.common.keys import Keys
    
    options = webdriver.ChromeOptions() 
    options.add_argument("start-maximized")
    driver = webdriver.Chrome(options=options, executable_path=r'C:\WebDrivers\chromedriver.exe')
    driver.get("https://google.com")
    element = driver.find_element_by_name("q")
    element.send_keys('Google')
    element.send_keys(Keys.RETURN)
    driver.quit()
    print("Test completed")
    
  • Using send_keys(Keys.ENTER):

    from selenium import webdriver
    from selenium.webdriver.common.keys import Keys
    
    options = webdriver.ChromeOptions() 
    options.add_argument("start-maximized")
    driver = webdriver.Chrome(options=options, executable_path=r'C:\WebDrivers\chromedriver.exe')
    driver.get("https://google.com")
    element = driver.find_element_by_name("q")
    element.send_keys('Google')
    element.send_keys(Keys.ENTER)
    driver.quit()
    print("Test completed")
    

Ideally, to click on Google Search button, you need to induce WebDriverWait for the element_to_be_clickable() and you can use the following Locator Strategies:

  • Using submit():

    from selenium import webdriver
    
    options = webdriver.ChromeOptions() 
    options.add_argument("start-maximized")
    driver = webdriver.Chrome(options=options, executable_path=r'C:\WebDrivers\chromedriver.exe')
    driver.get("https://google.com")
    element = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.NAME, "q")))
    element.send_keys('Google')
    element.submit()
    driver.quit()
    print("Test completed")
    
  • Using send_keys(Keys.RETURN):

    from selenium import webdriver
    from selenium.webdriver.common.keys import Keys
    
    options = webdriver.ChromeOptions() 
    options.add_argument("start-maximized")
    driver = webdriver.Chrome(options=options, executable_path=r'C:\WebDrivers\chromedriver.exe')
    driver.get("https://google.com")
    element = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.NAME, "q")))
    element.send_keys('Google')
    element.send_keys(Keys.RETURN)
    driver.quit()
    print("Test completed")
    
  • Using send_keys(Keys.ENTER):

    from selenium import webdriver
    from selenium.webdriver.common.keys import Keys
    
    options = webdriver.ChromeOptions() 
    options.add_argument("start-maximized")
    driver = webdriver.Chrome(options=options, executable_path=r'C:\WebDrivers\chromedriver.exe')
    driver.get("https://google.com")
    element = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.NAME, "q")))
    element.send_keys('Google')
    element.send_keys(Keys.ENTER)
    driver.quit()
    print("Test completed")
    

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 detailed discussions in:

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

ElementNotInteractableException: element not interactable error while trying to search for stock on www.finanzen.net using Selenium and Python

From Dev

Using Selenium for clicking on button Python

From Dev

Clicking on button using python + selenium

From Dev

python selenium - Element is not currently interactable and may not be manipulated

From Dev

Trouble clicking button using Selenium with Python

From Dev

Python with selenium over PhantomJS find_by_xpath error in google search

From Dev

How to Pull Links from Google Search using Selenium, Python

From Dev

Printing text from google search using python and selenium does not work?

From Dev

Python Selenium : finding an element and clicking a button based on Text

From Dev

element not interactable for the Gmail password field Selenium WebDriver using java

From Dev

Search a location in google maps using r selenium

From Dev

Search a location in google maps using r selenium

From Dev

Issues clicking an element using selenium

From Dev

Cannot find element for a popup chart that opens in the same page after clicking a button using selenium package in python. NoSuchElementException

From Dev

update homepage / landing page for google search

From Dev

GOOGLE CHROME: Changing Homepage and Search Engine Settings

From Dev

Clicking a button which is inside another element Selenium

From Dev

Selenium can't locate the element, a search button using xpath

From Dev

Retrieving url from google image search for first entry, using python and selenium

From Dev

element not interactable exception in selenium web automation

From Dev

OpenQA.Selenium.ElementNotInteractableException : element not interactable

From Dev

Selenium Element not interactable exception- How to overcome this?

From Dev

Clicking button within span with no ID using Selenium

From Dev

Error with Google search in Python: 503 Service Unavailable

From Dev

python, locating and clicking a specific button with selenium

From Dev

Python Selenium clicking next button until the end

From Dev

Python Selenium keep clicking next button

From Dev

clicking on a button i cant find with selenium in python

From Dev

Clicking on link through Google with Selenium web driver

Related Related

  1. 1

    ElementNotInteractableException: element not interactable error while trying to search for stock on www.finanzen.net using Selenium and Python

  2. 2

    Using Selenium for clicking on button Python

  3. 3

    Clicking on button using python + selenium

  4. 4

    python selenium - Element is not currently interactable and may not be manipulated

  5. 5

    Trouble clicking button using Selenium with Python

  6. 6

    Python with selenium over PhantomJS find_by_xpath error in google search

  7. 7

    How to Pull Links from Google Search using Selenium, Python

  8. 8

    Printing text from google search using python and selenium does not work?

  9. 9

    Python Selenium : finding an element and clicking a button based on Text

  10. 10

    element not interactable for the Gmail password field Selenium WebDriver using java

  11. 11

    Search a location in google maps using r selenium

  12. 12

    Search a location in google maps using r selenium

  13. 13

    Issues clicking an element using selenium

  14. 14

    Cannot find element for a popup chart that opens in the same page after clicking a button using selenium package in python. NoSuchElementException

  15. 15

    update homepage / landing page for google search

  16. 16

    GOOGLE CHROME: Changing Homepage and Search Engine Settings

  17. 17

    Clicking a button which is inside another element Selenium

  18. 18

    Selenium can't locate the element, a search button using xpath

  19. 19

    Retrieving url from google image search for first entry, using python and selenium

  20. 20

    element not interactable exception in selenium web automation

  21. 21

    OpenQA.Selenium.ElementNotInteractableException : element not interactable

  22. 22

    Selenium Element not interactable exception- How to overcome this?

  23. 23

    Clicking button within span with no ID using Selenium

  24. 24

    Error with Google search in Python: 503 Service Unavailable

  25. 25

    python, locating and clicking a specific button with selenium

  26. 26

    Python Selenium clicking next button until the end

  27. 27

    Python Selenium keep clicking next button

  28. 28

    clicking on a button i cant find with selenium in python

  29. 29

    Clicking on link through Google with Selenium web driver

HotTag

Archive