我在Chrome浏览器中使用'sendKeys()'方法时遇到问题。 我有这样的页面:
视图如下:
<td class="ng-binding">
<div class="b-combobox ps-list-drop-single-autocomplete ng-isolate-scope ng-pristine ng-required ng-invalid ng-invalid-required" required="required" placeholder="Еnто placeholder деTка!" name="autocomplete1" text="autocomplete.text" style="width: 200px; padding-right: 16px;" selected="selected" options="{allowUserValue: true}">
<div data-for="drop-single-autocomplete" ps-link-element="elements.input_wrap" class="b-combobox__autocomplete b-combobox__value_full_size">
<input ps-link-element="elements.input_offer" tabindex="-1" readonly="" class="b-combobox__input b-combobox__placeholder" type="text">
<input ps-link-element="elements.input_editable" on-link-element="onLinkInputEditable()" ng-readonly="states.readonly || states.disabled" class="b-combobox__input" type="text" ps-attr="{maxlength: +maxlength >= 0 && maxlength, tabindex:states.tabIndex}" tabindex="0">
</div>
<div class="b-combobox__buttons ng-scope" ng-if="options.isDropButton || options.isActionVisible || options.showDropDownButton || (options.allowUserValue && options.isDropSingleAutocomplete)" ps-link-element="elements.buttons" on-link-element="onLinkButtons()" unselectable="on">
<a class="b-button_arrow b-button ng-scope" tabindex="-1" ng-if="options.showDropDownButton && !options.isDropButton" ps-attr="{main: states.main, disabled: states.disabled}" ps-mousedown="onShowListButton($event)" unselectable="on"></a>
</div>
</div>
"
Значение из списка: (), произвольное зхначение: ()
"
我想发送到Key.DOWN这个字段。或者只写一些文字。但是,当我尝试这样做时,我有错误:“无法聚焦元素”。当我尝试点击()这个元素时它工作正常。
我尝试将browser.ignoreSynchronization = true;
添加到我的代码中,但它没有帮助。
答案 0 :(得分:2)
我认为你需要先点击元素进入可编辑模式,然后在输入中输入文字:
var dropdown = element(by.name("autocomplete1"));
dropdown.click();
var input = dropdown.element(by.css('input[ps-link-element="elements.input_editable"]'));
input.sendKeys("test");
由于我无法重现这个问题,所以这仍然是在黑暗中猜测/拍摄。