I'm using grunt-mocha to run unit tests via phantomJS.
I know that phantomJS has a lot of useful functionality. Can I access that from within a mocha test?
I've looked in the obvious places such as the window
object to see if I can somehow access the page object, but nothing seems obvious.
Specifically, I'd like to render a screenshot of the page under test.
This is called "Screen Capture" in the documentation.
The important part is that you need a reference to the WebPage
, not the browser window
object (this just emulates what JavaScript can usually see from inside the browser).
var page = require('webpage').create();
page.open('http://github.com/', function () {
page.render('github.png');
phantom.exit();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With