Selenium - screenshot images taken by headless server are mangled
Question: I am using selenium webdriver (Python version) to take images of a web page
after it loads. When I go to a page and save an image using a python script on
my local computer, it looks fine. However, I am running the script on a server
and there the screenshots are mangled- the edge might be cut off with text
missing, banners on the right side might be pushed to the bottom in a jumbled
fashion, etc. I even tried maximizing the window

    
    
    driver.get(url)
    driver.maximize_window()
    time.sleep(4)
    driver.save_screenshot('screen.png')
    

On the server, I cannot load firefox in a headed version and must manually
start/stop the display in my script before/after running selenium

    
    
    from pyvirtualdisplay.xvnc import XvncDisplay
    display = XvncDisplay(rfbport='####')
    display.start()
    

So I'm thinking this might have to do with the settings of my display.

Anyone have any ideas on how to fix this? Thanks


Answer: Try chomium + chromedriver instead. It works for me, even though I didn't have
the problem you describe. Just an idea.

Download chromedriver to /usr/local/bin
<https://sites.google.com/a/chromium.org/chromedriver/downloads> and don't
forget `chmod a+x /usr/local/bin/chromedriver`

I used this blog post: <http://coreygoldberg.blogspot.cz/2011/07/python-
taking-browser-screenshots-with.html>

