Hikaryu Hikaryu - 6 months ago 41
Javascript Question

Protractor test works on Firefox but fails on Chrome

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.

Answer

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.