使用ui-select使用量角器进行测试

Gia*_*fra 6 javascript testing angularjs protractor angular-ui-select

我正在尝试用量角器测试ui-select.在这个ui-select我有一个国家列表.我的HTML看起来像:

<ui-select ng-model="datiAnagrafici.countryOfBirth" name="countryOfBirth" theme="bootstrap" reset-search-input="true" append-to-body="true" required blur>
                <ui-select-match placeholder="paese di nascita">{{$select.selected.name}}</ui-select-match>
                <ui-select-choices repeat="country.code as country in countries | filter: {name:$select.search}">
                    <span ng-bind-html="country.name"></span>
                </ui-select-choices>
</ui-select>
Run Code Online (Sandbox Code Playgroud)

我的页面对象如下所示:

this.country = element(by.model('datiAnagrafici.countryOfBirth'));
this.fillForm = function(){
   this.country.sendKeys('IT');
}
Run Code Online (Sandbox Code Playgroud)

在我的spec文件中,我有:

it('should fill the form', function() {
  form.fillForm();
})
Run Code Online (Sandbox Code Playgroud)

但是当我运行我的测试时,ng-model没有填充发送的数据.你有什么建议吗?谢谢

Gia*_*fra 7

我在这里找到了解决方案

this.country = element(by.model('datiAnagrafici.countryOfBirth'));
this.selectCountry = this.country.element(by.css('.ui-select-search'));
Run Code Online (Sandbox Code Playgroud)

然后在填充表格方法几乎像alecxe说的那样:

this.country.click();
this.selectCountry.sendKeys('Italy');
Run Code Online (Sandbox Code Playgroud)