由於HTML:
<input type="text" size="30" class="searchText" dojoattachpoint="_searchTextAP" id="xwt_widget_uishell_Header17_2_search_searchTextAP" dojoattachevent="onfocus:_onFocus_searchTextAP,onblur:_onBlur_searchTextAP, onkeyup:_onKeyUp_searchTextAP">
它看起來像元素被監聽這些事件(通過道場):onfocus
,onblur
,onKeyUp
要觸發這些事件,您需要使用如下所示:
browser.text_field(:id => /.*searchTextAP$/).focus
browser.element(:id => 'someOtherElement').focus
browser.text_field(:id => /.*searchTextAP$/).fire_event "onkeyup"
如果你想提交表單,你可能需要點擊提交按鈕(既然你提到打:enter
):
browser.button(:type => 'submit').click
如果你真的想只發送:enter
鍵,的一個其他答案應該工作。
– user1771980 2013-02-13 18:11:40
可有人PLZ幫助我,緊急..我看到這些工作在google.com的搜索文本字段。但不是在我的應用程序:(任何想法? – user1771980 2013-02-13 21:11:26
@ user1771980,你試過讓開發者看看他們正在收聽什麼事件嗎? – 2013-02-14 14:05:04