我有一个帐户菜单。当我们将鼠标放在它上面时,它的子菜单就会出现在屏幕上。截图如下。
我想点击帐户摘要。我的硒代码如下。
def test_accounts(self):
self.login(self.driver,properties.userid,properties.password)
element_to_hover=self.driver.find_element_by_link_text('Accounts')
hover=ActionChains(self.driver).move_to_element(element_to_hover)
hover.click().perform()
self.driver.implicitly_wait(10)
self.driver.find_element_by_link_text('Account Summary').click()
我收到以下错误。
test_accounts (__main__.TestCase) ... ERROR
======================================================================
ERROR: test_accounts (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\New Workspace\Python Test\src\login.py", line 78, in test_accounts
self.driver.find_element_by_link_text('Account Summary').click()
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py", line 51, in click
self._execute(Command.CLICK_ELEMENT)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py", line 225, in _execute
return self._parent.execute(command, params)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 160, in execute
self.error_handler.check_response(response)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 149, in check_response
raise exception_class(message, screen, stacktrace)
MoveTargetOutOfBoundsException: Message: ''
----------------------------------------------------------------------
Ran 1 test in 24.563s
FAILED (errors=1)
我在 SO 和其他人中尝试了很多链接,但无法找到解决我的问题的方法。由于我是 Selenium 的新手,这是将鼠标悬停在链接上并转到其隐藏子元素的正确方法吗?
我正在使用python 2.7。任何帮助,将不胜感激