-
-
Save ikegami-yukino/51b247080976cb41fe93 to your computer and use it in GitHub Desktop.
mail_address = '' | |
password = '' | |
from selenium import webdriver | |
UA = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0' | |
PHANTOMJS_ARG = {'phantomjs.page.settings.userAgent': UA} | |
driver = webdriver.PhantomJS(desired_capabilities=PHANTOMJS_ARG) | |
url = 'https://www.google.com/accounts/Login?hl=ja&continue=http://www.google.co.jp/' | |
driver.get(url) | |
driver.find_element_by_id("Email").send_keys(mail_address) | |
driver.find_element_by_id("next").click() | |
driver.find_element_by_id("Passwd").send_keys(password) | |
driver.find_element_by_id("signIn").click() |
@razan19, you need to either provide the path for the chromedriver file in the driver
variable or copy the chromedriver file and paste it in the Python 3.9 directory.
@ochen1 , Pls give me a solution, I need it. Thank yout. My discord is xzhong19856#4042
They are onto us guys....
I'm getting "Confirm your identity" popups, which goes to the login screen, even with freshly stolen cookies...
@ochen1 , Please give me solution, I need it. I don't have discover account if you can please contact me in skype or anything else. i really need this solution Thank you. if any one have this solution please send it to me.
my Skype Name --> live:support_61916
@ysomad , did you know how can i use this package undetected-chromedriver in java i am working using java not python.
@v-shashwat , @quoctrunggol , @maxpong0616 , @Akkihi ,
@topdeveloper0729 , @gomingge , @gomingge , @hyh1993959 , @jinfuchen , @shr00mie , @vctr13 , @hoangbao123 , @kimcartoon , @mahaffey , @sijokun , @Hugo-cruz , @chris13337 , @Raczan , @joel , @odek53r , @KuroSol , @idislikebrian . Sorry if i 've tags you all in this comment but i think same people are still stuck in this problem if anyone have the solution please share it with us.
@Ouldani004 if anybody had a solution and wanted to share, they would, no need for notifying everyone.
Have you tried loading the cookie from another browser? If not look at my first reply here.
If that does not work, there is a undetected chromedriver in python aswell.
Failing all that your best bet is to go to something like robotjs
I have 4 google test accounts. I can log into 3 of them with show browser turned on. One of them just never works. Somehow google has tagged that one differently. None of them work in headless mode.
I'm working on a module that is guaranteed to login to google as a service and return an authenticated cookie via robotic process automation. If anyone here is interested, please sign up at https://loginbud.com.
I'm working on a module that is guaranteed to login to google as a service and return an authenticated cookie via robotic process automation. If anyone here is interested, please sign up at https://loginbud.com.
I just saw the signup page, is the module paid?
I just saw the signup page, is the module paid?
The module will be connected to a service that has a free and paid tier.
undetected chromedriver version 2 works example:
`import undetected_chromedriver.v2 as uc
import random,time,os,sys
from selenium.webdriver.common.keys import Keys
GMAIL = '<GMAIL_HERE>'
PASSWORD = '<PASSWORD_HERE>'
chrome_options = uc.ChromeOptions()
chrome_options.add_argument("--disable-extensions")
chrome_options.add_argument("--disable-popup-blocking")
chrome_options.add_argument("--profile-directory=Default")
chrome_options.add_argument("--ignore-certificate-errors")
chrome_options.add_argument("--disable-plugins-discovery")
chrome_options.add_argument("--incognito")
chrome_options.add_argument("user_agent=DN")
driver = uc.Chrome(options=chrome_options)
driver.delete_all_cookies()
driver.find_element_by_xpath("/html/body/div[1]/div[1]/div[2]/div/div[2]/div/div/div[2]/div/div[1]/div/form/span/section/div/div/div[1]/div/div[1]/div/div[1]/input").send_keys(GMAIL)
driver.find_element_by_xpath("/html/body/div[1]/div[1]/div[2]/div/div[2]/div/div/div[2]/div/div[1]/div/form/span/section/div/div/div[1]/div/div[1]/div/div[1]/input").send_keys(Keys.RETURN)
time.sleep(10)`
Finally, a solution that works. Thank you @Mike-Fakesome for suggesting this.
Any drawbacks using this over the normal driver?
Thank you @Mike-Fakesome! Totally works.
@Mike-Fakesome @MarialenaShiamma @thiagobenine
I am getting this error. Any solution?
from session not created: This version of ChromeDriver only supports Chrome version 93
current browser version is 92.0.4515.107
I have installed the undetected chrome driver using pip install undetected-chromedriver command.
After installing, I am getting that error and I have checked but there is no version 93 available for Chrome.
@Mike-Fakesome - this is a life saver. after using the stack-overflow auth method for all of last year, i hadn't needed to run my particular automation since Dec 2020. that is until... yesterday. and it broke. i tried everything, but finally found this solution! and it works again.
in my case, i need to automate uploading previews (hundreds and hundreds) to doubleclick studio, which is owned by google. from there i can get individual urls with said creatives and get screen captures to look for line break and layout bugs. makes testing our DCO content so much faster!!!!
this helps so much. can't thank you enough.
undetected chromedriver version 2 works example:
`import undetected_chromedriver.v2 as uc
import random,time,os,sys
from selenium.webdriver.common.keys import KeysGMAIL = '<GMAIL_HERE>'
PASSWORD = '<PASSWORD_HERE>'chrome_options = uc.ChromeOptions()
chrome_options.add_argument("--disable-extensions")
chrome_options.add_argument("--disable-popup-blocking")
chrome_options.add_argument("--profile-directory=Default")
chrome_options.add_argument("--ignore-certificate-errors")
chrome_options.add_argument("--disable-plugins-discovery")
chrome_options.add_argument("--incognito")
chrome_options.add_argument("user_agent=DN")
driver = uc.Chrome(options=chrome_options)
driver.delete_all_cookies()
driver.find_element_by_xpath("/html/body/div[1]/div[1]/div[2]/div/div[2]/div/div/div[2]/div/div[1]/div/form/span/section/div/div/div[1]/div/div[1]/div/div[1]/input").send_keys(GMAIL)
driver.find_element_by_xpath("/html/body/div[1]/div[1]/div[2]/div/div[2]/div/div/div[2]/div/div[1]/div/form/span/section/div/div/div[1]/div/div[1]/div/div[1]/input").send_keys(Keys.RETURN)time.sleep(10)`
Worked for me today!
Hey there people of the internet, I switched to a node app using the official API, however I noticed the API lacks many options (endscreens, cards...) present in tools such TubeBuddy, has anybody explored building a browser extension?
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:49426
from session not created: This version of ChromeDriver only supports Chrome version 92
Current browser version is 94.0.4606.30
@ochen1 please accept me, i am vulence# 0206 on discord. Thank you in advance!
@ochen1 please accept me too, paradoxx#3011
Hi @ochen1 Can you please add me on Discord... i'd like to know your solution, i will explain why i need it, Thanks
Discord : yhache#8537
undetected chromedriver version 2 works example: `import undetected_chromedriver.v2 as uc import random,time,os,sys from selenium.webdriver.common.keys import Keys
GMAIL = '<GMAIL_HERE>' PASSWORD = '<PASSWORD_HERE>'
chrome_options = uc.ChromeOptions()
chrome_options.add_argument("--disable-extensions")
chrome_options.add_argument("--disable-popup-blocking")
chrome_options.add_argument("--profile-directory=Default")
chrome_options.add_argument("--ignore-certificate-errors")
chrome_options.add_argument("--disable-plugins-discovery")
chrome_options.add_argument("--incognito")
chrome_options.add_argument("user_agent=DN")
driver = uc.Chrome(options=chrome_options)
driver.delete_all_cookies()
driver.find_element_by_xpath("/html/body/div[1]/div[1]/div[2]/div/div[2]/div/div/div[2]/div/div[1]/div/form/span/section/div/div/div[1]/div/div[1]/div/div[1]/input").send_keys(GMAIL) driver.find_element_by_xpath("/html/body/div[1]/div[1]/div[2]/div/div[2]/div/div/div[2]/div/div[1]/div/form/span/section/div/div/div[1]/div/div[1]/div/div[1]/input").send_keys(Keys.RETURN)
time.sleep(10)`
Link is still blocking by google .Soo link should be update !!!
Hi @ochen1 Can you please add me on Discord... i'd like to know your solution, i will explain why i need it, Thanks Discord : yhache#8537
Did you find any solution ?
I've created a script to help people automate Google login here: https://github.com/crawlspec/google-login
It only needs the phone number for 2FA on first use. Subsequent uses will be 'trusted' by the service. It's written in puppeteer javascript. I can write a python selenium version if there's demand. Let me know if it works for you or post in the project's 'Issues' tab for any questions.
@kicktheken
I would appreciate a python selenium version.
i've tried using it and it didn't work (i don't know if i did it wrong or not)
Current Best Method for google login is:
from seleniumbase import SB
with SB(uc=True) as driver:
driver.get("https://accounts.google.com/o/oauth2/v2/auth/oauthchooseaccount?redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground&prompt=consent&response_type=code&client_id=407408718192.apps.googleusercontent.com&scope=email&access_type=offline&flowName=GeneralOAuthFlow")
driver.type("#identifierId", <Your Username Here>)
driver.click("#identifierNext > div > button")
driver.type("#password > div.aCsJod.oJeWuf > div > div.Xb9hP > input", <Password Here>)
driver.click("#passwordNext > div > button")
driver.save_screenshot("test.png")
I can't figure out how to make the window show though.
Current Best Method for google login is:
from seleniumbase import SB with SB(uc=True) as driver: driver.get("https://accounts.google.com/o/oauth2/v2/auth/oauthchooseaccount?redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground&prompt=consent&response_type=code&client_id=407408718192.apps.googleusercontent.com&scope=email&access_type=offline&flowName=GeneralOAuthFlow") driver.type("#identifierId", <Your Username Here>) driver.click("#identifierNext > div > button") driver.type("#password > div.aCsJod.oJeWuf > div > div.Xb9hP > input", <Password Here>) driver.click("#passwordNext > div > button") driver.save_screenshot("test.png")I can't figure out how to make the window show though.
it worked.
Use This if you want head-full mode.
from seleniumbase import SB
with SB(uc=True, headed=True) as driver:
driver.get("https://accounts.google.com/o/oauth2/v2/auth/oauthchooseaccount?redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground&prompt=consent&response_type=code&client_id=407408718192.apps.googleusercontent.com&scope=email&access_type=offline&flowName=GeneralOAuthFlow")
driver.type("#identifierId", <Your Username Here>)
driver.click("#identifierNext > div > button")
driver.type("#password > div.aCsJod.oJeWuf > div > div.Xb9hP > input", <Password Here>)
driver.click("#passwordNext > div > button")
driver.save_screenshot("test.png")
Use This if you want head-full mode.
from seleniumbase import SB with SB(uc=True, headed=True) as driver: driver.get("https://accounts.google.com/o/oauth2/v2/auth/oauthchooseaccount?redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground&prompt=consent&response_type=code&client_id=407408718192.apps.googleusercontent.com&scope=email&access_type=offline&flowName=GeneralOAuthFlow") driver.type("#identifierId", <Your Username Here>) driver.click("#identifierNext > div > button") driver.type("#password > div.aCsJod.oJeWuf > div > div.Xb9hP > input", <Password Here>) driver.click("#passwordNext > div > button") driver.save_screenshot("test.png")
This browser or app may not be secure.
Requesting to provide some sample synthetic jobs that handle sign in page functionality. Please do the needful
@Fakesum Does this method only work locally? I am trying to standup some tests on jenkins but after entering the password this way, I'm then redirected to https://accounts.google.com/v3/signin/challenge/iap
and cannot complete the auth flow.
works well locally though
EDIT: https://accounts.google.com/v3/signin/challenge/iap
is a 2FA challenge for accounts that don't have 2FA enabled, to set it up in-line. Likely will need to forward proxy and that potentially won't help either.
@Fakesum Does this method only work locally? I am trying to standup some tests on jenkins but after entering the password this way, I'm then redirected to
https://accounts.google.com/v3/signin/challenge/iap
and cannot complete the auth flow.works well locally though
Same here.
@Fakesum Does this method only work locally? I am trying to standup some tests on jenkins but after entering the password this way, I'm then redirected to
https://accounts.google.com/v3/signin/challenge/iap
and cannot complete the auth flow.works well locally though
EDIT:
https://accounts.google.com/v3/signin/challenge/iap
is a 2FA challenge for accounts that don't have 2FA enabled, to set it up in-line. Likely will need to forward proxy and that potentially won't help either.
This works locally for me, it does give me a warning of suspicious activity but thats after logging in. try changing the url to "https://accounts.google.com/signin" since this will redirect to oauth v3 login screen instead of the old oauth v2 one.
@Fakesum Does this method only work locally? I am trying to standup some tests on jenkins but after entering the password this way, I'm then redirected to
https://accounts.google.com/v3/signin/challenge/iap
and cannot complete the auth flow.
works well locally though
EDIT:https://accounts.google.com/v3/signin/challenge/iap
is a 2FA challenge for accounts that don't have 2FA enabled, to set it up in-line. Likely will need to forward proxy and that potentially won't help either.This works locally for me, it does give me a warning of suspicious activity but thats after logging in. try changing the url to "https://accounts.google.com/signin" since this will redirect to oauth v3 login screen instead of the old oauth v2 one.
hey bro, can i contact you somewhere else? i really need your help
I wrote a javascript file to login. I made two tests:
- Open chrome via cmd and use chromedriver to connect to this existing chrome process, then run the javascript file in this chrome by selenium.
Result: "This browser or app may not be secure"- Open chrome via cmd, then paste content of javascript file into console to login,
Result: Login successfully.
What's the differences? I dont use any selenium functions like sendkeys, click, etc... All is done via the code in js file. The chrome processes in two cases opened via cmd not via selenium.
Hi bro. I 'am from VN. Can you help me automation login google
What is the error in the code?
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
driver = webdriver.Chrome()
driver.maximize_window()
driver.delete_all_cookies()
driver.get("https://www.gmail.com")
driver.find_element_by_id("identifierId").send_keys("youremailhere")
time.sleep(2)
driver.find_element_by_xpath('//*[@id="identifierNext"]/div/button/div[2]').click()
time.sleep(3)
driver.find_element_by_name("password").send_keys("#########")
time.sleep(3)
driver.find_element_by_xpath('//*[@id="passwordNext"]/div/button/div[2]').click()
time.sleep(3)
driver.close()
print("Gmail login has been successfully connected")
The result =====-> Run code :
PS C:\Users\Owner\Desktop\python\LoginMail> & C:/Users/Owner/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Owner/Desktop/python/LoginMail/mail.py
Traceback (most recent call last):
File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\Owner\Desktop\python\LoginMail\mail.py", line 6, in
driver = webdriver.Chrome()
File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in init
self.service.start()
File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home