iiSeymour / chromote

Simple wrapper to drive Google Chrome from Python
MIT License
317 stars 34 forks source link

cannot use chrome.tabs #10

Open MattMcFarland opened 7 years ago

MattMcFarland commented 7 years ago

Hey, thanks for making this repo. I tried to run but I'm running into an issue:

>>> from chromote import Chromote
>>> chrome = Chromote()
>>> chrome
Chromote(host="localhost", port=9222)
>>> print chrome

According to readme, I should see the following:

[Chromote(tabs=1)]

But instead, I see this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/chromote/__init__.py", line 156, in __str__
    return '[Chromote(tabs=%d)]' % len(self)
  File "/usr/local/lib/python3.6/site-packages/chromote/__init__.py", line 153, in __len__
    return len(self.tabs)
  File "/usr/local/lib/python3.6/site-packages/chromote/__init__.py", line 150, in tabs
    return tuple(self._get_tabs())
  File "/usr/local/lib/python3.6/site-packages/chromote/__init__.py", line 132, in _get_tabs
    for tab in res.json():
  File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 886, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Tried this in python 2.7 and got the same result as well.

Any ideas????

Thanks!

iiSeymour commented 7 years ago

Hey, do you have the developer tools open in chrome at the same time as running chromote?

MattMcFarland commented 7 years ago

Hi, no not at all, in fact I was using this to connect to headless chrome. Is that the problem?