Skip to content

Commit

Permalink
added title options for new har and new har page
Browse files Browse the repository at this point in the history
Signed-off-by: AutomatedTester <david.burns@theautomatedtester.co.uk>
  • Loading branch information
nicolasunravel authored and AutomatedTester committed Mar 31, 2016
1 parent 728dd46 commit 9840668
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions browsermobproxy/client.py
Expand Up @@ -99,24 +99,23 @@ def har(self):
return r.json()


def new_har(self, ref=None, options=None):
def new_har(self, ref=None, options=None, title=None):
"""
This sets a new HAR to be recorded
:param ref: A reference for the HAR. Defaults to None
:param options: A dictionary that will be passed to BrowserMob Proxy \
with specific keywords. Keywords are: \
captureHeaders - Boolean, capture headers \
captureContent - Boolean, capture content bodies \
captureBinaryContent - Boolean, capture binary content
:param title: the title of first har page. Defaults to ref.
"""
options = options if options is not None else {}
payload = {"initialPageRef": ref} if ref is not None else {}
if title is not None:
payload.update({'initialPageTitle': title})

if ref:
payload = {"initialPageRef": ref}
else:
payload = {}
if options:
payload.update(options)

Expand All @@ -126,17 +125,16 @@ def new_har(self, ref=None, options=None):
else:
return (r.status_code, None)

def new_page(self, ref=None):
def new_page(self, ref=None, title=None):
"""
This sets a new page to be recorded
:param ref: A reference for the new page. Defaults to None
:param title: the title of new har page. Defaults to ref.
"""
if ref:
payload = {"pageRef": ref}
else:
payload = {}
payload = {"pageRef": ref} if ref is not None else {}
if title is not None:
payload.update({'pageTitle': title})
r = requests.put('%s/proxy/%s/har/pageRef' % (self.host, self.port),
payload)
return r.status_code
Expand Down

0 comments on commit 9840668

Please sign in to comment.