1

I created a html page (stored locally) that uses Googlemaps API. My whole page is a basic google map with some customization. I want to take a screenshot every time I change some parameters in the customization so later I can easily compare.

I've found this similar answer and I got it to work on my machine. However, when I change the url from an actual webpage into my own local html file, Phantomjs only saves an entirely black image.

Here is my script.

var WebPage = require('webpage');
page = WebPage.create();
page.open('googlemaps_demo.html');
page.onLoadFinished = function() {
   page.render('myScreenShot' + '.png');
   phantom.exit();}

The file googlemaps_demo.html and this js script itself are in the same folder. Could someone explain to me why this code only works for an online url, but not a local html file? And how to fix it?

Community
  • 1
  • 1
F.S.
  • 1,175
  • 2
  • 14
  • 34

1 Answers1

2

You probably need to specify file using a file:/// scheme and a full location of your file, e.g. file:///c:/local/page.htm

oldbam
  • 2,397
  • 1
  • 16
  • 24
  • thanks for the suggestion. I made it work by using only forward slashes in the entire address, like file:///c:/Users/me/...... Just curious why you switch two slashes? – F.S. Aug 09 '16 at 20:57