How to leave the geckodriver fit for selenium use?

0

In Python 3 and Ubuntu, I want to run a test with selenium:

from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

from time import sleep

binary = FirefoxBinary('/usr/lib/firefox/firefox')
ff = webdriver.Firefox(firefox_binary=binary)
ff.get('http://127.0.0.1:8080/')
print(ff.page_source)

But I have this error message:

Traceback (most recent call last):
  File "/home/reinaldo/Documentos/Code/live-de-python/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 76, in start
    stdin=PIPE)
  File "/usr/lib/python3.6/subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1333, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "browser.py", line 7, in <module>
    ff = webdriver.Firefox(firefox_binary=binary)
  File "/home/reinaldo/Documentos/Code/live-de-python/lib/python3.6/site-packages/selenium/webdriver/firefox/webdriver.py", line 152, in __init__
    self.service.start()
  File "/home/reinaldo/Documentos/Code/live-de-python/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 83, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 

I've been to the geckodriver site to download: link

I downloaded the latest version for Linux and typed these commands into the terminal:

tar -xvzf geckodriver-v0.20.1-linux64.tar.gz
rm geckodriver-v0.20.1-linux64.tar.gz
chmod +x geckodriver

Geckodriver.exe now needs to be copied to / usr / local / bin, right?

I've tried:

cp geckodriver /usr/local/bin/

But I had access denied:

cp: não foi possível criar arquivo comum '/usr/local/bin/geckodriver': Permissão negada

How can I copy the geckodriver to / usr / local / bin?

Or just indicate the system PATH? How do I do this?

    
asked by anonymous 18.04.2018 / 18:16

1 answer

1

You can move geckodriver pro / usr / local / bin with super user permissions.

sudo cp geckodriver /usr/local/bin/

    
18.04.2018 / 18:43