from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.select import Select
import os
import os.path
import sys
from time import sleep
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
PATH = os.path.split(os.path.abspath(os.path.realpath(sys.argv[0])))[0] + '/'
options = Options()
options.add_argument("--mute-audio")
#options.add_argument('--headless')
options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36")
driver = webdriver.Chrome(executable_path=PATH + "chromedriver",
options=options)
try:
driver.get('https://www.youtube.com/watch?v=dQw4w9WgXcQ')
#Процес авторизации убрал
sleep(5)
except Exception as ex:
print(ex)
finally:
driver.close()
driver.quit()
Message:
#Activate the box
commentBox = driver.find_element_by_id('placeholder-area')
commentBox.click()
sleep(4)
#Send the keys to the input field
inputBox =driver.find_element_by_id('contenteditable-root')
inputBox.send_keys('test')