簡體   English   中英

如何將select從下拉菜單中取值Selenium using Python

[英]How to select from the drop-down menu value with Selenium using Python

我在 Selenium 上工作,我想使用 selenium Python 從下拉菜單中選擇 Select。我怎樣才能 select。 我想從下拉列表中輸入 select (00:00-06:00)

 <div class="prepopulated-select__SelectContainer-sc-xyhoe8-1 bfnzNQ"> <select class="prepopulated-select__Select-sc-xyhoe-2-3 kpVQsa" name="time"> <option class="prepopulated-select__StyledOption-sc-xyhoe8-2 lljkAc" value="0">00:00-06:00</option> <option class="prepopulated-select__StyledOption-sc-xyhoe8-2 lljkAc" value="6">06:00-12:00</option> <option class="prepopulated-select__StyledOption-sc-xyhoe8-2 lljkAc" value="12">12:00-18:00</option> <option class="prepopulated-select__StyledOption-sc-xyhoe8-2 lljkAc" value="18">18:00-00:00</option></select></div>

試試下面,

select = Select(driver.find_element(By.CLASS_NAME, "prepopulated-select__SelectContainer-sc-xyhoe8-1 bfnzNQ"))

select 通過可見文本

select.select_by_visible_text('00:00-06:00')

select 按價值計算

select.select_by_value('00:00-06:00')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM