Selenium Hover Over - 位于JavaScript中的元素

时间:2016-06-18 18:42:22

标签: selenium

在Amazon.com(网址:www.amazon.com)网页上使用Selenium-Java,我想首先将鼠标悬停在“部门”上,然后点击“部门”> “Books& Audible”> “书籍”,我想登陆“亚马逊书籍”网页。

困难:“书籍和声音”隐藏在javascript中,我不知道如何通过“查找”来访问它。

非常感谢您提供有关Selenese代码的帮助。

1 个答案:

答案 0 :(得分:0)

How is it hidden? Can you please provide your HTML code here?

Regarding performing a mouse hover over, below is a code snippet you can use as reference:

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains

firefox = webdriver.Firefox()
firefox.get('url')
element_to_hover_over = firefox.find_element_by_id("id")

hover = ActionChains(firefox).move_to_element(element_to_hover_over)
hover.perform()

Hope it helps.