0

I'm trying to run a script which run several tests using Selenium Firefox webdriver. It works flawless in a local machine, but fail miserably running on a xvfb.

The machine is a CentOS release 6.8 (Final) Firefox version 45.6.0

I'm using Python/Marionette

The command is similar to this:

xvfb-run --server-args="-screen 0, 1920x1080x24" MyProgram

Running this way I get several errors related to not loading the page. So I got a few screenshots, and all I see is the "Unable to connect" Firefox screen.

At first I though it could be proxy related... I was already implicit not disabling the proxy and a simple "wget" would work as expect. But then I forced the Firefox preference in the code so it doesn't use the proxy, for sure, right?

profile = webdriver.FirefoxProfile()
profile.set_preference("network.proxy.type", 0)

Same result. So I googled for similar situations and found some answers asking to add the display number in the command line. So I changed the command line to it:

export DISPLAY=:1
xvfb-run --server-args=":1 -screen 0, 1920x1080x24" MyProgram

Then I got a different error, but still not working:

ERROR: WebDriverException: connection refused Traceback (most recent call last):

I have also tried to log more information adding the -e parameter to xvfb-run, but all I get is an empty file.

Any idea what else can I try to make it work?

* UPDATE *

Here's a small code to reproduce the issue

from pyvirtualdisplay import Display
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.common.proxy import *

display = Display(visible=0, size=(1920, 1080))
display.start()

profile = webdriver.FirefoxProfile()
profile.set_preference("network.http.phishy-userpass-length", 255);
profile.set_preference("network.proxy.type", 0)
capabilities = None
# Marionette not necessary as it's Firefox 45
# capabilities = DesiredCapabilities.FIREFOX 
# capabilities["marionette"] = True 
print("Getting webdriver...")
browser = webdriver.Firefox(firefox_profile=profile, capabilities=capabilities)

print("Requesting URL...")
browser.get('https://www.google.com')
print("TITLE:", browser.title)

browser.quit()
display.stop()

The output:

Getting webdriver...
Requesting URL...
TITLE: Problem loading page
dfranca
  • 5,156
  • 2
  • 32
  • 60
  • 1
    [This post](http://stackoverflow.com/q/21553764/1382251) might be helpful. – barak manos Jan 30 '17 at 11:58
  • @barakmanos Thanks, but I've tried the solution on this link and still not working. I updated the question with an example code. – dfranca Jan 30 '17 at 15:16
  • Have you checked my answer within that post? AFAIK, you need to ensure a specific location of Firefox on the server, and use this location in your code. – barak manos Jan 30 '17 at 15:20
  • You mean setting the FirefoxBinary path? Yes, I tried this as well. – dfranca Jan 30 '17 at 15:26

0 Answers0