Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Selenium不在Chrome中使用我的自定义配置文件_Python_Google Chrome_Selenium - Fatal编程技术网

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

Python Selenium不在Chrome中使用我的自定义配置文件,python,google-chrome,selenium,Python,Google Chrome,Selenium,我在chrome中使用selenium,但它没有使用我指定的配置文件,而是从一个新的配置文件开始。以下是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_opt

我在chrome中使用selenium,但它没有使用我指定的配置文件,而是从一个新的配置文件开始。以下是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)

浏览器将打开,但不使用我的个人资料。selenium的版本是3.5.0,chrome驱动程序的版本是2.31,chrome的版本是60.0.3112.113,我在Ubuntu 16.04上查找您需要键入的chrome配置文件数据的路径chrome://version/ 进入地址栏。例如,mine显示为

C:\Users\pc\AppData\Local\Google\Chrome\User Data\Default, 
要在脚本中使用它,我必须排除它

\Default\ 
所以我们最后只有

C:\Users\pc\AppData\Local\Google\Chrome\User Data.
另外,如果您只想为selenium创建单独的配置文件:将该路径替换为任何其他路径,如果启动时不存在该路径,chrome将为其创建新的配置文件和目录


希望这有帮助。谢谢。

这没用。我现在还没有检查这个,但我记得以前在某个地方使用过确切的步骤,它对我有效。如果可能的话,你能再检查一遍吗?要选择不同的配置文件,比如配置文件1,请使用options.addArguments(“profile directory=profile 1”);你找到解决办法了吗?