-
-
Save idettman/d5d06f595a0492ae369cf634693c73d5 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
import time | |
from browsermobproxy import Server | |
server = Server('/Users/dhunt/Downloads/browsermob-proxy-2.0-beta-6/bin/browsermob-proxy') | |
server.start() | |
proxy = server.create_proxy() | |
from selenium import webdriver | |
profile = webdriver.FirefoxProfile() | |
profile.set_proxy(proxy.selenium_proxy()) | |
driver = webdriver.Firefox(firefox_profile=profile) | |
proxy.new_har('firefox') | |
driver.get('http://www.mozilla.org/') | |
download_buttons = driver.find_elements_by_class_name('download-firefox') | |
for button in download_buttons: | |
if button.is_displayed(): | |
break | |
else: | |
continue | |
button.click() | |
time.sleep(10) | |
assert proxy.har['log']['entries'][-1]['request']['url'] == 'http://download.cdn.mozilla.net/pub/mozilla.org/firefox/releases/15.0/mac/en-US/Firefox%2015.0.dmg' | |
time.sleep(10) | |
assert proxy.har['log']['entries'][-1]['response']['status'] == 200 | |
assert proxy.har['log']['entries'][-1]['response']['content']['mimeType'] == 'application/x-apple-diskimage' | |
assert proxy.har['log']['entries'][-1]['response']['content']['size'] == 34139395 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment