javascript - Protractor: Compare two element for equality -
i have list of elements
list = element.all(by.css(....));
one of them has specific attribute
specific = list.element(by.css('[active]');
now check if specific
element first
expect(list.get(0)).tobe(specific)
however doesn't work (it doesn't match). suggestion how compare elements?
you can value of active
attribute , see if not null:
expect(list.first().getattribute("active")).not.tobenull();
you cannot though directly compare elements, but, can compare id
s or outerhtml
attribute values of elements:
expect(list.first().getid()).toequal(specific.id()); expect(list.first().getattribute("outerhtml")).toequal(specific.getattribute("outerhtml"));
Comments
Post a Comment