pychrome
pychrome copied to clipboard
Something broken with newest chrome with tabs managment
Running example multi_tabs_navigate.py gives error:
Traceback (most recent call last):
File "./2.py", line 97, in <module>
main()
File "./2.py", line 70, in main
close_all_tabs(browser)
File "./2.py", line 64, in close_all_tabs
assert len(browser.list_tab()) == 0
AssertionError
If i comment assert statement I get antother error:
Traceback (most recent call last):
File "./2.py", line 97, in <module>
main()
File "./2.py", line 74, in main
tabs.append(browser.new_tab())
File "/usr/local/lib/python2.7/dist-packages/pychrome/browser.py", line 28, in new_tab
tab = Tab(**rp.json())
File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 892, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python2.7/dist-packages/simplejson/__init__.py", line 518, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Last one just after calling new_tab()
Were you ever able to figure out how to fix this?
I had the same issue when I was trying to use headless chrome in docker (image: https://hub.docker.com/r/chromedp/headless-shell). I was referring to the chrome debug endpoint with hostname (docker service name). When I used the IP address instead of the hostname, the issue was solved.