我遇到了Webdriver的SendKeys方法特别令人沮丧的问题。我正在目睹正在填充的字段,但一旦删除焦点,字段就会被清除。
源代码段:
<div class="search-row__departure">
<div class="search-label">
<label onclick="$(this).parent().parent().find('.airport-input-row:first input, select').focus();">Departure</label>
</div>
<div class="search-input__text">
<span id="id23">
<span id="idc">
<div class="airport-input-row">
<span class="inputContainer">
<input id="id11" class="departurePoint" name="airport_selection_panel:departurePoint:departureAirportPanel:listView:0:selector:airportFragment:departurePoint" value="" autocomplete="off" onblur="var wcall=wicketAjaxPost('./?0-IBehaviorListener.4-brix~page~2-brix~journey~4-brix~package_search-child-child-packages_search_form-airport_selection_panel-departurePoint-departureAirportPanel-listView-0-selector-airportFragment-departurePoint', wicketSerialize(Wicket.$('id11')),function() { }.bind(this),function() { }.bind(this), function() {return Wicket.$('id11') != null;}.bind(this));" type="text"/>
</span>
<script>$(function(){$('#idc').parent().trigger('addField',['departurePoint','#idc .departurePoint']);})</script>
</div>
请注意,输入标记有许多属性。
我试过了:
inputField.clear();
inputField.click();
inputField.sendKeys("text to input");
还:
String script = "arguments[0].value='text to input';";
javaScriptExecutor("script here", inputField);
还:
inputField.sendKeys("text to input", Keys.TAB);
在所有情况下,当驾驶员移动到下一个字段时,该字段被填充然后被擦除。 FF或Chrome没有区别
我使用的是Selenium 3.0.0-beta3,Firefox 49.0,Chrome 53.