How to locate [(ngModel)] for protractor tests

不打扰是莪最后的温柔 提交于 2019-12-06 10:50:36
alecxe

The idea would be to locate the select element (by the preceding label, for example), evaluate teams, sort it alphabetically by name, get the first team and check that this is the same as the selectedTeamId model value:

var select = element(by.xpath("//span[starts-with(., 'Team')]/following-sibling::select"));

select.evaluate("teams").then(function(teams) {
    teams.sort(function(a, b) {
         return a["name"].localeCompare(b["name"])
    });
    var firstTeam = teams[0];

    expect(select.evaluate("selectedTeamId")).toEqual(firstTeam);
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!