我正在尝试通过编写 feks 创建填充文本字段的 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('奥斯陆')
# 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
结尾