[英]Selenium click hidden button
我想用Selenium和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)
我想单击导航菜单下的“解决方案”按钮。
但是,解决方案位于导航菜单下。 所以它是隐藏的。
所以,我输入以下代码;
ActionChains(browser).move_to_element(menu).click(hidden)
ActionChains(browser).move_to_element(element).click(hidden)
但是硒什么也不会发生,也不给出任何错误信息。 如何单击带有硒的导航菜单下的按钮?
谢谢
如果我了解您的Question
和Requirement
我们需要将Mouse Hover
在WebElement
并将其文本作为“ Actions
,其中弹出两个选项作为“ Request
和“ Solution
并且您要在“ Solution
上click()
。 为此,可以使用以下代码块:
#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.