Last active
August 29, 2015 14:24
-
-
Save jlas/10b8db183de909f26265 to your computer and use it in GitHub Desktop.
Take a screenshot with selenium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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