I was trying to write a Selenium bot to search in twitch. I can click the search bar but I can't send any value to the search bar.
what is the issue? I worked for hours but can't fix my problem.
This is my code:
from selenium import webdriver
#https://selenium-python.readthedocs.io/
from selenium.webdriver.common.keys import Keys
#from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
class Twitch:
def __init__(self):
self.browser = webdriver.Chrome()
def openTwitch(self):
self.browser.get("https://www.twitch.tv/")
self.browser.maximize_window()
try:
barClick = WebDriverWait(self.browser,10).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="root"]/div/div[2]/nav/div/div[2]/div/div')))
barClick.click()
except:
print("Element not clickable")
try:
searchBar = WebDriverWait(self.browser,10).until(EC.visibility_of_element_located((By.XPATH,'//*[@id="tw-2a283106145a4249e75c7a6787c01324"]')))
searchBar.send_keys("Xantares") #this area is not working..
searchBar.send_keys(Keys.ENTER)
except:
print("Element not writable")
twtch = Twitch()
twtch.openTwitch()