How do you find the current url of a document in phantomjs ?

February 24, 2014

If you simply do the following in PhantomJS:

1
console.log( "- current url is " + document.URL );

then you will see the javascript filename you are running with PhantomJS.

If you want to see the URL of the currently loaded page, however, then you have to do it within the loaded page’s sandbox:

1
2
3
4
5
6
7
var url = page.evaluate(
    function () {
        return document.URL;
    }
);
 
console.log( "- current url is " + url );
 
Advertisements

Difference between text based, headless and normal browser

February 24, 2014

http://www.zenmeo.com/wordpress/what-is-headless-browser-the-list-of-headless-browser/