Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install firefoxdriver webdriver for python3 selenium on ubuntu 16.04?

I installed python3-selenium apt package on Ubuntu 16.04. While installing, got a message:

Suggested packages:
chromedriver firefoxdriver
The following NEW packages will be installed:
python3-selenium

When I try to run the following python code,

#! /usr/bin/python3.5
from selenium import webdriver
import time

def get_profile():
    profile = webdriver.FirefoxProfile()
    profile.set_preference("browser.privatebrowsing.autostart", True)
    return profile

def main():
    browser = webdriver.Firefox(firefox_profile=getProfile())

    #browser shall call the URL
    browser.get("http://www.google.com")
    time.sleep(5)
    browser.quit()

if __name__ == "__main__":
    main()

I get the following error:

Traceback (most recent call last): File "./test.py", line 19, in main() File "./test.py", line 11, in main browser = webdriver.Firefox(firefox_profile=getProfile()) File "/usr/lib/python3/dist-packages/selenium/webdriver/firefox /webdriver.py", line 77, in init self.binary, timeout), File "/usr/lib/python3/dist-packages/selenium/webdriver/firefox/extension_connection.py", line 47, in init self.profile.add_extension() File "/usr/lib/python3/dist-packages/selenium/webdriver/firefox/firefox_profile.py", line 91, in add_extension self._install_extension(extension) File "/usr/lib/python3/dist-packages/selenium/webdriver/firefox/firefox_profile.py", line 251, in _install_extension compressed_file = zipfile.ZipFile(addon, 'r') File "/usr/lib/python3.5/zipfile.py", line 1009, in init self.fp = io.open(file, filemode) FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib /firefoxdriver/webdriver.xpi'

I did searching for packages name firefoxdriver in Ubuntu repositories but none exist. How do I solve this problem?

Any help with installing the webdrivers appreciated!

like image 930
chanzerre Avatar asked Oct 20 '25 03:10

chanzerre


1 Answers

The package you are missing is called firefox-geckodriver. You can get it via sudo apt-get install firefox-geckodriver or by downloading from https://github.com/mozilla/geckodriver/releases, putting it into your $PATH (for example /usr/bin) and making it executable.

like image 119
Teichi Avatar answered Oct 21 '25 18:10

Teichi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!