When I run scrollIntoView script, protractor gets blocked and starts to increase resource consumption
My code is:
el = element(by.xpath('//a[@class="navigation-button" and text()="Text"]'));
browser.executeScript('arguments[0].scrollIntoView()', el);
If there is no scrollbar and there is not need to scroll to the element (because the window size of the browser does not require the scrollbar), protractor starts to consume too much ram and cpu until it blocks the whole computer.
Have you tried replacing the last line with:
browser.executeScript('arguments[0].scrollIntoView()', el.getWebElement());
browser.executeScript() is a webdriver function, and is intended to take webdriver elements, not protractor's wrapped version.
Thanks. I forgot to upload my solution, that was the same. If you can add it in someway to the documentation, I think a lot of people would benefit from it :-)
@sjelin : Is the getWebElement() part still needed?
Reading
https://github.com/angular/protractor/blob/master/spec/basic/elements_spec.js#L175 and
https://github.com/angular/protractor/blob/master/spec/ts/basic/element_spec.ts#L161
it looks to me the getWebElement() became obsolete.
Having that said and given, that scrollIntoView() is a rather important function for Protractor, I'd like to suggest, that it should be found in Protractor documentation or even there should be a Protractor function, which makes the browser.executeScript() part obsolete.
What do you think?