Reputation: 395
I am new to using protractor and want to visually see my web page scroll down to an element and it is not working. I understand scroll into allows me to visually see the scroll happen window.scroll to my understanding dosent all that. Any help would be appreciated
HTML CODE
a class="button button--secondary promo--app-button" href="https://itunes.apple.com/us/app/homes.com-real-estate-search/id306423353?mt=8&uo=4" target="_blank" data-tl-object="app_referral_hdc_portalhomefeatured_ios"> Apple Store
Protractor code:
it('scroll down page for (dropdown header search)', function () {
var EC = protractor.ExpectedConditions;
var scrolldown = $$('.button button--secondary promo--app-button').get(1);
scrolldown.scrollIntoView(true);
browser.sleep(10000);
})
Upvotes: 8
Views: 13434
Reputation: 3645
This should be simple. Just get the web-element's cor-ordinates and use Window.scroll
var elm = element(by.xpath("//blahblah"));
elm.getLocation()
.then(function(location) {
return browser.executeScript('window.scrollTo(' + location.x + ', ' + location.y + ');');
})
Upvotes: 3
Reputation: 1288
Try using browser.executeScript:
var scrolldown = $$('.button button--secondary promo--app-button').get(1);
browser.controlFlow().execute(function() {
browser.executeScript('arguments[0].scrollIntoView(true)', scrolldown.getWebElement());
});
Upvotes: 15