0

I have an script with Selenium which was working on both pc and server correctly. A few days ago it stopped over server and still I have not figured out what is wrong. I set both of Firefox (41.0.2) and Selenium (2.53.5) similar over pc and local.

By running:

from selenium import webdriver

browser = webdriver.Firefox()

With current version I face this error:

selenium.common.exceptions.WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.

I should mention that I run my code with setting DISPLAY:=1;

I decided to upgrade selenium to 3.0.2 and I faced the:

IOError: [Errno 13] Permission denied: 'geckodriver.log'

Based on recommendation of other people who faced this issue, I downloaded geckidriver and put it in /usr/local/bin. However, still I cannot run my code. Weird part is that the code run without any issue over pc!

Any advice or suggestions?

This is output of geckodriver.log:

(firefox:94561): GConf-WARNING **: Client failed to connect to the D-BUS  daemon:
/usr/bin/dbus-launch terminated abnormally without any error message
1484733755568   geckodriver     INFO    Listening on 127.0.0.1:35823
1484733756567   mozprofile::profile     INFO    Using profile path     /tmp/rust_mozprofile.UiIxs53qoUs1
1484733756568   geckodriver::marionette INFO    Starting browser /usr/bin/firefox
1484733756573   geckodriver::marionette INFO    Connecting to Marionette on localhost:44907

(process:95171): GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' failed

Xlib: extension "RANDR" missing on display ":1".

(firefox:95171): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
/usr/bin/dbus-launch terminated abnormally without any error message

(firefox:95171): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
/usr/bin/dbus-launch terminated abnormally without any error message

(firefox:95171): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
/usr/bin/dbus-launch terminated abnormally without any error message

  (firefox:95171): GConf-WARNING **: Client failed to connect to the  D-BUS daemon:
 /usr/bin/dbus-launch terminated abnormally without any error message

Thanks

Moohebat
  • 455
  • 1
  • 6
  • 15

2 Answers2

1

You need to set the property first like this

System.setProperty("webdriver.firefox.marionette", getRootDir()+ "/src/main/java/configuration/geckodriver");

where getRootDir() is the absolute path

then create the driver

driver = new FirefoxDriver();
Monis Majeed
  • 1,358
  • 14
  • 21
0

The problem is solved. I was running selenium headless and even I had set DISPLAY=:1 it did not work correctly. Later I changed it to

export DISPLAY=:99

and It started to work again. I got suspected that I had some unsuspended process that they had blocked the my DISPLAY. With checking my process I many pending Firefox process. After kill all of them. My code run without any problem on Selenium 2.53.5 and Firefox 45.

So, I recommend if your code was working correctly before and suddenly your selenium stopped working, check your DISPLAY by:

export DISPLAY=:1
firefox

and If this error rises up:

Maximum number of clients reachedError: cannot open display: :1 selenium

and at the same time it works for:

export DISPLAY=:99
firefox

You should check suspended processes that are using your DISPLAY 1.

I hope it can help.

Moohebat
  • 455
  • 1
  • 6
  • 15