[英]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.