【发布时间】:2020-08-16 03:16:39
【问题描述】:
我正在尝试使用 PyCharm 使用 Selenium 打开 Chromium。 这是我的代码:
from selenium import webdriver
options = webdriver.ChromeOptions()
options.binary_location = '/usr/bin/chromium-browser'
chrome_driver_binary = '/opt/WebDriver/bin/chromedriver'
driver = webdriver.Chrome(chrome_driver_binary, chrome_options=options)
driver.get('http://google.com/')
我在以 'driver = ' 开头的行中出现错误
selenium.common.exceptions.WebDriverException: Message: unknown error: no chrome binary at /usr/bin/chromium-browser
其实在/usr/bin里面有个东西叫chromium-browser,一个可执行文件。
我也从Set chrome browser binary through chromedriver in Python 尝试过这个解决方案,但没有更好的:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
cap = DesiredCapabilities.CHROME
cap = {'binary_location': '/usr/bin/chromium-browser'}
driver = webdriver.Chrome(desired_capabilities=cap, executable_path='/opt/WebDriver/bin/chromedriver')
driver.get('http://google.com/')
给予:
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
有什么帮助吗?第三个小时在谷歌上搜索它;)
【问题讨论】:
标签: python linux selenium chromium