I tried Most of the solution of StackOverflow but didn’t work for me I am trying to send some course name to youtube search bar using selenium python it works fine before but now it gives this error while doing this And search_bar.send_keys(course_name) works fine for other websites but not in YT
JavaScript
x
23
23
1
Traceback (most recent call last):
2
File "src/gevent/greenlet.py", line 766, in gevent._greenlet.Greenlet.run
3
File "/home/sh4d0w/PycharmProjects/AutoMate/venv/lib/python3.7/site-packages/eel/__init__.py", line 257, in _process_message
4
return_val = _exposed_functions[message['name']](*message['args'])
5
File "/home/sh4d0w/PycharmProjects/AutoMate/SmallTalk.py", line 72, in SingleQueryinputValue
6
RecommendCourse.getUdacityCourse(str(val))
7
File "/home/sh4d0w/PycharmProjects/AutoMate/RecommendCourse.py", line 160, in getUdacityCourse
8
getYoutubeCourse(course_name, driver)
9
File "/home/sh4d0w/PycharmProjects/AutoMate/RecommendCourse.py", line 98, in getYoutubeCourse
10
search_bar.send_keys(course_name)
11
File "/home/sh4d0w/PycharmProjects/AutoMate/venv/lib/python3.7/site-packages/selenium/webdriver/remote/webelement.py", line 479, in send_keys
12
'value': keys_to_typing(value)})
13
File "/home/sh4d0w/PycharmProjects/AutoMate/venv/lib/python3.7/site-packages/selenium/webdriver/remote/webelement.py", line 633, in _execute
14
return self._parent.execute(command, params)
15
File "/home/sh4d0w/PycharmProjects/AutoMate/venv/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
16
self.error_handler.check_response(response)
17
File "/home/sh4d0w/PycharmProjects/AutoMate/venv/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
18
raise exception_class(message, screen, stacktrace)
19
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
20
(Session info: chrome=81.0.4044.129)
21
22
2020-04-29T08:00:02Z <Greenlet at 0x7fd2089c67b8: _process_message({'call': 2.1877049007713376, 'name': 'SingleQueryi, <geventwebsocket.websocket.WebSocket object at 0x7)> failed with ElementNotInteractableException
23
Code sample
JavaScript
1
6
1
option = webdriver.ChromeOptions()
2
option.add_argument("window-size=1200x600");
3
driver = webdriver.Chrome('/usr/bin/chromedriver', options=option)
4
driver.get("https://www.youtube.com")
5
getYoutubeCourse(course_name, driver)
6
getYoutubeCourse() function body
JavaScript
1
11
11
1
def getYoutubeCourse(course_name, driver):
2
time.sleep(2)
3
4
search_bar = driver.find_element_by_xpath('//*[@id="search"]')
5
search_bar.send_keys(course_name)
6
7
search_bar_button = WebDriverWait(driver, 5).until(EC.element_to_be_clickable(
8
(By.XPATH, '//*[@id="search-icon-legacy"]')))
9
search_bar_button.click()
10
11
then after this, the logic of scraping the youtube links is there I also tried web driver wait and all, and my drivers are also up to date
Please help I am new in python and selenium
Advertisement
Answer
There is 3 elements found by xpath : //*[@id="search"]
You have to correct it to
JavaScript
1
2
1
//input[@id="search"]
2