如何使用 Selenium 从选择下拉列表中检索选项的值? [英] How to retrieve the value of options from a select drop-down using Selenium?

查看:22
本文介绍了如何使用 Selenium 从选择下拉列表中检索选项的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在给定的代码中,我需要选择下拉列表中每个选项的value"属性值列表:

In the given code, I need the list of the value of the "value" attribute for each of the options in the select drop-down :

<select id="myselect">
<option value="val1">Some Text</option>
<option value="val2">Some Text</option>
<option value="val3">Some Text</option>
<option value="val4">Some Text</option>
<option value="val5">Some Text</option>
<option value="val6">Some Text</option>
</select>

我想要所有值的列表,即{val1,val2,val3,val4,val5,val6}

I want the list of all the values, which is {val1,val2,val3,val4,val5,val6}

推荐答案

创建一个 List 的所有值的 value attribute对于

发送“验证码”获取 | 15天全站免登陆