@Ojaswini, Phantomjs is used for automating webpage interactions. It's discontinued Headless browser which provides a Javascript API enabling automated navigation, screenshots, user behavior and assertions.It is a common tool used to run browser-based unit tests in headless system. You can use phantomJs for capturing screenshot this way:
var webpage = require('webpage').create();
webpage.open('http://google.com/', function() {
webpage.render('screenshot.pdf');
phantom.exit();
});