Search code examples
google-chromeselenium-webdriverselenium-chromedrivergeckodriver

Selenium Google Login Block


I have a problem with Google login. I want to login to my account but Google says that automation drivers are not allowed to log in.

I am looking for a solution. Is it possible to get a cookie of normal Firefox/Chrome and load it into the ChromeDriver/GeckoDriver? I thought that this can be a solution. But I am not sure is it possible or not..

Looking for solutions...

enter image description here

Quick solution is using =>

var options = new ChromeOptions();
options.addArguments(@"user-data-dir=c:\Users\{username}\AppData\Local\Google\Chrome\User Data\");

Solution

  • I had the same problem and found the solution for it. I am using

    1. Windows 10 Pro

    2. Chrome Version 83.0.4103.97 (Official Build) (64-bit)

    3. selenium ChromeDriver 83.0.4103.39

    Some simple C# code which open google pages

    var options = new ChromeOptions();
    options.addArguments(@"user-data-dir=c:\Users\{username}\AppData\Local\Google\Chrome\User Data\");
    IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver();
    driver = new ChromeDriver(Directory.GetCurrentDirectory(), options);
    driver.Url = "https://accounts.google.com/";
    Console.ReadKey();
    

    The core problem here you can't login when you use selenium driver, but you can use the profile which already logged to the google accounts.

    You have to find where your Chrome store profile is and append it with "user-data-dir" option.

    PS. Replace {username} with your real account name.

    On linux the user profile is in "~/.config/google-chrome".