2016-10-15 2 views
4

私は最近、セレンをダウンロードし、このスクリプトを実行しようとしていますのpython webdriverをするEROR

from selenium import webdriver 
driver = webdriver.Firefox() 

が、私はこのエラーを取得:これはその前に私にgeckodriver.exe開く方法によって

Traceback (most recent call last): 
    File "<pyshell#3>", line 1, in <module> 
    driver = webdriver.Firefox() 
    File "C:\Heights\PortableApps\PortablePython2.7.6.1\App\lib\site-packages\selenium-3.0.1-py2.7.egg\selenium\webdriver\firefox\webdriver.py", line 145, in __init__ 
    keep_alive=True) 
    File "C:\Heights\PortableApps\PortablePython2.7.6.1\App\lib\site-packages\selenium-3.0.1-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 92, in __init__ 
    self.start_session(desired_capabilities, browser_profile) 
    File "C:\Heights\PortableApps\PortablePython2.7.6.1\App\lib\site-packages\selenium-3.0.1-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 179, in start_session 
    response = self.execute(Command.NEW_SESSION, capabilities) 
    File "C:\Heights\PortableApps\PortablePython2.7.6.1\App\lib\site-packages\selenium-3.0.1-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 236, in execute 
    self.error_handler.check_response(response) 
    File "C:\Heights\PortableApps\PortablePython2.7.6.1\App\lib\site-packages\selenium-3.0.1-py2.7.egg\selenium\webdriver\remote\errorhandler.py", line 192, in check_response 
    raise exception_class(message, screen, stacktrace) 
WebDriverException: Message: Expected browser binary location, but unable to find binary in default location, no 'firefox_binary' capability provided, and no binary flag set on the command line 

ああエラーを書いてください

+0

Firefoxをインストールしましたか?それがどこにあるのかセレンに伝えようとしましたか?あなたがポータブルアプリを使用している場合、彼らは物事を破るであろう非典型的な場所に物を置いているかもしれません。 – jonrsharpe

+0

コメントありがとう、私は火キツネがインストールされている、どのように私はそれがどこにセレンを教えて?私はそれを削除して、それを使わずにPythonをダウンロードする必要があると思いますか? – omersk

+0

現在お使いのFirefoxのバージョンは? – Piyush

答えて

7

私はこれを回避するために次の答えに従ってバイナリの場所を手動で設定しています:

https://stackoverflow.com/a/25715497

コンピュータ上のFirefoxのバイナリの実際の場所へのあなたのバイナリを設定することを忘れないでください

例:

from selenium.webdriver.firefox.firefox_binary import FirefoxBinary 

binary = FirefoxBinary(r'C:\Program Files (x86)\Mozilla Firefox\firefox.exe') 
self.browser = webdriver.Firefox(firefox_binary=binary) 

(注:ファイルパスの最初の引用符の前に「R」 stringはPythonに文字列を 'raw'テキストとして表示するので、 '\'のような文字をエスケープする必要はありません - 実際にはパスに入れるだけです)