编程语言
首页 > 编程语言> > Python Selenium Geckodriver Connection拒绝了

Python Selenium Geckodriver Connection拒绝了

作者:互联网

我花了几个小时试图让Selenium与Python合作没有运气
此错误消息
selenium.common.exceptions.WebDriverException:消息:连接被拒绝
这是我用过的例子: –

from pyvirtualdisplay import Display
from selenium import webdriver
display = Display(visible=0, size=(800, 600))
display.start()
browser = webdriver.Firefox()
browser.get('http://www.python.org')
browser.close()

这是我的安慰
apt-get install -y xorg xvfb dbus-x11 xfonts-100dpi xfonts-75dpi xfonts-cyrillic

这是/root/geckodriver.log输出

1493938773101 geckodriver INFO Listening on 127.0.0.1:40876
1493938774156 geckodriver::marionette INFO Starting browser
/usr/lib/firefox/firefox.sh with args [“-marionette”] (firefox:3128):
GLib-GObject-CRITICAL **: g_object_ref: assertion ‘object->ref_count >
0’ failed

我在Ubuntu 14.04 64位VPS远程服务器上运行Selenium,内存为128MB
我无法弄清楚是什么让Selenium无法与Chrome和Firefox的浏览器驱动程序进行通信.

解决方法:

请先查看“firefox”浏览器版本.

我发现它在某些方面非常令人困惑.我正在使用Raspbian,使用apt-get下载的“Iceweasel”是一个Firefox 52版本,它与geckodriver 0.19不兼容(这个需要Firefox 55或更高版本).

对我有用的是下载geckorvider v0.16并解决了这个问题.

此外,你可能不需要xorg来使它工作,我需要的唯一包是xfvb和iceweasel.

标签:python,selenium-webdriver,selenium,geckodriver,xvfb
来源: https://codeday.me/bug/20190527/1164131.html