如何使用python从下拉菜单中选择下拉菜单值

发布于 2025-02-09 13:00:57 字数 800 浏览 4 评论 0原文

我在硒上工作,我想使用硒python从下拉菜单中进行选择。我该如何选择。我想从下拉中选择(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>

Im working on Selenium and I want to Select from drop down using selenium Python. how can I select it. I want to select (00:00-06:00) from drop down

<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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

随梦而飞# 2025-02-16 13:00:57

尝试以下内容,

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

通过可见文本选择

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

按值选择

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

Try the below,

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

select by visible text

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

select by value

select.select_by_value('00:00-06:00')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文