使用 Selenium IDE 选择下拉选项 [英] Selecting a drop-down option using Selenium IDE
问题描述
我是 Selenium 的新手,很难从下拉列表中选择选项(尝试选择第二个选项).
这是我正在使用的 HTML:
<label id="applicationReasonTypeIDLabel" for="applicationReasonTypeID">申请原因</label><select name="appstart_international1:applicationReasonTypeID" id="applicationReasonTypeID" class="AppStart dropdown required" title="申请原因"><option value="0"> </option><option value="1">新建应用程序</option><option value="2">附加位置</option><option value="3">所有者变更</option>我正在使用 XPath 检查器来查找 XPath,它给了我这个但是当我尝试单击或选择命令时它不起作用
id('applicationReasonTypeID_listbox')/x:li[2]
使用 XPath 查找这样的选项的正确 Target 应该是什么?
谢谢!
解决方案 我确实找到了问题所在——这是 Kendo UI 无法正确支持下拉菜单的问题.基本上解决方法是单击下拉箭头,然后使用 sendKeys 并指向与下拉列表相同的目标,值是列表中您想要的任何项目,然后再次单击下拉列表.这对我有用,希望对其他人有帮助!
I'm new to Selenium and having a difficult time selecting options from a drop down list (trying to select the second option).
Here is the HTML that I'm working with:
<div id="applicationReasonTypeIDContainer" class="appfield">
<label id="applicationReasonTypeIDLabel" for="applicationReasonTypeID">Application Reason</label>
<select name="appstart_international1:applicationReasonTypeID" id="applicationReasonTypeID" class="AppStart dropdown required" title="Application reason">
<option value="0"> </option>
<option value="1">New Application</option>
<option value="2">Additional location</option>
<option value="3">Owner change</option>
I'm using XPath checker to find the XPath, and it's giving me this but it doesn't work when I try and click or select command
id('applicationReasonTypeID_listbox')/x:li[2]
What should the proper Target be for finding an option like this using XPath?
Thanks Kindly!
解决方案 I actually figured out the problem - it's an issue with Kendo UI not supporting drop-downs properly. Basically the workaround is the click the drop-down arrow, then use sendKeys and point to the same Target as the drop-down with the value being whatever item you want from the list, then clicking the drop-down again. This worked for me, hopefully it helps somebody else!
这篇关于使用 Selenium IDE 选择下拉选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文