Answer the question
In order to leave comments, you need to log in
Google won't let me sign in with selenium python. What to do?
I wrote a code that goes to YouTube and tries to log into a Google account:
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
PATH = os.path.split(os.path.abspath(os.path.realpath(sys.argv[0])))[0] + '/'
options = Options()
#options.add_argument('--headless')
driver = webdriver.Chrome(executable_path=PATH + "chromedriver",
options=options)
try:
driver.get('https://www.youtube.com/')
sleep(10)
login = driver.find_element_by_partial_link_text('ВОЙТИ')
login.click()
sleep(2)
email = driver.find_element_by_name('identifier')
email.clear()
email.send_keys('test.gmail.com')
sleep(1)
email.send_keys(Keys.ENTER)
sleep(10)
except Exception as ex:
print(ex)
finally:
driver.close()
driver.quit()
Answer the question
In order to leave comments, you need to log in
please use the user agent like the browser for example
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")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question