4
我看了一些例子以及ActionChains的源代码,看起来我正在使用其他示例中提供的代码来实现悬停功能,但我仍无法克服此异常。代码如下:找不到python selenium webdriver move_to_element功能
menu = browser.find_element_by_xpath("//nav/ul/li/a[@href='#'][.='Profile']")
hover = ActionChains(webdriver).move_to_element(menu)
hover.perform()
和例外是:
Traceback (most recent call last):
File "./test.py", line 56, in <module>
hov.perform()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/action_chains.py", line 44, in perform
action()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/action_chains.py", line 201, in <lambda>
self._driver.execute(Command.MOVE_TO, {'element': to_element.id}))
AttributeError: 'module' object has no attribute 'execute'
起初,我认为这是行不通的,因为在元素上没有id属性,但是我确认,是不是案例(find_element_by_xpath确实返回正确的元素,并且有一些{unique ID}分配给它)。我的Python技能非常初级,但我需要调整我正在处理的测试脚本。我相信我只是不明白这个错误。
感谢您的帮助!
是的,那是我的愚蠢。 :-) 接得好! – user1762591 2013-03-07 21:31:33