[英]Python Selenium Geckodriver Connection refused
I spent hours trying to make Selenium works with Python no luck this error message selenium.common.exceptions.WebDriverException: Message: connection refused
this is the example I have used:- 我花了几个小时试图使Selenium与Python一起工作没有运气这个错误消息
selenium.common.exceptions.WebDriverException: Message: connection refused
这是我用过的例子: -
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()
This is depence I intalled apt-get install -y xorg xvfb dbus-x11 xfonts-100dpi xfonts-75dpi xfonts-cyrillic
这是我所说的
apt-get install -y xorg xvfb dbus-x11 xfonts-100dpi xfonts-75dpi xfonts-cyrillic
This is /root/geckodriver.log
output 这是
/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
1493938773101 geckodriver INFO收听127.0.0.1:40876 1493938774156 geckodriver :: marionette INFO使用args [“-marionette”]启动浏览器/usr/lib/firefox/firefox.sh(firefox:3128):GLib-GObject-CRITICAL **: g_object_ref:断言'object-> ref_count> 0'失败
I'm running Selenium on Ubuntu 14.04 64-bit
VPS remote server with 128MB RAM I can't figure out what's make Selenium not able to communicate with browsers drivers both Chrome and Firefox. 我在
Ubuntu 14.04 64-bit
VPS远程服务器上使用128MB RAM运行Selenium我无法弄清楚是什么让Selenium无法与Chrome和Firefox的浏览器驱动程序进行通信。
Please start with checking your "firefox" browser version. 请先查看“firefox”浏览器版本。
I found it very confusing at some point. 我发现它在某些方面非常令人困惑。 I'm using the Raspbian and the "Iceweasel" downloaded with apt-get was a Firefox 52 version which didn't work with geckodriver 0.19 (this one requires Firefox 55 or greater).
我正在使用Raspbian,使用apt-get下载的“Iceweasel”是一个Firefox 52版本,它与geckodriver 0.19不兼容(这个需要Firefox 55或更高版本)。
What worked for me was to download geckorvider v0.16 and that resolved the problem. 对我有用的是下载geckorvider v0.16并解决了这个问题。
Whats moreover, you probably don't need xorg to make it work, the only packages I needed was xfvb and iceweasel. 此外,你可能不需要xorg来使它工作,我需要的唯一包是xfvb和iceweasel。
Ok, I gave up on Geckodriver
and I use PhantomJS
as my webdriver. 好吧,我放弃了
Geckodriver
,我使用PhantomJS
作为我的webdriver。
from selenium import webdriver
display = Display(visible=0, size=(800, 600))
display.start()
driver = webdriver.PhantomJS()
driver.get('http://www.python.org')
html_source = driver.page_source
print ("html_source:",html_source)
driver.quit()
Here are the steps I used to install PhantomJS : 以下是我用于安装PhantomJS的步骤:
cd ~
export PHANTOM_JS="phantomjs-2.1.1-linux-x86_64"
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
tar xvjf $PHANTOM_JS.tar.bz2
mv $PHANTOM_JS /usr/local/share
ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin
Python Selenium
apt-get install python-pip -y
pip uninstall pyvirtualdisplay
apt-get install x11vnc xvfb fluxbox
Xvfb :99 -ac
xvfb-run -a python 99.py
pip uninstall selenium
pip install selenium==2.53.1
See also How to install PhantomJS on Ubuntu . 另请参见如何在Ubuntu上安装PhantomJS 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.