Protractor: cannot access input element

I have a problem with the method 'sendKeys()' in Chrome browser. I have page like this: enter image description here

A view looks like:

<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 &amp;&amp; maxlength, tabindex:states.tabIndex}" tabindex="0">
    </div>
    <div class="b-combobox__buttons ng-scope" ng-if="options.isDropButton || options.isActionVisible || options.showDropDownButton || (options.allowUserValue &amp;&amp; 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 &amp;&amp; !options.isDropButton" ps-attr="{main: states.main, disabled: states.disabled}" ps-mousedown="onShowListButton($event)" unselectable="on"></a>
    </div>
</div>
    "
              Значение из списка: (), произвольное зхначение: ()
    "

I want to send into this field Key.DOWN. Or just write some text. But when I try to do this I have the error: "cannot focus element". When I try to click() this element it's work fine. I tried to add browser.ignoreSynchronization = true; into my code, but it didn't help.

Upvotes: 1

Views: 2822

Answers (1)

alecxe
alecxe

Reputation: 473873

I think you need to first click the element to enter the editable mode, then enter text into the input:

var dropdown = element(by.name("autocomplete1"));
dropdown.click();

var input = dropdown.element(by.css('input[ps-link-element="elements.input_editable"]'));
input.sendKeys("test");

This is still a guess/shot in the dark since I'm not able to reproduce the issue.

Upvotes: 2

Related Questions