Last active
August 29, 2015 14:01
-
-
Save rossnz/be4fa82d8331c631dc8e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#------------------------------------------------------------------------------- | |
# Name: cookies.py | |
# Purpose: Import cookies as JSON and output in WPT script format | |
# | |
# Author: Ross Brown | |
# | |
# Created: 23/05/2014 | |
# Copyright: (c) RBrown 2014 | |
# Licence: Beerware | |
#------------------------------------------------------------------------------- | |
def main(): | |
import json | |
json_data=open('cookies.json') | |
data = json.load(json_data) | |
json_data.close() | |
# Change this to the site under test | |
testurl = "http://www.mysite.foo" | |
outfile = 'wpt.txt' | |
navline = "navigate " + testurl | |
for cookie in data: | |
line = "SetCookie {} {}={}\n".format(cookie["domain"],cookie["name"],cookie["value"]) | |
with open(outfile, 'a') as the_file: | |
the_file.write(line) | |
with open(outfile, 'a') as the_file: | |
the_file.write(navline) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment