首页新闻找找看学习计划

python 使用webdriver 打开浏览器,但不能send_keys

-1
[已关闭问题] 关闭于 2017-11-05 14:04

python3.5 _x86

system:win7_x64

selenium3.5

geckodriver:0.18.0_x64

firefox:55_x64

代码:

from selenium import webdriver
import time

driver = webdriver.Firefox(executable_path=u'C:\Program Files (x86)\Mozilla Firefox\geckodriver.exe')
driver.get('http://www.baidu.com')
time.sleep(0.5)

input = driver.find_element_by_name('wd')
input.clear()
input.send_keys('1234567890')

time.sleep(0.5)
driver.find_element_by_css_selector('#su').click()

错误:

D:\Python\Python35-32\python.exe D:/PycharmProjects/untitled1/bai.py
Traceback (most recent call last):
  File "D:/PycharmProjects/untitled1/bai.py", line 10, in <module>
    input.send_keys('1234567890')
  File "D:\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 350, in send_keys
    'value': keys_to_typing(value)})
  File "D:\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 499, in _execute
    return self._parent.execute(command, params)
  File "D:\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 297, in execute
    self.error_handler.check_response(response)
  File "D:\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Expected [object Undefined] undefined to be a string

这是为什么呢??

 

所有用到的都升到了最新了。

还没有的主页 还没有 | 菜鸟二级 | 园豆:475
提问于:2017-08-13 19:23
< >
分享
所有回答(2)
1

火狐浏览器太高,换成低版本火狐浏览器试试。

ycyzharry | 园豆:18805 (专家六级) | 2017-08-13 23:57
1

https://ftp.mozilla.org/pub/firefox/releases/47.0.1/

这是Firefox47版本的,换个低点版本浏览器就可以了

G2Bent | 园豆:202 (菜鸟二级) | 2017-08-25 12:00

为什么最新版不行呢。

是不支持了吗?

支持(0) 反对(0) 还没有 | 园豆:475 (菜鸟二级) | 2017-08-28 11:18
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册