一直在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
求大神看看什么原因,跪谢!!!
解决方法:尝试将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()
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。