javascript - How to compare two values in protractor? -


code values

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);}) 

using code getting 2 values i.e:

5, 6 

problem: if 2 values same have assert true,if not have assert false

this tried

expect(values).not.tobedefined(values) expect(values).toequal(values); expect(values).not.tobe(values) 

please me

you don't have values separately using .then() chaining. expect statement default resolves promises methods return. have use them in expect statement. here's how -

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 equality of values 

the above expect statement passes if both equal, else throw error following format-

expected 5 equal 6

similarly can test other conditions want -

expect(archived_projects_before.gettext()).tobedefined(); //check if value not undefined , should have valid value expect(archived_projects_before_1.gettext()).tobedefined(); //check if value not undefined , should have valid value  expect(archived_projects_before.gettext()).not.toequal(archived_projects_before_1.gettext()); //check inequality of values. throw error if values passed equal in terms of both type , value. 

hope helps.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -