Search code examples
javaselenium-webdriverselenium-chromedriverbrowser-automation

cannot log in to google with selenium webdrive


so i want to automate a specific scenario where i have to access gmail. but unfortunately once i enter the email address the following error appears.

[enter image description here]

in text: Couldn’t sign you in This browser or app may not be secure. Learn more Try using a different browser. If you’re already using a supported browser, you can try again to sign in.

what can i do to get past this error ? and there is another gmail address i use but i can logged in to that account without any issue but i cant use that address to my purpose

tried using a different browser(edge) but still the issue presents


Solution

  • You can bypass bot detection with SeleniumBase in uc mode.

    First pip install seleniumbase. Then you can run:

    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"]', "test123@gmail.com")
        sb.click('button:contains("Next")')
        sb.sleep(5)
        # sb.type('input[type="password"]', PASSWORD)
        # sb.click('button:contains("Next")')
    

    Update the script with the info you need, then run with python. To access the raw driver from the script, use sb.driver.