Python Selenium Geckodriver Connection refused

I spent hours trying to get Selenium to work with Python, no luck this error message selenium.common.exceptions.WebDriverException: Message: connection refused

is the example I used: -

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()

      

It depends on me apt-get install -y xorg xvfb dbus-x11 xfonts-100dpi xfonts-75dpi xfonts-cyrillic

This is the /root/geckodriver.log

conclusion

1493938773101 geckodriver INFO Listening 127.0.0.1:40876 1493938774156 geckodriver :: marionette INFO Launching the browser /usr/lib/firefox/firefox.sh with args ["-marionette"] (firefox: 3128): GLib-GObject-CRITICAL_f_f : assertion 'object-> ref_count> 0' failed

I am running Selenium on a Ubuntu 14.04 64-bit

remote VPS server with 128MB of RAM I cannot figure out what makes Selenium unable to communicate with both Chrome and Firefox browser drivers.

+3


source to share


2 answers


Ok I gave up Geckodriver

and I use PhantomJS

both my 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 followed to install 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 .

0


source


Please start by checking your Firefox browser version.

At some point, I found this very confusing. I am using Raspbian and the "Iceweasel" downloaded from apt-get was Firefox 52 version which did not work with geckodriver 0.19 (this requires Firefox 55 or higher).



What worked for me was to download geckorvider v0.16 and that solved the problem.

Also, you probably don't need xorg for it to work, I only needed the xfvb and iceweasel packages.

+3


source







All Articles