1

I am writing a code that asks the user for a type of music and redirects them to a playlist in YouTube which is related to what the user wrote. While trying to click on the "Filter" button on YouTube to access the diferent playlist I encountered the following error:selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable.

Is there any way of making that button interactable?

While searchinig for a way to solve it, some of the solutions recommended using an explicit wait, but the timer reaches it's limits:

raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: 

Here is my code:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

link= "https://www.youtube.com/"
PATH= "C:\Program Files (x86)\chromedriver.exe"
driver= webdriver.Chrome(PATH)

driver.get(link)
print("\n")
print(driver.title)

genre= input("What kind of music do you want?: ")
print("Looking in YouTube's playlists ("+ genre+")...")

search_bar= driver.find_element_by_name("search_query")
search_bar.send_keys(genre+" playlist")

print(driver.current_url)

search_button= driver.find_element_by_id("search-icon-legacy")
search_button.click()

filter_pl = WebDriverWait(driver, 120).until( #Without the explicit wait this line would be: filter_pl= driver.find_element_by_id("button")
EC.element_to_be_clickable((By.ID, "button")) #Without the explicit wait this line wouldn't exist

filter_pl.click()
Epileef
  • 11
  • 1

0 Answers0