问题
I want to click invisible html's sub menu click.
*invisible html source
<ul class="options">
<li class="_ranking-attr-filter-container _sub-menu-target">
<span>Hide work using these filters</span>
</li></ul>
*my code
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.
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.
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.
回答1:
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()
来源:https://stackoverflow.com/questions/41795013/how-to-click-mouse-over-sub-menu-in-selenium