[英]Unable to select dropdown value using selenium python
我需要選擇一個下拉值,我檢查了它不包含選擇類的代碼。 有什么辦法可以在沒有選擇類的情況下選擇值
通過這個,我點擊下拉菜單,然后啟用下拉值driver.find_element_by_xpath("(//div[@class='ot-lookup__input-container'])").click()
那是下拉菜單
Xpath 的代碼是:(**每個值都相同)
<button _ngcontent-fru-c1=""
class="slds-media slds-listbox__option slds-listbox__option_entity slds-listbox__option_has-meta tabbable-button"
role="option"
type="button"
id="listbox-option-unique-id-[object Object]">
<!----><!---->Skipped<!---->
</button>
你可以。 單擊以打開下拉菜單,然后單擊所需選項(在您的情況下按鈕)。 在下面的代碼中,我使用WebDriverWait
等待帶有文本跳過的按鈕可點擊:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
# ...
wait = WebDriverWait(driver, 10)
# ...
driver.find_element_by_xpath("(//div[@class='ot-lookup__input-container'])").click()
wait.until(EC.element_to_be_clickable((By.XPATH, "//button[normalize-space()='Skipped']"))).click()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.