1

I want to automate through python using selenium and I need help.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

Sergo=['Sergo']
driver = webdriver.Chrome()

driver.get("https://www.youtube.com/")
print(driver.title)
search = driver.find_element_by_xpath('//*[@id="search"]')
search.send_keys(Sergo)


time.sleep(5)
driver.quit()

Here is the error:

Traceback (most recent call last):
  File "c:/Users/user/Desktop/bot/automation.py", line 11, in <module>
    search.send_keys(Sergo)

  File "C:\Users\user\Desktop\bot\venv\lib\site-packages\selenium\webdriver\remote\webelement.py", line 477, in send_keys
    self._execute(Command.SEND_KEYS_TO_ELEMENT,

  File "C:\Users\user\Desktop\bot\venv\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
    return self._parent.execute(command, params)

  File "C:\Users\user\Desktop\bot\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)

  File "C:\Users\user\Desktop\bot\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response

    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
  (Session info: chrome=83.0.4103.116)
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Sergo96
  • 15
  • 5

2 Answers2

0

This is because you don't have the Chromedriver.

  • Click on the 3 dots at the right-top in your Chrome browser

  • Click on About Chrome/Chromium

  • Check the version mentioned in light gray

  • Go to the ChromeDriver [downloads page] (https://chromedriver.chromium.org/downloads).

  • Download the correct version as per your browser version.

  • Copy the path to ChromeDriver.exe

  • As an argument,pass executable_path=r'path/to/chromedriver.exe' in driver = webdriver.Chrome().

  • For example, mine is:

    driver = webdriver.Chrome(executable_path=r'C:\Users\dell\Libs\chromedriver.exe')

RushiSrinivas.K
  • 171
  • 2
  • 11
0

Your xpath is not unique

enter image description here

Use this xpath:

search = driver.find_element_by_xpath('//input[@id='search']')
Norayr Sargsyan
  • 1,737
  • 1
  • 12
  • 26