获取值的代码
var archived_projects_before = element.all(by.css('a[ng-click="setCurrentGroup(tab)"]')).get(6).getText().then(function(text){console.log(text);})
var archived_projects_before = element.all(by.css('a[ng-click="setCurrentGroupproject(tab)"]')).get(6).getText().then(function(text){console.log(text);})
使用此代码得到两个值,即:
5,
6
问题:如果两个值相同,我必须断言为真,如果不是,我必须断言假
这是我试过的
expect(values).not.toBeDefined(values)
expect(values).toEqual(values);
expect(values).not.toBe(values)
请帮帮我
答案 0 :(得分:0)
您不必使用values
链接分别获取.then()
。默认情况下,expect
语句解析方法返回的promise。你只需要在期望陈述中使用它们。这是怎样的 -
var archived_projects_before = element.all(by.css('a[ng-click="setCurrentGroup(tab)"]')).get(6);
var archived_projects_before_1 = element.all(by.css('a[ng-click="setCurrentGroupproject(tab)"]')).get(6);
expect(archived_projects_before.getText()).toEqual(archived_projects_before_1.getText()); //Check for equality of values
上述expect
语句如果两者相等则会通过,否则会抛出以下格式的错误 -
预期5到等于6
同样,您可以测试您想要的其他条件 -
expect(archived_projects_before.getText()).toBeDefined(); //Check if the value is not undefined and should have a valid value
expect(archived_projects_before_1.getText()).toBeDefined(); //Check if the value is not undefined and should have a valid value
expect(archived_projects_before.getText()).not.toEqual(archived_projects_before_1.getText()); //Check for the inequality of values. This will throw error if the values passed are equal in terms of both type and value.
希望它有所帮助。