Selenium : Sending enter command to text box gives unknown error: unexpected command response

Issue

Hi guys i am new on selenium i tried to search from website’s textbox

There is my code:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By

import time

PATH="C:\Program Files (x86)\chromedriver.exe"
s=Service(PATH)
driver = webdriver.Chrome(service=s)
url='https://www.techwithtim.net/'
driver.get(url)
print(driver.title)
search=driver.find_element(by=By.NAME, value="s")
search.send_keys("test")
search.send_keys(Keys.ENTER)

time.sleep(5)
driver.close() #driver

The program is able to search, but it throws an error at the search.send_keys(Keys.ENTER) line and exits the code.

I can’t give all error for you because of this website doesn’t allow i don’t know

so some of the error:


File "C:/Users/User/PycharmProjects/us1/selen.py", line 16, in <module>
    search.send_keys(Keys.ENTER)
  File "C:\Users\User\PycharmProjects\us1\venv\lib\site-packages\selenium\webdriver\remote\webelement.py", line 223, in send_keys
    self._execute(Command.SEND_KEYS_TO_ELEMENT,
  File "C:\Users\User\PycharmProjects\us1\venv\lib\site-packages\selenium\webdriver\remote\webelement.py", line 396, in _execute
    return self._parent.execute(command, params)
  File "C:\Users\User\PycharmProjects\us1\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 435, in execute
    self.error_handler.check_response(response)
  File "C:\Users\User\PycharmProjects\us1\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response
 raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot determine loading status
from unknown error: unexpected command response
  (Session info: chrome=103.0.5060.66)
Stacktrace:
Backtrace:
    Ordinal0 [0x00F36463+2188387]
    Ordinal0 [0x00ECE461+1762401]
    Ordinal0 [0x00DE3D78+802168]
    Ordinal0 [0x00DD7210+750096]
.
.
.

Solution

So I faced the same error on my desktop, turns out that this has something to do with version mismatch.

My chrome version was

Version 103.0.5060.66 (Official Build) (64-bit)

So I updated my chrome driver to version

103.0.5060.53

You can try updating your chrome and chrome driver accordingly.

  • If you are using Chrome version 104, please download ChromeDriver 104.0.5112.20

  • If you are using Chrome version 103, please download ChromeDriver 103.0.5060.53

  • If you are using Chrome version 102, please download ChromeDriver 102.0.5005.61

Chrome Driver download link

You can check your chrome version here chrome://settings/help

Once updated, the below code should work fine

import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By

chrome_path = r"C:\Users\hpoddar\Desktop\Tools\chromedriver_win32\chromedriver.exe"
s = Service(chrome_path)
url = 'https://www.techwithtim.net/'
driver = webdriver.Chrome(service=s)
driver.get(url)
time.sleep(5)
driver.maximize_window()
search=driver.find_element(by=By.CLASS_NAME, value="search-field")

Answered By – Himanshu Poddar

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published