Selenium打开未登录Chrome帐户的Chrome [英] Selenium opens up chrome not signed into Chrome account
问题描述
除非您指定使用哪个配置文件,否则您将获得默认配置文件。要配置它以便Selenium将使用您的正常配置文件,请在新选项卡中导航到 chrome://版本。显示您的配置文件路径,只需将其作为指定选项输入即可,只需从路径末尾删除/ Default(如果存在)即可。这些都在 Google的这个网页中解释过,但这里也是一个例子(这是一个Windows路径,但相同的代码可以在Mac上使用 - 只需更改路径):
System.out .println(现在在我的个人资料中打开Chrome);
ChromeOptions选项=新ChromeOptions();
options.addArguments(user-data-dir = C:/ Users / [your user name] / AppData / Local / Google / Chrome / User Data);
driver = new ChromeDriver(options);
driver.get(http://www.google.com);
I have recently been working with Selenium WebDriver. I am also working specifically with chromedriver. Whenever I open up a new chrome window (driver.get(url)), Chrome starts up in a completely default state, instead of the state it would open up in if I just opened a new window from my dock (I am on a macbook running OS X Yosemite). Is there a way around this? Or is this just a set behavior?
You will get a default profile unless you specify which profile to use. To configure it so Selenium will use your normal profile, navigate to chrome://version in a new tab. Your profile path is shown, and you just enter it as a specified option, just removing the "/Default" from the end of your path if it is there. This is all explained in this page from Google, but here's also an example (this is a Windows path, but the same code would work for Mac--just change the path):
System.out.println("Now opening Chrome in my profile");
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=C:/Users/[your user name]/AppData/Local/Google/Chrome/User Data");
driver = new ChromeDriver(options);
driver.get("http://www.google.com");
这篇关于Selenium打开未登录Chrome帐户的Chrome的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!