简体   繁体   English

Selenium在Chrome中不使用我的自定义配置文件

[英]Selenium does not use my custom profile in Chrome

I am using selenium with chrome, but it does not use the profile that I specified, but starts with a new profile instead. 我将硒与chrome一起使用,但是它不使用我指定的配置文件,而是以新的配置文件开始。 Here is the python code: 这是python代码:

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--user-data-dir=/home/username/.config/google-chrome/Profile 1')
driver = webdriver.Chrome(chrome_options=chrome_options)

The browser opens but it does not use my profile. 浏览器打开,但不使用我的个人资料。 The version of selenium is 3.5.0, the version of chrome driver is 2.31, the version of chrome is 60.0.3112.113, and I am on Ubuntu 16.04 selenium的版本是3.5.0,chrome驱动程序的版本是2.31,chrome的版本是60.0.3112.113,我在Ubuntu 16.04上

To find path to your chrome profile data you need to type chrome://version/ into address bar . 要找到您的chrome配置文件数据的路径,您需要在地址栏中输入chrome:// version /。 For ex. 对于前。 mine is displayed as 我的显示为

C:\Users\pc\AppData\Local\Google\Chrome\User Data\Default, 

to use it in the script I had to exclude 在脚本中使用它我不得不排除

\Default\ 

so we end up with only 所以我们最终只能

C:\Users\pc\AppData\Local\Google\Chrome\User Data.

Also if you want to have separate profile just for selenium: replace the path with any other path and if it doesn't exist on start up chrome will create new profile and directory for it. 另外,如果您只想为硒设置单独的配置文件:请将该路径替换为其他任何路径,如果启动时不存在该路径,则chrome会为其创建新的配置文件和目录。

Hope this helps. 希望这可以帮助。 Thanks. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM