【发布时间】:2010-10-10 18:22:40
【问题描述】:
我正在尝试通过编写 feks 创建填充 inn 文本字段的 watir 测试
“lon”并等待下拉菜单被触发,然后单击列表中的第一个元素。
写“lon”应该触发许多选项,例如“London, England, Storbritannia”, London, Kentucky, USA 等。 用watir有可能做到这一点吗? 提前谢谢。
这是我的代码到现在的样子, 它虽然不起作用,但我想知道我在哪里错过了一些东西。
def test_scriptflight_autocomplete @site.navigate_to(:travel, :flight) from_field = @site.ie.text_field(:id, "locOriginName") to_field = @site.ie.text_field(:id, 'locDestinationName') from_field.set('oslo')
# need to fire a key press event after setting the text since the js is handling
# trigger the autocomplete (requires a 'keydown')
from_field.fire_event('onkeydown')
# wait until the autocomplete gets populated with the AJAX call
@site.ie.wait_until{@site.ie.div(:id, 'onlinesearch').lis.length > 0}
puts @site.ie.div(:id, 'locOriginName ').lis.length
puts @site.ie.div(:id, 'locOriginName').li(:index, 5).text
# find the li you want to select in the autocomplete list and click it
@site.ie.div(:id, 'from-field').li(:text, 'Oslo, Oslo, Norge').click
结束
【问题讨论】: