0

I'm using Selenium like this:

#!/usr/bin/env python

from pyvirtualdisplay import Display
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = True

browser = webdriver.Firefox(capabilities=firefox_capabilities)

# Set screen resolution to 1366 x 768 like most 15" laptops
display = Display(visible=0, size=(1366, 768))
display.start()


# Sets the width and height of the current window
browser.set_window_size(1366, 768)

# Open the URL
browser.get('http://www.vionblog.com/')

# set timeouts
browser.set_script_timeout(30)
browser.set_page_load_timeout(30) # seconds

# Take screenshot
browser.save_screenshot('vionblog.png')

# quit browser
browser.quit()

# quit Xvfb display
display.stop()

But when I run the script, I get the following error:

Traceback (most recent call last):   
  File "a.py", line 10, in <module>
    browser = webdriver.Firefox(capabilities=firefox_capabilities)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 145, in __init__
    self.service.start()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 81, in start
    os.path.basename(self.path), self.start_error_message) 
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
finefoot
  • 9,914
  • 7
  • 59
  • 102
  • 2
    Possible duplicate of [Selenium using Python - Geckodriver executable needs to be in PATH](http://stackoverflow.com/questions/40208051/selenium-using-python-geckodriver-executable-needs-to-be-in-path) – dot.Py Mar 13 '17 at 12:59

1 Answers1

2

From your error message

Message: 'geckodriver' executable needs to be in PATH.

we can understand that the problem is that Selenium couldn't locate the geckodriver executable.

You have 2 solutions:

  1. Add geckodriver.exe path to your PATH variable environment
  2. Inform the geckodriver.exe path when starting the webdriver
Community
  • 1
  • 1
dot.Py
  • 5,007
  • 5
  • 31
  • 52