我需要测试两个文本框。 这是页面视图:
<div class="wrap-ctrl ng-scope" ng-switch-when="input">
<input type="text" name="surnameInput" class="text-field ng-pristine ng-isolate-scope ng-pending ng-touched" data-ng-class="::surnameFeature ? 'box-ctrl_tooltip' : ''" placeholder="Input surname" data-ng-model="input.surname" ng-model-options="{updateOn: 'blur'}" data-input-type="FIO-SURNAME" data-dts-input="" data-ng-disabled="$root.isDisabled(prefix + 'surnameInput')" data-validator="restrictValue, required, percentCyrillic=50" data-message-id="surnameErrors" data-warning="isTrueGenderSurname" data-warning-id="surnameWarnings">
<!-- ngIf: ::surnameFeature -->
<!-- ngIf: ::surnameFeature -->
<div id="surnameErrors" class="form-error-messages"></div>
<div id="surnameWarnings" class="form-error-messages"></div>
</div>
<div name="name" data-ng-class="::nameFeature ? 'box-ctrl_tooltip' : ''" placeholder="Input name" data-ng-model="person.name" data-options="item as item for item in data.items, count by data.totalCount" data-data-limit="10" data-min-length="2" data-is-search-from-start="true" data-ng-params="urlParams()" data-url="/test/api/autocomplite/names/" data-input-type="FIO-NAME" data-dts-typeahead="" custom-class="wrap-ctrl angucomplete-holder" data-ng-disabled="$root.isDisabled(prefix + 'name')" data-validator="restrictValue, required, percentCyrillic=50" data-message-id="nameErrors" warning="isTrueGenderName" data-warning-id="nameWarnings" class="ng-untouched ng-isolate-scope tt-container wrap-ctrl angucomplete-holder ng-pending ng-dirty ng-valid-parse"><input class="tt-hint text-field" type="text" tabindex="-1" style="opacity: 1;"><input class="tt-input text-field" type="text" dts-highlighter="focus" placeholder="Input name"></div>
(http://pastebin.com/Y9APWST4)
第一个问题我没有问题,但第二个问题无法解决。
var surname = element(by.model('input.surname'));
var name = element(by.model('person.name'));
surname.click().sendKeys('Smith'); //works great
name.click().sendKeys('John'); //doesn't work
我从朋友那里得到了一个我应该使用链式定位器的提示,所以我尝试了这个:
var name = element(by.model('person.name').element(by.css('input:not([tabindex="-1"])')));
但它也不起作用。有什么建议吗?
答案 0 :(得分:0)
var name = element.all(by.model('person.name')).get(0).element(by.css('[dts-highlighter="focus"]'));