繁体   English   中英

硒点击隐藏按钮

[英]Selenium click hidden button

我想用Selenium和python控制网页

Python代码;

menu = browser.find_element_by_css_selector(".nav")
hidden = browser.find_element_by_link_text('Soluton')
element = browser.find_element_by_xpath("//div[@class=\"two-columns\"]")
Option 1: ActionChains(browser).move_to_element(menu).click(hidden)
Option 2 : ActionChains(browser).move_to_element(element).click(hidden)

html代码;

请访问此图片

我想单击导航菜单下的“解决方案”按钮。

但是,解决方案位于导航菜单下。 所以它是隐藏的。

所以,我输入以下代码;

选项1:

ActionChains(browser).move_to_element(menu).click(hidden)

选项2:

ActionChains(browser).move_to_element(element).click(hidden)

但是硒什么也不会发生,也不给出任何错误信息。 如何单击带有硒的导航菜单下的按钮?

谢谢

如果我了解您的QuestionRequirement我们需要将Mouse HoverWebElement并将其文本作为“ Actions ,其中弹出两个选项作为“ Request和“ Solution并且您要在“ Solutionclick() 为此,可以使用以下代码块:

#import
from selenium.webdriver.common.action_chains import ActionChains
#code block
menu = driver.find_element_by_xpath("//a[@class='incident-action']/i[@class='icon-ellipsis-h']")
ActionChains(driver).move_to_element(menu).perform()
driver.find_element_by_xpath("//div[@class='action-list' and @id='header-actions-list']//a[@class='icon-arrow' and contains(text(),'Solution')]").click()

您可以尝试单击“ Actions以显示操作列表,然后单击所需的“ Solution选项:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as wait
from selenium.webdriver.support import expected_conditions as EC

actions = wait(driver, 10).until(EC.element_to_be_clickable((By.LINK_TEXT, "Actions")))
actions.click()
solution = wait(driver, 10).until(EC.element_to_be_clickable((By.LINK_TEXT, "Solution")))
solution.click()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM