GMail is blocking login via Automation (Selenium)

Go to Gmail --> Settings --> Search for "Less secure app access" --> Enable

This is not a suggested method because it allows access to less secure apps and it's easier to get into your account but if it's just a testing account and no important data is being transferred to or from, you can give this a try.


I just tried something out that worked for me after several hours of trial and error.

Adding args: ['--disable-web-security', '--user-data-dir', '--allow-running-insecure-content' ] to my config resolved the issue.

I realized later that this was not what helped me out as I tried with a different email and it didn't work. After some observations, I figured something else out and this has been tried and tested.

Using automation:

Go to https://stackoverflow.com/users/login Select Log in with Google Strategy Enter Google username and password Login to Stackoverflow Go to https://gmail.com (or whatever Google app you want to access)

After doing this consistently for like a whole day (about 24 hours), try automating your login directly to gmail (or whatever Google app you want to access) directly... I've had at least two other people do this with success. PS - You might want to continue with the stackoverflow login until you at least get a captcha request as we all went through that phase as well.


After some trial and error, found out that this issue happens only in a scenario when multiple gmail accounts have already been created from the same App/IP/Device. Google somehow is marking those accounts and blocks them if they are launched by automation frameworks/extensions.

Temporary Solutions:

  • Create a fresh GMail account using a different mobile number from another device (Not recommended).
  • We should be using workarounds like nodemailer zeolearn.com/magazine/sending-and-receiving-emails-using-nodejs (as mentioned by Rahul L as a suggestion)
  • Automate temporary mail providers like Guerilla Mail or 10 Minute Mail if you are worried about only receiving mails

My humble opinion is to entirely avoid automating the UI of third party Mail applications as you cannot predict how their UI and elements will change. They might block you from launching for security purposes and they have every right to do so!