Sunny
Sunny

Reputation: 478

How to use callbacks in phantomjs

I am using phantomjs for testing one web application. but i am facing problem with page load means sometimes phantom script executed but dom element is not loaded. How to use callbacks for sorting this kind of issues

resourceReceived(request),resourceRequested(resource),resourceError(resource)

Upvotes: 0

Views: 455

Answers (1)

Cameron Tinker
Cameron Tinker

Reputation: 9789

If you want to execute code after the page has finished loading, use this:

page.onLoadFinished = function() 
{
    // function body
    var pageTitle = page.evaluate(function() {
            console.log('Page Name: ' + document.title);
            return document.title;
    });
};

Upvotes: 1

Related Questions