Selenium webdriver with Phantomjs save_screenshot not working in Docker container
The same code works on my local machine, but doesn't work in a Docker container. On my local machine, it stores the image of the desired website as intended. In the Docker container, it saves the .png file with the correct name, but the image is only 8KB and empty. The error message is missing. The Docker container has internet access because pinging google.com from the bash container shows the internet connection is working. Likewise, if I try to get it to show me the html from this page, it doesn't work in Docker, but succeed on my local system. Any idea what is wrong here?
Here's the code that calls selenium and phantoms:
def init_driver():
driver = webdriver.PhantomJS()
driver.set_window_size(1600, 1200)
# must give the page enough time to fully render
driver.implicitly_wait(WAIT_TIME)
return driver
def render_page(driver, url):
driver.get(url)
def save_image(driver, path):
driver.save_screenshot(path)
IMAGE_NAME = 'test_image.png'
WAIT_TIME = 10
url = 'https://www.google.com/'
driver = phantom_tools.init_driver()
render_page(driver, url)
save_image(driver, IMAGE_NAME)
+3
source to share
No one has answered this question yet
Check out similar questions: