Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"No JSON object" error when calling new_har() with parameters #77

Open
flesheatingarthropods opened this issue Oct 6, 2017 · 0 comments

Comments

@flesheatingarthropods
Copy link

I am using MacOS 10.12.6. with the preinstalled Python 2.7.10. and browsermobproxy 2.1.4.

browsermobproxy-py is version 0.8.0 installed via pip.

I trying to create har files with the following code (which mostly works):

from browsermobproxy import Server
server = Server("browsermob-proxy/bin/browsermob-proxy")
server.start()
proxy = server.create_proxy()

from selenium import webdriver

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--allow-file-access-from-files");
chrome_options.add_argument("disable-infobars");
chrome_options.add_argument("--proxy-server={0}".format(proxy.proxy))
driver = webdriver.Chrome(chrome_options = chrome_options)

proxy.new_har('someString')
driver.get("https://www.google.de/")
result = proxy.har # returns a HAR JSON blob

server.stop()
driver.quit()

If I understand the documentation correctly then the first argument to new_har() is an arbitrary string to disambiguate multiple har files if I want to record har files from multiple urls in one go. However whenever I supply that argument I get the following output:

Traceback (most recent call last):
File "test.py", line 23, in
result = proxy.har # returns a HAR JSON blob
File "build/bdist.macosx-10.12-intel/egg/browsermobproxy/client.py", line 104, in har
File "/Library/Python/2.7/site-packages/requests-2.18.4-py2.7.egg/requests/models.py", line 892, in json
return complexjson.loads(self.text, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/init.py", line 338, in loads
return _default_decoder.decode(s)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 384, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

The return value from new_har contains a http status code, and I can see that when I provide the argument I get a 500, which i guess is why I don't have any JSON to be decoded.

If I do not supply any arguments to new_har() I get a valid har file.

From looking at the function definition for new_har() I do not understand why this is happening.

I also see a ton of warnings and error messages in server.log ("illegal reflective access operation","Failed to start Jetty server"), but that happens in both cases, so I am not sure if this is related to my problem.

At the moment I am not sure if I there is a problem with my code or my setup, or if there is a bug in browsermobproxy-py.

I would appreciate any guidance on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant