[英]How to click a span text using selenium Python
我一直在嘗試使用 selenium python 從下面的鏈接單擊登錄頁面中的繼續按鈕。
我已經嘗試了幾個選擇器,xpath ..似乎沒有什么對我有用。
這是我試圖點擊的元素:
driver.find_element_by_xpath("//span[text()='Continue']").click()
也嘗試使用 Div class :
driver.find_element_by_xpath("//div[contains(@class, 'appendBottom25 ')]")
我希望 selenium 單擊繼續按鈕並加載到密碼頁面
試試這個:
driver.find_element_by_xpath("//*[@id="SW"]/div[2]/div[2]/div[2]/section/form/div[2]/button/span").click()
如果您選擇通過 xpath 查找元素,則必須將 xpath 作為參數傳遞。 (您右鍵單擊繼續按鈕 > inspect
> 然后右鍵單擊標記的元素 > copy xpath
)
您正在使用正確的 xpath
解決方案:
執行兩次點擊操作:
element =driver.find_element_by_xpath("//span[text()='Continue']")
element.click()
element.click()
這是一個奇怪的解決方案,但是..我只是以同樣的方式解決了這個問題。
我認為你應該點擊“按鈕”。
嘗試使用下面的 xpath:
//按鈕[./span[text()='繼續']]
並使用顯式等待等待元素可點擊。
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[./span[text()='Continue']]"))).click()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.