Skip to content

Commit 9840668

Browse files
nicolasunravelAutomatedTester
authored andcommitted
added title options for new har and new har page
Signed-off-by: AutomatedTester <david.burns@theautomatedtester.co.uk>
1 parent 728dd46 commit 9840668

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

browsermobproxy/client.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,24 +99,23 @@ def har(self):
9999
return r.json()
100100

101101

102-
def new_har(self, ref=None, options=None):
102+
def new_har(self, ref=None, options=None, title=None):
103103
"""
104104
This sets a new HAR to be recorded
105105
106-
107106
:param ref: A reference for the HAR. Defaults to None
108107
:param options: A dictionary that will be passed to BrowserMob Proxy \
109108
with specific keywords. Keywords are: \
110109
captureHeaders - Boolean, capture headers \
111110
captureContent - Boolean, capture content bodies \
112111
captureBinaryContent - Boolean, capture binary content
112+
:param title: the title of first har page. Defaults to ref.
113113
"""
114114
options = options if options is not None else {}
115+
payload = {"initialPageRef": ref} if ref is not None else {}
116+
if title is not None:
117+
payload.update({'initialPageTitle': title})
115118

116-
if ref:
117-
payload = {"initialPageRef": ref}
118-
else:
119-
payload = {}
120119
if options:
121120
payload.update(options)
122121

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

129-
def new_page(self, ref=None):
128+
def new_page(self, ref=None, title=None):
130129
"""
131130
This sets a new page to be recorded
132131
133-
134132
:param ref: A reference for the new page. Defaults to None
133+
:param title: the title of new har page. Defaults to ref.
135134
"""
136-
if ref:
137-
payload = {"pageRef": ref}
138-
else:
139-
payload = {}
135+
payload = {"pageRef": ref} if ref is not None else {}
136+
if title is not None:
137+
payload.update({'pageTitle': title})
140138
r = requests.put('%s/proxy/%s/har/pageRef' % (self.host, self.port),
141139
payload)
142140
return r.status_code

0 commit comments

Comments
 (0)