用UI选量角器测试 [英] Testing with protractor using ui-select

查看:249
本文介绍了用UI选量角器测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想测试一个用户界面,选择用量角器。在此UI,选择我的国家名单。
我的HTML如下:

I am trying to test an ui-select with protractor. In this ui-select I have a list of countries. My html looks like:

<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>

我的页面对象如下:

My page object looks like:

this.country = element(by.model('datiAnagrafici.countryOfBirth'));
this.fillForm = function(){
   this.country.sendKeys('IT');
}

在我的规格文件中我有:

In my spec file I have:

it('should fill the form', function() {
  form.fillForm();
})

但是,当我运行我的测试NG-模型不填充发送的数据。
你有什么建议吗?
谢谢

But when i run my test the ng-model is not filled with the sent data. Do you have any tips? Thanks

推荐答案

我已经找到了解决方案的这里

I have found the solution here

this.country = element(by.model('datiAnagrafici.countryOfBirth'));
this.selectCountry = this.country.element(by.css('.ui-select-search'));

在填表方法

然后是几乎一样alecxe说:

then in the fill form method is almost as alecxe said:

this.country.click();
this.selectCountry.sendKeys('Italy');

这篇关于用UI选量角器测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆