如何在硒的子菜单上单击鼠标? [英] how to click mouse over sub menu in selenium?
问题描述
我想单击不可见的html的子菜单.
I want to click invisible html's sub menu click.
*不可见的html源代码
*invisible html source
<ul class="options">
<li class="_ranking-attr-filter-container _sub-menu-target">
<span>Hide work using these filters</span>
</li></ul>
*我的代码
element_to_hover_over = _Driver.find_element_by_xpath("//li[contains(@class, 'sub-menu-target')]")
hover = ActionChains(_Driver).move_to_element(element_to_hover_over).perform()
wait.until(EC.presence_of_element_located((By.PARTIAL_LINK_TEXT, unicode("男", errors='replace')))).click() #this line don't working. 10061 socket error.
我的代码的鼠标悬停部分正在工作,但是子菜单的单击不起作用. 但是子菜单的汉字在html中不可见(找不到ID,类名),我不知道如何选择子菜单.
my code's mouse hover part is working, but sub menu's click don't working. but sub menu's kanji is invisible in html(can't find id, class name), I don't know how to select sub menu.
我尝试了这个,但是不起作用(UnicodeDecodeError:'utf8'编解码器无法解码盗窃...)
I tried this, but don't work(UnicodeDecodeError: 'utf8' codec can't decode blarblar...)
wait.until(EC.presence_of_element_located((By.XPATH, '//input[@type="checkbox"][contains(text(), "男")]'))).click()
我需要您的建议,谢谢.
I need your advise, thank you.
推荐答案
按PARTIAL_LINK_TEXT
进行搜索以及按LINK_TEXT
进行搜索仅用于锚标记(<a>
),因此您可以尝试使用>
Search by PARTIAL_LINK_TEXT
as well as search by LINK_TEXT
is used for anchor tags only (<a>
), so you might try to use
wait.until(EC.presence_of_element_located((By.XPATH, '//input[@type="checkbox"][contains(text(), "男")]'))).click()
这篇关于如何在硒的子菜单上单击鼠标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!