![](/img/trans.png)
[英]How to select a drop-down menu value with 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.