51Testing软件测试论坛

标题: selenium 模拟鼠标右键报错? [打印本页]

作者: 悠悠小仙仙    时间: 2017-11-29 16:17
标题: selenium 模拟鼠标右键报错?

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

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

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

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


  16. Process finished with exit code 1
复制代码

查了好多答案 没找到为什么故来求助啊 ?


作者: lsekfe    时间: 2017-11-29 16:37
Chrome是没问题的,webdriver目前对于Firefox的支持还不到位,是个已知的bug




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2