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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -