填写搜索框,然后单击自动完成

Filling in a search box and then clicking on the autocomplete

我在填写和单击此搜索框时遇到问题

<input type="text" name="js-emu-operation-search" id="js-emu-operation-search" placeholder="Enter service name" autocomplete="off">

我试过使用

internet.fill_in('js-emu-operation-search', :with => "Alternator Replacement")

但它不起作用。填写完之后我也想知道如何点击第一个自动完成选项。

使用自动完成可能非常困难,具体取决于它的实现方式。我过去使用过的一些技巧:

  • 在发送文本之前点击输入

    find('#js-emu-operation-search').click()

  • 尝试使用底层元素方法而不是 fill_in 包装器,例如

    find('#js-emu-operation-search').set("Alternator Replacement")

  • Select 从带有 find("#results-pane", text: "My Result").click 的下拉选项中,或者如果您真的很绝望,请确保只有一个结果并且 select 它带有向下箭头,find('#js-emu-operation-search').native.send_keys(:arrow_down)

免责声明:我的水豚生锈了,可能需要修补一下。如果你在一个团队中工作,我也很幸运地将另一个开发人员拖入其中,最好是实现自动完成的人。