
#問題
http://chromedriver.storage.googleapis.com/index.html?path=2.9/より、ドライバーをインストールして実行したのですが、実行すると途中で強制停止します。
Windows10 64bit
python3.6.3
#状況
これに従ってコードを書いているのですが次のようなエラーが出ます。
#エラーメッセージ
python
1Traceback (most recent call last): 2 File "C:/Users/user/AppData/Local/Programs/Python/Python36-32/MyScript/SeleniumTest.py", line 11, in <module> 3 driver.get("https://www.google.co.jp/") 4 File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 320, in get 5 self.execute(Command.GET, {'url': url}) 6 File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 306, in execute 7 response = self.command_executor.execute(driver_command, params) 8 File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 460, in execute 9 return self._request(command_info[0], url, body=data) 10 File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 484, in _request 11 resp = self._conn.getresponse() 12 File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\http\client.py", line 1331, in getresponse 13 response.begin() 14 File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\http\client.py", line 297, in begin 15 version, status, reason = self._read_status() 16 File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\http\client.py", line 258, in _read_status 17 line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") 18 File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\socket.py", line 586, in readinto 19 return self._sock.recv_into(b) 20ConnectionResetError: [WinError 10054] 既存の接続はリモート ホストに強制的に切断されました。
#ソースコード
python
1#_*_ coding: utf-8 _*_ 2 3#import json_util 4 5from selenium import webdriver 6 7import time 8 9driver = webdriver.Chrome("chromedriver_win32/chromedriver") 10 11driver.get("https://www.google.co.jp/") 12 13time.sleep(3) 14 15driver.find_element_by_id("lst-ib").send_keys("Selenium Test") 16 17driver.find_element_by_name("btnK").click() 18 19time.sleep(10) 20 21driver.quit()
32bit版しかなかったので、それを使ったことが原因かなと思うのですが、64bit版はどこにあるのでしょうか?
#追記
python
1# -*- coding: utf-8 -*- 2 3from selenium import webdriver 4from selenium.webdriver.common.keys import Keys 5 6driver = webdriver.Chrome("C:/Users/user/AppData/Local/Program/Python/Python36-32/MyScript/chromedriver_win32/chromedriver.exe") 7content = driver.find_element_by_name("q") 8content.send_keys("this is test") 9content.send_keys(Keys.ENTER) 10
エラーメッセージ
Traceback (most recent call last): File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start stdout=self.log_file, stderr=self.log_file) File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 709, in __init__ restore_signals, start_new_session) File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 997, in _execute_child startupinfo) FileNotFoundError: [WinError 2] 指定されたファイルが見つかりません。 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\MyScript\SeleniumTest.py", line 6, in <module> driver = webdriver.Chrome("C:/Users/user/AppData/Local/Program/Python/Python36-32/MyScript/chromedriver_win32/chromedriver.exe") File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in __init__ self.service.start() File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start os.path.basename(self.path), self.start_error_message) selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

