Seleniumのインストールに苦労しています.Seleniumのドキュメントで提供されているテストスクリプトを実行しようとしました。私はPython 3とPython 2をインストールしましたが、pyをPython 2.7と3ではなくインストールすることは可能ですか?多分それは私の問題ですか?どんな助けや指導も頂ければ幸いです。Seliniumインストールに問題があります
テストコード:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()
1:まず、私はピップ
sudo pip install selenium
2でセレンをインストール:
:私は、テストスクリプトpython TestSelenium.py
トレースバックのエラーを実行しようとしました
Traceback (most recent call last):
File "TestSelenium.py", line 1, in <module>
from selenium import webdriver
ImportError: No module named selenium
3:セレンを使用するための
Traceback (most recent call last):
File "/usr/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 64, in start
stdout=self.log_file, stderr=self.log_file)
File "/usr/lib64/python3.5/subprocess.py", line 950, in __init__
restore_signals, start_new_session)
File "/usr/lib64/python3.5/subprocess.py", line 1544, 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 "TestSelenium.py", line 4, in <module>
driver = webdriver.Firefox()
File "/usr/lib/python3.5/site-packages/selenium/webdriver/firefox/webdriver.py", line 135, in __init__
self.service.start()
File "/usr/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 71, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x7f9f9f184c18>>
Traceback (most recent call last):
File "/usr/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 163, in __del__
self.stop()
File "/usr/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 135, in stop
if self.process is None:
AttributeError: 'Service' object has no attribute 'process'
フェイスパーム!私はエラーメッセージを慎重に見ていたが、 "gekodriver"を見逃しているに違いないと思った。 – Machiavelli