【问题标题】:Why selenium crashes when I set google chrome profile? [duplicate]当我设置谷歌浏览器配置文件时,为什么 selenium 会崩溃? [复制]
【发布时间】:2020-03-16 03:34:51
【问题描述】:

这就是我的代码,我想用我在 selenium 中的默认配置文件信息打开 chrome。但是当我单击 chrome 中的配置文件图标时,它不会加载并崩溃

从硒导入网络驱动程序 从 selenium.webdriver.chrome.options 导入选项

options = webdriver.ChromeOptions()
options.add_argument("--user-data-dir=/Users/Library/Application Support/Google/Chrome/Default/Default")
driver = webdriver.Chrome(executable_path='/Users/Desktop/supbot/chromedriver', options=options, service_log_path="/tmp/log")
driver.get('google.com')

【问题讨论】:

  • 我正在使用带有排除开关的 add_experimental_option,也许这是一个原因?

标签: python selenium


【解决方案1】:

您应该使用驱动程序文件的完整路径,例如:

C:\pathtodriver\chromedriver.exe

另外,避免使用Capabilities,试试这个方法:

System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
WebDriver driver = new ChromeDriver();
driver.get('google.com')

【讨论】:

  • 那行不通
猜你喜欢
  • 1970-01-01
  • 2013-11-10
  • 2021-10-16
  • 1970-01-01
  • 2015-05-14
  • 1970-01-01
  • 2021-06-12
  • 2011-09-22
  • 1970-01-01
相关资源
最近更新 更多