简体   繁体   English

无法在Debian上使用Selenium加载Chrome配置文件

[英]Can't load Chrome profile with Selenium on Debian

I've successfully managed to load a Chrome Profile on MAC and I was trying to replicate the same on Linux but without success (Debian). 我已经成功地在MAC上加载了Chrome配置文件,并且试图在Linux上复制相同的文件,但是没有成功(Debian)。 I'm using Python, and the following works just fine on a MAC 我正在使用Python,以下在MAC上正常运行

from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("user-data-dir=/Users/username/Library/Application Support/Google/Chrome")
driver = webdriver.Chrome('./chromedriver', options=chrome_options)

The same code on Debian, just doesn't work... 在Debian上使用相同的代码,只是行不通...

from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--user-data-dir=/home/username/.config/google-chrome")
# I've tried also without the `--` but same outcome
# chrome_options.add_argument("user-data-dir=/home/username/.config/google-chrome")
driver = webdriver.Chrome('./chromedriver_linux', options=chrome_options)

I honestly now idea what's wrong. 老实说,我现在想出什么问题了。 I'm using chromedriver 2.45 https://chromedriver.storage.googleapis.com/index.html?path=2.45/ and the issue is related to "Debian GNU/Linux 9 (stretch)" ... 我正在使用chromedriver 2.45 https://chromedriver.storage.googleapis.com/index.html?path=2.45/ ,该问题与“ Debian GNU / Linux 9(拉伸)”有关...

In terms of launching Chrome, they both works. 就启动Chrome而言,它们都可以工作。 The difference is that on MAC it loads the profile, on Debian it doesn't. 区别在于,在MAC上它加载配置文件,在Debian上不加载。

Anyone has an idea why this is happening? 有人知道为什么会这样吗?

Right, so after many headaches, apparently this is something to do with the fact than I'm using CRD (Chrome Remote Desktop) to connect to the Linux instances! 是的,因此在经历了许多麻烦之后,显然这与我使用CRD (Chrome远程桌面)连接到Linux实例有关!

In fact, you can check the profile location loading chrome://version . 实际上,您可以检查加载chrome:// version的配置文件位置。 When connecting with CRD, this changes from the usual /home/user/.config/google-chrome to /home/user/.config/chrome-remote-desktop/chrome-profile/ 与CRD连接时,这将从通常的/home/user/.config/google-chrome更改为/home/user/.config/chrome-remote-desktop/chrome-profile/

All I needed to do is basically replace with the CRD directory to get all the profile information I wanted! 我需要做的基本上是用CRD目录替换以获得我想要的所有配置文件信息!

from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
#chrome_options.add_argument("--user-data-dir=/home/user/.config/google-chrome")
chrome_options.add_argument("--user-data-dir=/home/user/.config/chrome-remote-desktop/chrome-profile/")
driver = webdriver.Chrome('./chromedriver_linux', options=chrome_options)

Hopefully this will be helpful for others! 希望这对其他人有帮助! :) :)

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

相关问题 Selenium WebDriver无法加载配置文件 - Selenium WebDriver can't load profile Selenium:FirefoxProfile 异常无法加载配置文件 - Selenium: FirefoxProfile exception Can't load the profile Selenium Webdriver错误:“无法加载配置文件” - Selenium Webdriver error: “Can't load the profile” Chrome 无法使用 selenium python 打开配置文件 - Chrome can't open a profile using selenium python Windows 7下的Selenium无法启动FirefoxDriver:无法加载配置文件 - Selenium under Windows 7 cannot start FirefoxDriver: Can't load profile WebDriverException:无法在selenium python脚本中加载配置文件错误 - WebDriverException:can't load profile error in selenium python script selenium.common.exceptions.WebDriverException:消息:无法加载配置文件 - selenium.common.exceptions.WebDriverException: Message: Can't load the profile Selenium python - 如何加载默认 Chrome 配置文件 - Selenium python - How to load Default Chrome Profile 错误-消息:无法加载配置文件。 个人资料目录…使用Firefox进行Selenium Web抓取 - ERROR - Message: Can't load the profile. Profile Dir… Selenium Web Scraping with Firefox selenium.common.exceptions.WebDriverException:消息:“无法加载配置文件。配置文件目录: - selenium.common.exceptions.WebDriverException: Message: "Can't load the profile. Profile Dir:
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM