-
-
Save zoghal/6c04a6ed67837e52047c to your computer and use it in GitHub Desktop.
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
# Installation: | |
# pip install selenium && curl -O http://chromedriver.storage.googleapis.com/2.8/chromedriver_mac32.zip && unzip chromedriver_mac32.zip && mv ./chromedriver /usr/local/bin/chromedriver | |
# Resources: | |
# ChromeDriver: https://code.google.com/p/selenium/wiki/ChromeDriver | |
# ChromeDriver Getting Started: https://sites.google.com/a/chromium.org/chromedriver/getting-started | |
# Selenium Python: http://selenium-python.readthedocs.org/en/latest/api.html | |
from selenium import webdriver | |
import time | |
screenshot_folder = '' | |
site = 'mysite.dev' | |
port = '8080' | |
browsers = ['Firefox','Chrome'] | |
pages = [''] | |
sizes = [360, 768, 992, 1200] | |
for browser in browsers: | |
if browser is 'Chrome': | |
driver = webdriver.Chrome("/usr/local/bin/chromedriver") | |
elif browser is 'Firefox': | |
driver = webdriver.Firefox() | |
for page in pages: | |
for width in sizes: | |
driver.get('http://%s:%s/%s' % (site, port, page)) | |
driver.set_window_size(width, 900) | |
# time.sleep(5) | |
screenshot = '%s%s-%s-%s@%s.png' % (screenshot_folder, browser, site, page, width) | |
print screenshot | |
driver.save_screenshot(screenshot) | |
driver.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment