Does protractor.findElement () represent scrolling to this element?

My current unit test (protractor + angularJS project) does not work with UnknownError: unknown error: Element is not clickable at point (525, 1103) . I used the debugger to stop it just before the crash, and the only reason I can think that it will fail is because the button is not in the view port (you have to scroll down).

Bad lines

 homeLink = ptor.findElement(protractor.By.linkText('Home')); homeLink.click(); expect(ptor.getCurrentUrl()).toBe(homeUrl); 

From https://github.com/angular/protractor/issues/319 he says: "... when I use findElement (), it will scroll them to the" top "of the page. And the comments agree.

In my test, homeLink = ptor.findElement(protractor.By.linkText('Home')); page scrolling does not occur.

Am I mistaken in thinking that this should be?

What should I do?

+6
source share
2 answers

You need to scroll down (or increase the browser if this allows you to see the button you want to click) first, so that the button is visible on the page:

 var scrollIntoView = function () { arguments[0].scrollIntoView(); } browser.executeScript(scrollIntoView, yourwebelement); 
+9
source

don't forget to get webElement browser.driver.executeScript ("arguments [0] .scrollIntoView (true);", ed.getWebElement ());

+2
source

All Articles