Reputation: 317
While i am using protractor with firefox (ubuntu) 46 all my test are green but when i use chrome some of them fails becouse command browser.executeScript('window.scrollTo(0,10000);');
doesn't work properly. I was trying to use :
var elm = element(by.sth)
browser.executeScript("arguments[0].scrollIntoView();", elm.getWebElement());
or
scrollIntoView : function(){ arguments[0].scrollIntoView(); }
but they didn't work aswell.
And my second question is, when i try to start the same test on Windows they all fail becouse of missing locators etc. is it becouse of archtecture differences of browseres or my tests aren't writen well.
Upvotes: 0
Views: 222
Reputation: 317
I resolved problem.
Problem was with promises, We must treat browser.executeScript('window.scroll(0,600);')
as a promise so if the test is too fast ,it fails.
Solution is using :
browser.executeScript('window.scroll(0,600);').then(function(){
return this;
});
It also fix problem with missing locators, becouse the have time to load on windows.
Upvotes: 1
Reputation: 41
Are you sure you need to use scrollIntoView ? I have scrollbars in the app I test, but Protractor scrolls automatically when needed.
Otherwise it would be helpful to have more details about the failure. What error message do you get? In what context is called your function? An extract of your code could help.
Upvotes: 0