4

I am using Selenium WebDriver to do something on a page that requires http authentication.

I am already login in my default profile. But the selenium chromedriver will automatically use a new profile for each use therefore I can't get past the authentication stage.

Therefore, I was thinking of using my default profile (With account login inside) on Selenium WebDriver for Chrome.

The default profile don't seem to be loaded into Chrome even when I use the code as below

ChromeOptions options = new ChromeOptions();

options.AddArguments("user-data-dir=C:/Users/user_name/AppData/Local/Google/Chrome/User Data/Default");   


IWebDriver driver = new ChromeDriver(@"C:\Users\Lawrence\Desktop\selenium-dotnet-2.33.0\net40",options);

Any help? =)

Lawrence Wong
  • 1,129
  • 4
  • 24
  • 40
  • see http://stackoverflow.com/questions/27630091/using-the-same-chrome-profile-session-for-different-chromedriver-instances – William Jul 06 '15 at 16:25

1 Answers1

5

Try add '--' before your Chrome switch and remove Default from path, escape slashes if necessary.

options.AddArguments("--user-data-dir=C:\\Users\\user_name\\AppData\\Local\\Google\\Chrome\\User Data");
Yi Zeng
  • 32,020
  • 13
  • 97
  • 125
  • Hi there. I tried adding the '--' before the Chrome switch. It did not work sadly. – Lawrence Wong Aug 04 '13 at 05:07
  • Hi @user1177637 I just tried the updated code. It's still not working. Any more suggestions? – Lawrence Wong Aug 04 '13 at 06:47
  • @LawrenceWong: Please explain what does `not working` mean? Also make sure your path is actually correct. – Yi Zeng Aug 04 '13 at 09:54
  • Hi user1177636, I just realised I forgot to change the user_name part to my profile name. Thanks! It's working now. =) – Lawrence Wong Aug 04 '13 at 10:12
  • Hi @YiZeng , tried this,chrome opens with the user profile but gives this error {"The HTTP request to the remote WebDriver server for URL http://localhost:52408/session timed out after 60 seconds."} – Gokul Feb 06 '17 at 12:49
  • @Gokul: Hello. This answer was made 4 years ago, ChromDriver has been changed quite a bit. Maybe create a little demo to reproduce your problem and get help there https://sites.google.com/a/chromium.org/chromedriver/help – Yi Zeng Feb 06 '17 at 20:36