LoginSignup
2
0

More than 5 years have passed since last update.

Pythonのスクレイピングコードでsend_keysエラー発生

Last updated at Posted at 2018-01-23

事象

以下のようなpythonのheadlesschromeのスクレイピングコードで、send_keysでエラーが発生しました。

sample.py
#!/usr/bin/python3

import os

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys

# headless chrome

options = Options()
options.binary_location = '/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary'
options.add_argument('--headless')
options.add_argument('--window-size=1280,3000')

driver = webdriver.Chrome(chrome_options=options)
driver.get("https://example.com")
driver.find_element_by_xpath("//*[@id='email']").send_keys("hoge@example.com")
driver.find_element_by_xpath("//*[@id='password']").send_keys("hogehoge" + Keys.RETURN)

エラー内容

 File “sample.py”, line 28, in <module>
   send_keys(‘john@example.com’)
 File “/Users/:user/.pyenv/versions/anaconda3-4.3.0/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py”, line 479, in send_keys
   ‘value’: keys_to_typing(value)})
 File “/Users/:user/.pyenv/versions/anaconda3-4.3.0/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py”, line 628, in _execute
   return self._parent.execute(command, params)
 File “/Users/:user/.pyenv/versions/anaconda3-4.3.0/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py”, line 312, in execute
   self.error_handler.check_response(response)
 File “/Users/:user/.pyenv/versions/anaconda3-4.3.0/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py”, line 237, in check_response
   raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: call function result missing ‘value’
 (Session info: headless chrome=66.0.3329.1)
 (Driver info: chromedriver=2.33.506106 (8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2),platform=Mac OS X 10.13.3 x86_64)

対応

どうやら ChromeCanaryの66.0.3329.1版(2018/1/23時点で最新)で、該当エラーが発生するようなので、ダウングレードして、
バージョン: 63.0.3239.132(Official Build)
にすればエラーが回避できました。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0