selenium+webdriver+pyhton启动火狐浏览器报unicodedecodeerror的错误

suxi 发布于 2016/09/13 17:55
阅读 1K+
收藏 0

IDLE中代码:

#coding=utf-8
from selenium import webdriver

browser=webdriver.Firefox()

browser.find_element_by_id("kw").send_keys(decode("selenium"))
browser.find_element_by_id("su").click

browser.quit()

结果:

Traceback (most recent call last):
  File "C:/workspace/bad.py", line 4, in <module>
    browser=webdriver.Firefox()
  File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 85, in __init__
    keep_alive=True)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 90, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 177, in start_session
    response = self.execute(Command.NEW_SESSION, capabilities)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 234, in execute
    response = self.command_executor.execute(driver_command, params)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 398, in execute
    data = utils.dump_json(params)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\utils.py", line 34, in dump_json
    return json.dumps(json_struct)
  File "C:\Python27\lib\json\__init__.py", line 244, in dumps
    return _default_encoder.encode(obj)
  File "C:\Python27\lib\json\encoder.py", line 207, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "C:\Python27\lib\json\encoder.py", line 270, in iterencode
    return _iterencode(o, 0)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xb0 in position 3: invalid start byte

加载中
0
Ashkandi
Ashkandi

应该是selenium的版本和firefox的版本不匹配。

可以把firefox自动升级关闭,就不用频繁升级selenium了。

s
suxi
回复@Ashkandi : 恩恩,是的,谢谢!
返回顶部
顶部