Skip to content

Instantly share code, notes, and snippets.

@rossnz
Last active August 29, 2015 14:01
Show Gist options
  • Save rossnz/be4fa82d8331c631dc8e to your computer and use it in GitHub Desktop.
Save rossnz/be4fa82d8331c631dc8e to your computer and use it in GitHub Desktop.
#-------------------------------------------------------------------------------
# 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