liyunfei331518 2017-06-19 05:33 采纳率: 0%
浏览 1423

python+selenium+firefox ActionChains鼠标事件报错

一直在python(IDLE)中输入这些命令:

from selenium import webdriver
b=webdriver.Firefox()
from selenium.webdriver.common.action_chains import ActionChains
b.get('http://www.sina.com')
ele=b.find_element_by_link_text('微博')
ActionChains(b).move_to_element(ele).perform()

到这一步报错如下:
Traceback (most recent call last):
File "", line 1, in
ActionChains(b).move_to_element(ele).perform()
File "D:\Program Files\python3.6\lib\site-packages\selenium\webdriver\common\action_chains.py", line 77, in perform
self.w3c_actions.perform()
File "D:\Program Files\python3.6\lib\site-packages\selenium\webdriver\common\actions\action_builder.py", line 76, in perform
self.driver.execute(Command.W3C_ACTIONS, enc)
File "D:\Program Files\python3.6\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in execute
self.error_handler.check_response(response)
File "D:\Program Files\python3.6\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: POST /session/ab75399e-c8e6-40bd-92fe-9c14af6a600c/actions did not match a known command

求大神看看什么原因,跪谢!!!

  • 写回答

1条回答 默认 最新

  • pythonw 2017-06-21 06:09
    关注

    解决方法:尝试将get代码修改为b.get("http://www.sina.com.cn/")。#使用python3.4测试没有报错,代码片段如下:
    #!python34
    #-*- coding:utf-8 -*-
    from selenium import webdriver
    from selenium.webdriver.common.action_chains import ActionChains

    b = webdriver.Chrome(executable_path=your_chromedriver_path)
    b.get('http://www.sina.com.cn/')
    ele = b.find_element_by_link_text('微博')
    ActionChains(b).move_to_element(ele).perform()

    评论

报告相同问题?

悬赏问题

  • ¥30 vmware exsi重置后的密码
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面