How to configure the path for geckodriver in Ubuntu?

0

I'm doing a TDD tutorial on Django and selenium. I'm using Ubuntu and the first part is to run the following code:

from selenium import webdriver
browser = webdriver.Firefox() 
browser.get('http://localhost:8000')
assert 'Django' in browser.title

When I run the file, it returns the following:

Traceback (most recent call last):
  File "functional_test.py", line 3, in <module>
    browser = webdriver.Firefox()
  File "/home/jorge/Documents/envdjango/gogoat/lib/python3.5/site-packages/selenium/webdriver/firefox/webdriver.py", line 142, in __init__
    self.service.start()
  File "/home/jorge/Documents/envdjango/gogoat/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 74, in start
    stdout=self.log_file, stderr=self.log_file)
  File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg)
NotADirectoryError: [Errno 20] Not a directory

From what I understand the error is from selenium that fails to find the geckodrive, I had some approximations (I tried this link )

I'm running everything in a virtualenv and these are the versions that pip freeze gives:

Django==1.11.2
selenium==3.4.3
Ubuntu==16.04.2 LTS
    
asked by Tajaludo 04.06.2017 в 23:35
source

1 answer

0

How about,

In python you could try this

binary = FirefoxBinary('path/a/geckodriver')
browser = webdriver.Firefox(firefox_binary=binary)

In java I do it in the following way, you could search how to set the property in python (as an alternative to python):

System.setProperty("webdriver.gecko.driver","path/a/geckodriver");

Another option is the following:

  • Download the geckodriver: link
  • Unzip and copy the file to some route.
  • in the terminal paste the following command taking care to change the "[path-where-is-the-geckodriver]"

    export PATH = $ PATH: / [path-where-is-the-geckodriver] / geckodriver

  • answered by 05.06.2017 в 01:53