拇指法则
Chrome在启动过程中崩溃的常见原因是 在Linux上以
root用户(administrator
)的身份运行Chrome 。虽然可以--no-sandbox在创建WebDriver会话时通过传递标志来解决此问题,但这种配置不受支持,因此不建议使用。您需要配置您的环境以改为以普通用户身份运行Chrome。
根据您的 代码试用 ,您似乎正在尝试访问 Chrome配置文件, 因此可以使用以下解决方案:
代码块:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument(“user-data-dir=C:pathtoyourprofileGoogleChromeUser DataProfile 2”)
driver = webdriver.Chrome(executable_path=r’C:pathtochromedriver.exe’, chrome_options=options)
driver.get(“https://www.google.co.in")



