K
K
kolomiec_artiom2018-03-13 02:11:37
Python
kolomiec_artiom, 2018-03-13 02:11:37

Selenium in pythonanywhere. Why is the path not specified?

Good night friends! There is the following program code:

from pyvirtualdisplay import Display
from selenium import webdriver
with Display():
    browser = webdriver.Firefox("/home/annanikolaeva/test")
    try:
        browser.get('http://www.google.com')
        print(str(browser.page_source))
    finally:
        browser.quit()

When executing it, an error pops up:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py", line 74, in start
stdout=self.log_file, stderr=self .log_file)
File "/usr/lib/python3.6/subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.6/subprocess.py", line 1326, 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 "/home/annanikolaeva/test/example .py", line 6, in
browser = webdriver.Firefox("/home/annanikolaeva/test")
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/firefox/webdriver.py", line 140, in __init__
self. service.start()
File "/usr/local/lib/python3.6/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.

Although there is a file in the directory. What to do?
5aa7090817a2a790940283.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeniy _, 2018-03-13
@GeneD88

In the case of the geckodriver, you need to specify the path up to the executable.
browser = webdriver.Firefox("/home/annanikolaeva/test/geckodriver.exe")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question