Wednesday, 29 April 2015

angularjs Protractor

When you do e2e test for angular by Protractor, sometimes you may find protractor can't give you the full accessing of all you html elements, for example, if you want to test scroll bar.

If you want to get a value, you should add "return" at the beginning and use call back:

 browser.executeScript('return document.body.scrollTop').then(function(scrollTop){
       console.log("scrollTop = " + scrollTop);

If you want to assert this value, you didn't need : do it in the callback:

expect(browser.executeScript('return document.body.scrollTop')).toEqual(130)

If you want to run a script or multi scripts:

browser.executeScript(' = "100000px"; window.scrollTo(0,document.body.scrollHeight)').then(function(){


No comments:

Post a comment