gpt4 book ai didi

python - WebDriver - Python - 下拉菜单中有多少个元素

转载 作者:行者123 更新时间:2023-11-30 23:17:02 26 4
gpt4 key购买 nike

我尝试计算有多少元素有下拉菜单。我的部分代码是:

while a < ? :

Select(driver.find_element_by_id("MyBox")).select_by_index(a)

a += 1

其他选项是通过索引检查元素是否存在,但我无法找到解决方案。

最佳答案

使用.options属性:

options

Returns a list of all options belonging to this select tag

 select = Select(driver.find_element_by_id("MyBox"))
print(len(select.options))

关于python - WebDriver - Python - 下拉菜单中有多少个元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27454606/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com