我的页面上有一个这样的选择框:
<select id="typeSelect"
ng-model="typeId"
ng-options="item.id as item.name for item in types"></select>
当我的页面控制器启动时,它应该从服务器获得类型列表。一旦列表准备好,那么它应该选择第一个类型,它的值为"*"。
我对Protractor如何与选择列表连接感到非常困惑,该列表用于单击选择并确定所选内容。
有人能给我一些建议,我如何可以测试,如果值是"*"?
如果我理解正确的话,下面是我针对您的情况进行的一个测试:
describe('typeSelect startup', function() {
var typeSelect;
beforeEach(function() {
/*
* I don't know how your list is getting updated with server data
* But if it's the result of an action you have to perform it and
* declare your elements into the .then() function
*/
updateButton.click().then(function() {
// might be necessary but not always
browser.waitForAngular();
typeSelect = element(by.id('typeSelect'));
});
});
it('should have "*" value', function() {
expect(typeSelect.getAttribute('value')).toEqual('*');
});
});