Explore Courses Blog Tutorials Interview Questions
+1 vote
in DevOps and Agile by (19.7k points)

I am trying to use Selenium, PhantomJS, and GoogleMaps API to automatically screenshot / save down maps. The url I request is a local html file with javascript to generate the map. When I open the local file, I am able to view the map, however, when I run the following code and attempt to screenshot the map, only a blank picture is saved.

I have explored the Google Static Maps API, but my maps have hundreds of markers, exceeding the URL length limit. I am trying to screenshot hundreds of maps that will change over time and need to be a set size. I believe this is the best way to go about it.

As a reference, here is some test html that brings up a Google API map (note: will require API key):

Here is my code:

from selenium import webdriver

from import WebDriverWait

from import expected_conditions as EC

def maps():

    driver = webdriver.PhantomJS()




    element = driver.find_element_by_id('map')



`Can someone point me in the right direction?

1 Answer

0 votes
by (62.9k points)


var page = require('webpage').create();'', function () { page.render('github.png'); phantom.exit(); });

This is how to get a screenshot in phantomJS, I've used phantomJS for some time now.

You can find more information here.


driver = webdriver.Chrome(); driver.get(''); driver.save_screenshot('out.png'); driver.quit();

Hope this helps.

Browse Categories