0

all,

Recently, I set a new ubuntu server (version 14.04.3) for a screenshot solution with firefox and selenium. Though there are a lot discussions about this topic since firefox v47, but it seems all can not fix mine.

My python script is as below:

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
caps = DesiredCapabilities.FIREFOX
caps["marionette"] = True
caps["binary"] = "/usr/bin/firefox"

browser = webdriver.Firefox(capabilities=caps)
browser.set_window_size(1200, 2400)

For my development server, I have firefox v47.0.1 and selenium 2.53.5, and the code works. But in my new system, at beginning, I have firefox 48 and selenium 2.53.6, I got the error:

  browser = webdriver.Firefox(capabilities=caps)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 65, in __init__
    self.service.start()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 71, in start
    os.path.basename(self.path), self.start_error_message)
WebDriverException: Message: 'wires' executable needs to be in PATH. 

I tried to add the firefox binary to the PATH:

export PATH=$PATH:/usr/bin/firefox

After this, I got new error:

browser = webdriver.Firefox(capabilities=caps)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 65, in __init__
    self.service.start()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 64, in start
    stdout=self.log_file, stderr=self.log_file)
  File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
    raise child_exception
OSError: [Errno 20] Not a directory

Exception AttributeError: "'Service' object has no attribute 'process'" in <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x7fe3183edf50>> ignored

As a post here mentioned v48 should fix this problem, but it seems it is not. Then I downgrade firefox to v47.0.1, but still get the same errors. I checked the selenium code from v2.53.6 and v2.53.5, can not really identify the issue. And then I uninstall selenium to v2.53.5. But still get the same error. I think there maybe something wrong with my setting related to firefox with selenium, but can not further debug this.

Can anyone help? Thanks very much

Zhihong

Community
  • 1
  • 1
zhihong
  • 1,808
  • 2
  • 24
  • 34

2 Answers2

0

Well I had the same issue and I just switched to Chrome web driver...

But if you want to stay with Firefox try upgrading selenium to 3.0.0.

RadekE
  • 37
  • 4
  • thanks for your answer, did not know there is a selenium 3.0 released, I will give it a try, otherwise, will move to chrome as well – zhihong Aug 18 '16 at 14:31
  • You might also want to use gecko driver for firefox 47+ https://github.com/mozilla/geckodriver/releases/ – RadekE Aug 25 '16 at 13:28
  • RadekE, thanks, yes, I already use gecko driver. The difference is that, with 47+ and selenium 2.56, you patch marionette to slave the problem. And if use selenium 3.0(I tried after your recommendation), then need install gecko driver. – zhihong Aug 25 '16 at 14:07
0

You have done everything correctly zhihong. I encountered the same issue today after upgrading firefox to v48 yesterday. Best solution will be to downgrade back to 47.0.1 (can be downloaded from here) which is fully compatible with Selenium ( 2.35.1 for Java or 2.35.0 for Python)

Best of luck!

Xwris Stoixeia
  • 1,831
  • 21
  • 22
  • thanks for your reply. I already tried to downgrade firefox to 47.0.1, got the same error. And Bbad luck, after downgrade selenium to 2.35.0, I got other error: WebDriverException: Message: 'Can\'t load the profile. ... A quick check, this related to an old bug in selenium. So did not solve the problem yet. – zhihong Aug 18 '16 at 14:50
  • Damn, unlucky! The thing that puzzles me is according to your post this was working fine for you beforehand (i.e. v47.0.1 Firefox and 2.35.5 for Selenium) - but you have already tried that..Surely you should be able to revert back to the old situation. What has changed in the new system? Only the fact perhaps that your firefox bin folder could be located somewhere else from your dev machine or maybe you don't have enough privileges to access that folder..Question? Is your old setup working fine on your Ubuntu server? IF yes, I think it is more of a matter of pointing to the right path.. – Xwris Stoixeia Aug 18 '16 at 15:16
  • the selenium that works in my development server is version 2.53.5. Not 2.35.5. The new system (not really new, but a production sever run few scripts), not with selenium and firefox installed before, firefox bin set is the same as my development, the only difference I can see is the system version, the new is 14.04.3, and my local is 14.04.05, I will update the server to see what happens – zhihong Aug 19 '16 at 09:19