0

I use selenium with python to login to my Gmail with chrome browser, But there was a problem while logging in look to photo . look to it

this is my code :

from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys import time EMAIL="your text" PASS = "your text" chrom_path ="C:\\development\\chromedriver_win32" driver = webdriver.Chrome(executable_path=chrom_path) driver.get("https://mail.google.com/mail/u/0/?tab=rm&ogbl#inbox") email_box= driver.find_element(By.XPATH, '//\*\[@id="identifierId"\]') email_box.send_keys(EMAIL) email_box.send_keys(Keys.ENTER) time.sleep(5) pass_box= driver.find_element(By.XPATH, '//\*\[@id="password"\]/div\[1\]/div/div\[1\]/input') pass_box.send_keys(PASS) pass_box.send_keys(Keys.ENTER) time.sleep(5) 
1
  • 1
    But there was a problem Post the problem here, in plain text. Don't make us click on an image.CommentedMay 21, 2023 at 15:09

2 Answers 2

1

The reason you get this error is because GMAIL identifies the bot(your script) and blocks you from logging in.

To overcome this issue, you can use a python library known as undetected-chromdriver. This library has been developed for the same purpose. You just have to install this library and import it in your code as use it as below:

import undetected_chromedriver as uc # driver = webdriver.Chrome() driver = uc.Chrome() 

For more info about undetected-chromedriver refer the below:

https://pypi.org/project/undetected-chromedriver/2.1.1/

https://www.zenrows.com/blog/undetected-chromedriver#what-is

https://www.zenrows.com/blog/undetected-chromedriver#conclusion

    0

    Gmail blocked you because their site detected a selenium bot.

    You can bypass bot-detection by using SeleniumBase in uc mode.

    First pip install seleniumbase. Then run the following script with python:

    from seleniumbase import SB with SB(uc=True) as sb: sb.open("https://www.google.com/gmail/about/") sb.click('a[data-action="sign in"]') sb.type('input[type="email"]', "[email protected]") sb.click('button:contains("Next")') sb.sleep(5) # sb.type('input[type="password"]', PASSWORD) # sb.click('button:contains("Next")') 

    (To access the raw driver from the script, use sb.driver)

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.