Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97792

Why I can't send_keys to Twitch search bar in Python with Selenium?

$
0
0

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()

Viewing all articles
Browse latest Browse all 97792

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>