开发者社区> 问答> 正文

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

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

展开
收起
爱吃鱼的程序员 2020-06-23 01:27:14 738 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

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

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

    2020-06-23 01:27:31
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载