javascript - Protractor.js test case for Horizontal Scrolling and vertical Scrolling in angular2 -
how write test case identify whether view has horizontal or vertical scrolling through protactor angularjs2?
here reusable jasmine matcher use check if element has vertical scroll (reference: expect element have scroll) (cannot guarantee work in or of cases, of course - works though):
beforeeach(function() { jasmine.addmatchers({ tohavescroll: function() { return { compare: function(elm) { return { pass: protractor.promise.all([ elm.getsize(), elm.getattribute("scrollheight") ]).then(helpers.spread(function (size, scrollheight) { return scrollheight >= size.height; })) }; } }; } }); });
usage sample:
expect(loginpage.license).tohavescroll();
fyi, here 1 - checking if there scroll on page using overflowx
, overflowy
css properties:
tohavescrollonpage: function() { return { compare: function(elm, visibility) { return { pass: protractor.promise.all([ elm.getcssvalue('overflowy'), elm.getcssvalue('overflowx') ]).then(helpers.spread(function (horz, vert) { if (visibility) { return horz.indexof("visible") !== -1 || vert.indexof("visible") !== -1; } else { return horz.indexof("visible") === -1 && vert.indexof("visible") === -1; } })) }; } }; },
note don't have wrap logic jasmine matchers - can make helper functions or use logic in suitable in case way.
Comments
Post a Comment