Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protractor scroll into view not working

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);
    })
like image 902
Jonathan Avatar asked Sep 08 '16 20:09

Jonathan


1 Answers

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());
    });
like image 59
martin770 Avatar answered Sep 25 '22 07:09

martin770