Reputation: 33
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.
Upvotes: 0
Views: 1553
Reputation: 5147
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:
Upvotes: 2