Unable to load default profile in Chrome with Sele

2019-04-11 22:53发布

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? =)

1条回答
SAY GOODBYE
2楼-- · 2019-04-11 23:21

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");
查看更多
登录 后发表回答