selenium中的MoveTargetAutofBoundsException,python
我有一份会计菜单。当我们把鼠标放在它上面时,它的子菜单就会出现在屏幕上。 截图如下 我想点击账户摘要。我的selenium代码如下selenium中的MoveTargetAutofBoundsException,python,python,python-2.7,selenium,selenium-webdriver,Python,Python 2.7,Selenium,Selenium Webdriver,我有一份会计菜单。当我们把鼠标放在它上面时,它的子菜单就会出现在屏幕上。 截图如下 我想点击账户摘要。我的selenium代码如下 def test_accounts(self): self.login(self.driver,properties.userid,properties.password) element_to_hover=self.driver.find_element_by_link_text('Accounts') hover=ActionChai
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。
任何帮助都将不胜感激我认为活动的顺序应该是:
移动到要素账户->移动到要素账户摘要->单击要素->执行这是您应该单击要素的方式:
accounts_button = driver.find_element_by_link_text('Accounts')
hidden_button = browser.find_element_by_id(hidden_button)
ActionChains(driver).move_to_element(accounts_button).click(hidden_button).perform()
如您所见,就是这样,请删除代码的最后两行