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()

    评论

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧