Selenium:即使chromedriver与chrome版本匹配,也无法创建会话?

时间:2020-03-20 21:18:55

标签: python selenium selenium-chromedriver ubuntu-14.04 chromium

我有一个Python脚本,正在运行一个EC2实例(ubuntu)。

options = webdriver.ChromeOptions() 
options.add_argument('--no-sandbox')
options.add_argument('--window-size=1420,1080')
options.add_argument('--headless')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--disable-gpu')
options.add_argument("--disable-notifications")
options.add_experimental_option('useAutomationExtension', False)
options.binary_location='/usr/bin/chromium-browser'
driver = webdriver.Chrome(options=options)

当我尝试运行脚本时,出现以下错误:

 selenium.common.exceptions.SessionNotCreatedException: Message: session not created
from disconnected: unable to connect to renderer
  (Session info: headless chrome=79.0.3945.130)

我使用chromedriver -v:验证了我的chromedriver版本,发现它是:

ChromeDriver 79.0.3945.130

无头chrome和chromedriver似乎是同一版本,因此我对可能导致此错误的其他原因感到困惑。我看到在脚本中,我指向/usr/bin/chromium-browser。我测试了指向/usr/bin/chromedriver的指向,但仍然无法正常工作,并给出了相同的错误?预先谢谢你。

0 个答案:

没有答案