在Selenium IDE中,如何在下拉菜单中按索引选择一个选项? [英] In Selenium IDE how can you select an option by index in a dropdown menu?
问题描述
问题在于选项标签更改,因此我无法按标签抓取.我需要说说选项[0]
The problem is the option labels change and so I cant grab by label. I need to grab by say option[0]
有什么主意吗?
我正在使用Selenium IDE(Firefox),这是我要询问的部分:
I'm using Selenium IDE (Firefox), this is the piece im asking about:
<tr>
<td>select</td>
<td>dateRangeString</td>
<td>index=1</td>
</tr>
IDE中的最后一个TD是VALUE字段,
the last TD there is the VALUE field in the IDE,
我已经瞄准了select元素,但是我需要模拟用户选择第一个选项.我看到的唯一方法是在IDE的VALUE部分中使用LABEL ="string",但是string是动态的,因此无法正常工作!
I already am targeting the select element, but i need to simulate the user selecting the first option. The only way I see to do this is by using LABEL="string" in the VALUE part of the IDE, but string is dynamic so thats not going to work!
推荐答案
棘手,但是"type"命令在这里帮助了我:
Tricky, but the "type" command helped me here:
<tr>
<td>type</td>
<td>id=numStuff</td>
<td>1</td>
</tr>
相应的html看起来像这样(@id和@name属性除外)
The corresponding html looks like this (except the @id and @name attributes)
<select id="numStuff" name="numStuff">
<option selected= value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
我想知道它是否适用于超过1个按键的选项值.至少暂时好.
I'm wondering if it works for option values longer than 1 keystroke. At least, it's good for the time being.
这篇关于在Selenium IDE中,如何在下拉菜单中按索引选择一个选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!