protractor icon indicating copy to clipboard operation
protractor copied to clipboard

When I run scrollIntoView script, protractor gets blocked and starts to increase resource consumption

Open bitliner opened this issue 11 years ago • 3 comments

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.

bitliner avatar Jan 23 '15 18:01 bitliner

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.

sjelin avatar Jan 23 '15 22:01 sjelin

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 :-)

bitliner avatar Jan 24 '15 00:01 bitliner

@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?

zwingliernst avatar Nov 27 '17 10:11 zwingliernst