Jun-08-2019, 07:43 AM
Here I am trying to send message in youtube live chat.
Until login everything is working fine.
But I am unable to draw message in chat box and send it.
Help.
Until login everything is working fine.
But I am unable to draw message in chat box and send it.
Help.
import contextlib
import time
import selenium.webdriver as webdriver
import selenium.webdriver.support.ui as ui
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
chrome_path = r"\chromedriver.exe"
chrome_options = webdriver.ChromeOptions()
driver = webdriver.Chrome(chrome_path,chrome_options=chrome_options)
driver.get('https://accounts.google.com/ServiceLogin?continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Fhl%3Den%26feature%3Dcomment%26app%3Ddesktop%26next%3D%252Fall_comments%253Fv%253D6-S4et2YpZc%26action_handle_signin%3Dtrue&uilel=3&service=youtube&passive=true&hl=en')
wait = ui.WebDriverWait(driver, 30) # timeout after 10 seconds
inputEmail = driver.find_element_by_name('identifier')
inputEmail.send_keys('xxxxxx')
btSubmit = driver.find_element_by_xpath("//span[@class='RveJvd snByac']")
btSubmit.click()
inputPass = wait.until(lambda driver: driver.find_element_by_xpath("//input[@name='password']"))
inputPass.send_keys('xxxxxx')
time.sleep(5)
loginButton = wait.until(lambda driver: driver.find_element_by_xpath("//span[@class='RveJvd snByac']"))
loginButton.click()
time.sleep(20)
chatInput = driver.find_element_by_xpath("//*[@class='style-scope yt-live-chat-message-input-renderer'][5]")
chatInput.click()
chatInput.send_keys('xxxxxxx')
