How to trigger a window.scrollTo(x, y) in phantomJ

2019-07-21 21:21发布

问题:

I open a web page, and I want trigger a scrolling in onLoadFinished callback. but it dose't working. I also tried scrollPosition and set timer to sent key event. Both of them dose't working. So ask for help.

page.onLoadFinished = function() {
    window.scrollTo(0, document.height);
}

page.open('http://www.XXX.com', function (status) {
    if (status !== 'success') {
        console.log('Unable to open weibo.com');
    }
}

回答1:

Why would you need scrolling if you could open the page in the whole size? Just set size of the page to be whatever size you need.