15

初めて Selenium をインストールしましたが、使い始めるのに問題があります。

インストールは次のようにうまくいきましたpip:

pip install selenium

そして、私はimport seleniumPython内でできます。

今、次のサンプル スクリプトを実行しようとしています。

from selenium import webdriver
driver = webdriver.Firefox()
driver.get("http://www.python.org")
assert "Python" in driver.title

何が起こるかというと、Firefox は開きますが、「 http://www.python.org 」に移動しません(この質問で説明されている動作と同様に、空白のページのみが表示されます)。

次の例外が発生するまで、約 60 秒間何も起こりません。

Traceback (most recent call last):
  File "selenium-test.py", line 4, in <module>
    driver = webdriver.Firefox()
  File "/home/usr1/.local/lib/python2.6/site-packages/selenium/webdriver/firefox/webdriver.py", line 61, in __init__
    desired_capabilities=capabilities)
  File "/home/usr1/.local/lib/python2.6/site-packages/selenium/webdriver/remote/webdriver.py", line 72, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/home/usr1/.local/lib/python2.6/site-packages/selenium/webdriver/remote/webdriver.py", line 114, in start_session
    'desiredCapabilities': desired_capabilities,
  File "/home/usr1/.local/lib/python2.6/site-packages/selenium/webdriver/remote/webdriver.py", line 165, in execute
    self.error_handler.check_response(response)
  File "/home/usr1/.local/lib/python2.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 136, in check_response
    raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: u'<HTML><HEAD>\r\n<TITLE>Network Error</TITLE>\r\n</HEAD>\r\n<BODY>\r\n<FONT face="Helvetica">\r\n<big><strong></strong></big><BR>\r\n</FONT>\r\n<blockquote>\r\n<TABLE border=0 cellPadding=1 width="80%">\r\n<TR><TD>\r\n<FONT face="Helvetica">\r\n<big>Network Error (tcp_error)</big>\r\n<BR>\r\n<BR>\r\n</FONT>\r\n</TD></TR>\r\n<TR><TD>\r\n<FONT face="Helvetica">\r\nA communication error occurred: "Operation timed out"\r\n</FONT>\r\n</TD></TR>\r\n<TR><TD>\r\n<FONT face="Helvetica">\r\nThe Web Server may be down, too busy, or experiencing other problems preventing it from responding to requests. You may wish to try again at a later time.\r\n</FONT>\r\n</TD></TR>\r\n<TR><TD>\r\n<FONT face="Helvetica" SIZE=2>\r\n<BR>\r\nFor assistance, contact your network support team.\r\n</FONT>\r\n</TD></TR>\r\n</TABLE>\r\n</blockquote>\r\n</FONT>\r\n</BODY></HTML>'

これらはソフトウェアのバージョンです

  • Firefox ESR 17.0.5
  • Selenium (Python バインディング) 2.35.0
  • パイソン 2.6.6
  • Red には Linux 6.3 がありました
  • 「Firefox WebDriver 2.35.0」ブラウザ拡張機能がインストールされている
4

4 に答える 4

2

セレンをアップグレードする必要があります。最新バージョンの Firefox を使用している場合は、最新バージョンのセレンを使用する必要があります

Python の場合、このコマンドを入力します

pip install -U selenium

Java の場合は、古い jar を削除し、 http://www.seleniumhq.org/download/から最新バージョンをダウンロードして、ビルド パスにアタッチします。動作します find 。Firefox でのハッピー テスト

于 2016-05-27T05:01:47.600 に答える
-1

gecko ドライバーのバージョンを確認するためにリンクを参照したのと同じ問題がありました: https://firefox-source-docs.mozilla.org/testing/geckodriver/Support.html

問題を修正したバージョンを適宜ダウンロードします

于 2020-06-11T21:23:29.103 に答える