从鼠标悬停下拉菜单中选择一个选项

时间:2020-04-06 18:48:08

标签: python html selenium-webdriver

我正在尝试从子菜单中选择一个选项,当您使用硒将鼠标悬停在标题菜单中的某个选项上时,该菜单会下拉。我尝试了ActionChain和WebDriverWait,但均未成功。菜单被编码为表格。我已经在下面提供了代码示例和html。

wait= WebDriverWait(bot,20)
wait.until(EC.visibility_of_element_located((By.XPATH,"/html/body/div[2]/div/div[1]/table/tbody/tr/td[4]")))
hover= bot.find_element_by_xpath("/html/body/div[2]/div/div[1]/table/tbody/tr/td[4]")
reports= bot.find_element_by_xpath("/html/body/div/div[2]/div/table/tbody/tr[3]")

action= ActionChains(bot)
action.move_to_element(hover).perform()
action.click(reports).perform()

Copy of HTML of menu Copy of HTML submenu

0 个答案:

没有答案