Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"This browser may not be secure" error when trying to log into a Gmail account using Playwright Chromium via Playwright and Python

I want to use playwright to sign into my Gmail account. I employ Python 3.10 Although there is no mistake, the screen stated that I was unable to sign into my account for some reason. The screenshot is shown below.

enter image description here

Python code :

from playwright.sync_api import Playwright, sync_playwright

with sync_playwright() as playwright:
    # Define Chrome browser options
    options = {
        'args': [
            '--disable-gpu',
            '--disable-dev-shm-usage',
            '--disable-setuid-sandbox',
            '--no-first-run',
            '--no-sandbox',
            '--no-zygote',
            '--ignore-certificate-errors',
            '--disable-extensions',
            '--disable-infobars',
            '--disable-notifications',
            '--disable-popup-blocking',
            '--remote-debugging-port=9222'
        ],
        'headless': False  # Set headless option here
    }

    # Launch Chrome browser with options
    browser = playwright.chromium.launch(**options)
    
    # Create a new context
    context = browser.new_context()
    
    # Create a new page
    page = context.new_page()
    for i in range(0, 100):
        num = '01703081815'
        number = int(num) + i
        numbers = "0"+str(number)
        # Navigate to the Gmail login page
        page.goto('https://accounts.google.com/v3/signin/identifier?dsh=S-1391596855%3A1680666082703684&continue=https%3A%2F%2Fmail.google.com%2Fmail%2Fu%2F0%2F%3Ftab%3Dwm&emr=1&followup=https%3A%2F%2Fmail.google.com%2Fmail%2Fu%2F0%2F%3Ftab%3Dwm&ifkv=AQMjQ7QIjnt4FMkK0TiFkjtzUAkNCpukXud3h6GXgdEJmiWUc6aKq5OfhTv5uWXS4k8uLLYtzU_rJg&osid=1&passive=1209600&service=mail&flowName=GlifWebSignIn&flowEntry=ServiceLogin')

        # Fill in the email field and press Enter
        page.fill('input[type="email"]', numbers)
        page.keyboard.press('Enter')

        # Wait for the password field to appear and fill it in
        page.wait_for_selector('input[type="password"]')
        page.fill('input[type="password"]', numbers)

        # Click the sign-in button
        page.keyboard.press('Enter')

        # Wait for the Gmail inbox to load
        # page.wait_for_selector('div[role="main"]')

    # Close the browser
    browser.close()
like image 223
Anik Saha Avatar asked Oct 25 '25 15:10

Anik Saha


1 Answers

I have the same issue, and "--disable-blink-features=AutomationControlled" worked for me!

like image 164
Nguyễn Triệu Vĩ Avatar answered Oct 27 '25 03:10

Nguyễn Triệu Vĩ