browserup / browserup-proxy

BrowserUp Proxy is a free utility to watch, test, and manipulate web application network traffic and performance.
https://browserup.com
Apache License 2.0
164 stars 41 forks source link

No HAR information seems to be generated. #335

Closed alex4200 closed 3 years ago

alex4200 commented 3 years ago

Describe the bug

I followed the instructions given HERE in order to use this tool for python.

But when I try to use it I get a Warning

tester.py:19: DeprecationWarning: This method has been deprecated. Please pass in the proxy object to the Driver Object
  profile.set_proxy(proxy.selenium_proxy())

and an error:

Traceback (most recent call last):
  File "tester.py", line 33, in <module>
    print(proxy.har)
  File "/Users/adietz/Envs/mac_1.19_salpeter/lib/python3.8/site-packages/browserupproxy/client.py", line 104, in har
    return r.json()
  File "/Users/adietz/Envs/mac_1.19_salpeter/lib/python3.8/site-packages/requests/models.py", line 900, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/Cellar/python@3.8/3.8.6/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/local/Cellar/python@3.8/3.8.6/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/Cellar/python@3.8/3.8.6/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

To Reproduce

Steps to reproduce the behavior:

  1. pip install git+https://github.com/browserup/browserup-proxy-py.git@master#egg=browserup-proxy==0.1.0
  2. Executed the followingcommand:
#!/usr/bin/env bash

if [ "$(uname)" == "Darwin" ]; then
    echo "We're on a MAC!"
   chromeDriver="chromedriver_mac64.zip"
   geckoDriverVersion="v0.24.0"
   geckoDriver="geckodriver-$geckoDriverVersion-macos.tar.gz"
else
    echo "We're not on a MAC!"
   chromeDriver="chromedriver_linux64.zip"
   geckoDriverVersion="v0.24.0"
   geckoDriver="geckodriver-$geckoDriverVersion-linux64.tar.gz"
fi
rm -rf tools
mkdir -p tools && \
cd tools && \
wget https://github.com/browserup/browserup-proxy/releases/download/v1.1.0/browserup-proxy-1.1.0.zip && \
unzip -o browserup-proxy-1.1.0.zip && \
rm -rf browserup-proxy*.zip* && \
wget https://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar && \
wget https://github.com/mozilla/geckodriver/releases/download/${geckoDriverVersion}/${geckoDriver} && \
tar zxf ${geckoDriver} && \
rm -rf ${geckoDriver}* && \
wget https://chromedriver.storage.googleapis.com/74.0.3729.6/${chromeDriver} && \
unzip ${chromeDriver} && \
rm -rf ${chromeDriver}* && \
cd ..
  1. Added the path for tools to PATH.

  2. Run the following code:

from browserupproxy import Server
server = Server("tools/browserup-proxy-1.1.0/bin/browserup-proxy")
server.start()
proxy = server.create_proxy()

from selenium import webdriver
profile  = webdriver.FirefoxProfile()
profile.set_proxy(proxy.selenium_proxy())
driver = webdriver.Firefox(firefox_profile=profile)

proxy.new_har("google")
driver.get("http://www.google.co.uk")

server.stop()
driver.quit()

print("--- propxy.har output: ---")
print(proxy.har)

Expected behavior

A HAR file.

Please complete the following information:

ericbeland commented 3 years ago

Unfortunately, we don't control that client library. We have an upcoming version where were will be generating our API clients (including Python) with swagger. That should hopefully provide a way to get around this.

alex4200 commented 3 years ago

@ericbeland So it means the package (browserup/browserup-proxy) is currently broken and cannot be used at all? Is that correct?