How to fit the geckodriver for use of Selenium?

Asked

Viewed 1,013 times

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 went to the geckodriver website to download: https://github.com/mozilla/geckodriver/releases

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 tried to:

cp geckodriver /usr/local/bin/

But I was denied access:

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

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

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

1 answer

2


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

sudo cp geckodriver /usr/local/bin/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.