angularjs - Expect two elements to be equal -
i want test if 2 elements in 2 different pages equal. reason need check "copy" function works in page, both elements (divs in case) have indentical:
i found there's method in protractor element objects called "clone" doesn't explains purpose much. anyway tried this:
// in first page: browser.get("/page1"); var clone1 = element(by.id("firstelem")).clone(); // navigating other page browser.get("/page2"); var clone2 = element(by.id("secondelem")).clone(); // expectation of them equal expect(clone1).toequal(clone2); but expectation fails heavy stacktrace. tried comparing:
expect(clone1 == clone2).tobetruthy(); which fails again.
what "clone()" supposed used for? and,
how compare 2 divs in 2 separate pages being identical?
what "clone()" supposed used for?
i've created closely related question, can follow updates there:
how compare 2 divs in 2 separate pages being identical?
depending on end goal, may compare "outer html" representations of elements using getouterhtml() , example:
browser.get("/page1"); element(by.id("firstelem")).getouterhtml().then(function(value) { browser.get("/page2"); expect(element(by.id("secondelem")).getouterhtml()).toequal(value); });
Comments
Post a Comment