Page is not completely loaded/rendered when onLoadFinished fires

前端 未结 1 387
礼貌的吻别
礼貌的吻别 2021-01-21 16:43

I\'m using Phantomjs to examine my application. The page I am looking at includes a lot of components and is powered by Angularjs. My test server is slow. In the onLoadFin

1条回答
  •  借酒劲吻你
    2021-01-21 17:42

    You might find a way here to register an event when angular has finished rendering, but it might not be necessary if you are willing to wait a static amount of time:

    page.onLoadFinished = function(response) {
        console.log(response, page.url);
        if (page.url.indexOf("login") == -1) {
            setTimeout(function(){
                page.render('zoot.png');
                phantom.exit();
            }, 1000);
        }
    };
    

    You can also use waitFor to explicitly wait for the appearance of a selector which denotes the end of the load.

    Note that page.open(url); and page.onLoadFinished = finishedFunction; is the same as page.open(url, finishedFunction).

    0 讨论(0)
提交回复
热议问题