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 reference, here is some test html that brings up a Google API map (note: will require API key): https://developers.google.com/maps/documentation/javascript/earthquakes
Here is my code:
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
def maps():
driver = webdriver.PhantomJS()
driver.set_window_size(640,640)
driver.implicitly_wait(5)
driver.get("file:///U:/ABC%20Comps/test.html")
element = driver.find_element_by_id('map')
driver.save_screenshot('test.png')
driver.quit()
`
Can someone point me in the right direction?