这个简短的琐碎代码工作正常。昨天, 但现在send_keys不再起作用了:
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("http://www.google.com")
elem = driver.find_element_by_name("q")
elem.send_keys("Hello WebDriver!")
elem.submit()
print(driver.title)
这是堆栈跟踪:
C:\Users\Rui\PycharmProjects\geo\venv\Scripts\python.exe C:/Users/Rui/PycharmProjects/geo/send_keys.py
debug value ('Hello WebDriver!',)
Traceback (most recent call last):
File "C:/Users/Rui/PycharmProjects/geo/send_keys.py", line 5, in <module>
elem.send_keys("Hello WebDriver!")
File "C:\Users\Rui\PycharmProjects\geo\venv\lib\site-packages\selenium\webdriver\remote\webelement.py", line 483, in send_keys
'value': keys_to_typing(value)})
File "C:\Users\Rui\PycharmProjects\geo\venv\lib\site-packages\selenium\webdriver\remote\webelement.py", line 632, in _execute
return self._parent.execute(command, params)
File "C:\Users\Rui\PycharmProjects\geo\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
self.error_handler.check_response(response)
File "C:\Users\Rui\PycharmProjects\geo\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: call function result missing 'value'
(Session info: chrome=65.0.3325.181)
(Driver info: chromedriver=2.34.522940 (1a76f96f66e3ca7b8e57d503b4dd3bccfba87af1),platform=Windows NT
6.1.7601 SP1 x86)
Process finished with exit code 1
(字符串:
调试值(&#39; Hello WebDriver!&#39;,)
结果是试图理解正在发生的事情,在#34; webelement.py&#34;我补充道
这一行"print("debug value " + str(value))":
def send_keys(self, *value):
# 2018MAR25
# send_key generating errors since 2018MAR24!
print("debug value " + str(value))
因为它确实打印了#34;调试值(&#39; Hello WebDriver!&#39;,)&#34;我不明白 为什么&#34; webelement.py&#34;正在抱怨&#34;呼叫功能结果缺失&#39;值&#39;&#34;
有人可以开导我吗?我该如何解决这个问题? 我注意到Chrome在这个日期更新到65,可能是相关的吗?
Windows 7 32位
Selenium 3.11.0
Python 3.6.4
2017-12-19 Chrome
65.0.3325.181 2018-03-22
谢谢, REC
答案 0 :(得分:0)
您的Chrome驱动程序似乎不是最新的。如果你使用的是chrome 65,那么你需要最新的镀铬驱动程序。
请从此处获取最新版本的Chrome驱动程序:https://chromedriver.storage.googleapis.com/index.html?path=2.37/
它应解决您的sendkey问题。