Firewatir:Firewatir 脚本从下拉列表中选择一个项目
我是 Watir 自动化测试的新手,希望获得一些有关下拉菜单的帮助。在我们的网站上,我们有一个州下拉菜单,您可以在其中输入州的第一个字母(在我的示例中,C 代表加利福尼亚州),它会缩小范围找到以 C 开头的所有州。获得列表后,您需要单击正确的州。但我很难选择正确的状态。
(下面是我们网站上的 html:
<div class="x-form-field-wrap x-trigger-wrap-focus" id="ext-gen202" style="width: 166px;">
<input type="hidden" id="entityStateCode" name="entityStateCode" value="">
<input type="text" id="ext-comp-1005" autocomplete="off" size="24" class=" x-form-text x-form-field x-form-focus">
我使用以下内容来自动化该场景,但这些都没有给我我想要的东西:
@browser.text_field(:id,"ext-comp-1005").value=( "CA")
@browser.text_field(:id,"ext-comp-1005").set("CA")
@browser.text_field(:id=> "ext-comp-1055",:index =>; 5).set“CA”
如果您能为我指明正确的方向,我真的很感激
。
I am new to Watir automation testing and would like to get some help for the drop down.On our website we have a state drop down where you enter the first letter of the state (in my example C for California) and it narrows it down to the all states starting with C. Once you have the list you need to click on the correct state. But I am having difficulties selecting the correct state.
(Below is the html from our website:
<div class="x-form-field-wrap x-trigger-wrap-focus" id="ext-gen202" style="width: 166px;">
<input type="hidden" id="entityStateCode" name="entityStateCode" value="">
<input type="text" id="ext-comp-1005" autocomplete="off" size="24" class=" x-form-text x-form-field x-form-focus">
I used the following to automate the scenario but none of these are giving me what i am looking for:
@browser.text_field(:id,"ext-comp-1005").value=("CA")
@browser.text_field(:id,"ext-comp-1005").set("CA")
@browser.text_field(:id=> "ext-comp-1055",:index => 5).set "CA"
I really appreciate that if you can point me to the right direction.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我以前遇到过类似的情况。在我的情况下,DIV 中有一个表,动态下拉列表中的每个项目都有一个单独的行。因此,如果您遇到这种情况,那么您需要使用类似的方法来访问这些项目:
尝试在运行时打印 DIV 的 HTML,以查看您需要交互的具体内容(如果这不起作用)。
I ran into a similar situation before. In my situation there was a TABLE inside the DIV which had a separate row for each item in the dynamic drop down. So, if that's the case for you then you would need to use something like this to access the items:
Try printing out the HTML for the DIV at runtime to see the specifics of what you need to interact with if that doesn't work.
你没有说出问题是什么,这还不够:
This should Enter
CA
into text field:如果在错误的文本字段中输入文本,请更改
:id =>; “ext-comp-1005”
。如果它正在将文本输入到正确的文本字段中,但没有出现状态列表,则您可能必须触发一些 javascript 事件。查看如何找出触发了哪些 JavaScript 事件? 问题。
You did not tell what the problem is, this is not enough:
This should enter
CA
into text field:If it is entering text into wrong text field, change
:id => "ext-comp-1005"
.If it is entering text into the correct text field, but list of states does not appear, you probably have to fire some javascript event. Take a look at How to find out which JavaScript events fired? question.