selenium 模拟鼠标右键报错

kent0122 2016-12-03 10:58:50

#coding:utf-8
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains

driver = webdriver.Firefox() #打开浏览器
driver.get("Http://www.baidu.com")
#定位到元素
right = driver.find_element_by_id('su')
print "定位到搜索框"
#执行元素鼠标右键操作

ActionChains(driver).context_click(right).perform()



报错了
/usr/bin/python2.7 /home/stephen/PycharmProjects/python/selenium2/5.鼠标右键.py
Traceback (most recent call last):
定位到搜索框
File "/home/stephen/PycharmProjects/python/selenium2/5.鼠标右键.py", line 12, in <module>
ActionChains(driver).context_click(right).perform()
File "/home/stephen/.local/lib/python2.7/site-packages/selenium/webdriver/common/action_chains.py", line 74, in perform
action()
File "/home/stephen/.local/lib/python2.7/site-packages/selenium/webdriver/common/action_chains.py", line 225, in <lambda>
Command.MOVE_TO, {'element': to_element.id}))
File "/home/stephen/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/home/stephen/.local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: POST /session/428be644-5484-425f-8bfb-10800d287143/moveto did not match a known command


Process finished with exit code 1

查了好多答案 没找到为什么故来求助啊
...全文
1922 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wy6616753 2017-01-14
  • 打赏
  • 举报
回复
firefox和selenium版本兼容的问题 可以参考这里的说法 http://stackoverflow.com/questions/40360223/webdriverexception-moveto-did-not-match-a-known-command Firefox的bug中心也在修复中: https://bugzilla.mozilla.org/show_bug.cgi?id=1292178
广印大叔 2016-12-20
  • 打赏
  • 举报
回复
楼上正解, Chrome是没问题的,webdriver目前对于Firefox的支持还不到位,是个已知的bug
leahllia 2016-12-08
  • 打赏
  • 举报
回复
ps:此代码报了个错selenium.common.exceptions.WebDriverException: Message: POST /session/f743b659-6a1f-438d-8f3d-890556e000ad/moveto did not match a known command 原因:火狐和geckodriver的一个bug,用旧版本的火狐就没问题

转载自:http://www.cnblogs.com/fnng/p/3193955.html
leahllia 2016-12-08
  • 打赏
  • 举报
回复
我也有相同的问题,解决了吗

5,177

社区成员

发帖
与我相关
我的任务
社区描述
软件工程/管理 质量管理/软件测试
功能测试压力测试安全性测试 个人社区 湖南省·长沙市
社区管理员
  • 软件测试
  • 虫无涯
  • 小博测试成长之路
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

欢迎大家加入到软件测试的社区,在这里,希望大家勇于发表自己的看法,欢迎大家分享自己在软件测试工作过程中遇到的问题以及工作经验分享。

1.想转行的小伙伴,遇到问题没有及时回复的,可以私聊小博进行反馈

2.大家对社区有好的建议,都可以在社区发帖进行反馈

推荐大家学习的软件测试入门笔记:软件测试入门学习笔记

试试用AI创作助手写篇文章吧