Skip to content

Instantly share code, notes, and snippets.

@jlas
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlas/10b8db183de909f26265 to your computer and use it in GitHub Desktop.
Save jlas/10b8db183de909f26265 to your computer and use it in GitHub Desktop.
Take a screenshot with selenium
#!/usr/bin/env python
'''Script for taking a screenshot with selenium
Install selenium using pip:
[sudo] pip install selenium
'''
import os
from selenium import webdriver
# you'll need to download chromedriver, available here:
# https://code.google.com/p/selenium/wiki/ChromeDriver
# alternatively, you can use webdriver.Firefox() if you have firefox installed
d = webdriver.Chrome()
# iphone 5 resolution is 620x1136
d.set_window_size(640, 1136)
d.get('http://www.m.wikipedia.com')
homedir = os.environ.get('HOME')
d.save_screenshot(os.path.join(homedir, 'screenshot.png'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment