Protractor: Scroll down

后端 未结 9 464
有刺的猬
有刺的猬 2020-11-30 04:59

I have an button on my page that is visible when the user scrolls down. Because of this, protractor tests give me an error:

UnknownError: unknown erro

9条回答
  •  隐瞒了意图╮
    2020-11-30 05:06

    I'd like to add to the previous answer, and hopefully provide a little more explanation.

    This code, in the call to 'executeScript':

    'window.scrollTo(0,0);'
    
    • Scrolls the window UP, to window coordinates 0,0...essentially to the very top
    • If you know the specific area you need to go to, just change the coordinates.

    If you know you want to be at the very bottom of the window, which was my goal. You can put a very large number in the 'y' coordinate, like I did here:

    browser.executeScript('window.scrollTo(0,10000);').then(function () {
        expect(.).toBe();
    })
    

提交回复
热议问题