Giter Site home page Giter Site logo

Comments (6)

brupelo avatar brupelo commented on June 27, 2024

Actually, i think you can reproduce it if you open chrome dev tools in the browser (ctrl+shift+j).

from chromote.

iiSeymour avatar iiSeymour commented on June 27, 2024

I can reproduce this when multiple clients are attached (which isn't supported by the protocol). Are you using Chromote and the browser at the same time?

from chromote.

brupelo avatar brupelo commented on June 27, 2024

The simplest way to reproduce the issue is this:

  1. Close all opened browsers and start a single chrome browser with the remote-debugging-port parameter:

chrome.exe -remote-debugging-port=9222

  1. In that browser, open chrome dev tools (ctrl+shift+j)

  2. Run the next code:

from chromote import Chromote

chrome = Chromote()
tab = chrome.tabs[0]

At this point the exception should appear

yield ChromeTab(tab['title'], tab['url'], tab['webSocketDebuggerUrl'])

If you close the chrome dev tools and run again the snippet the exception won't be launched.

Btw, cool project of yours!

from chromote.

brupelo avatar brupelo commented on June 27, 2024

It's not real solution but locally I've patched _get_tabs:

   def _get_tabs(self):
        """
        Get all open browser tabs that are pages tabs
        """
        res = requests.get(self.url + '/json')
        for tab in res.json():
            if ('webSocketDebuggerUrl' in tab.keys()):
                if tab['type'] == 'page':
                    yield ChromeTab(tab['title'], tab['url'], tab['webSocketDebuggerUrl'])

So i can use chromote having multiple browsers where many tabs will be using the ChromeDevTools... I won't get them back of course but at least Chromote won't crash.

from chromote.

iiSeymour avatar iiSeymour commented on June 27, 2024

Great, why not send a PR. My preference would be to drop the parens and explicate call to keys:

if 'webSocketDebuggerUrl' in tab:

from chromote.

brupelo avatar brupelo commented on June 27, 2024

Nah, your choice, it's your baby ;-)

For my use-case i've tweaked my local copy like this:

    def _get_tabs(self):
        res = requests.get(self.url + '/json')
        for tab in res.json():
            if tab['type'] == 'page':
                if ('webSocketDebuggerUrl' not in tab.keys()):
                    yield ChromeTab(tab['title'], tab['url'], None)
                else:
                    yield ChromeTab(tab['title'], tab['url'], tab['webSocketDebuggerUrl'])

and adding one method to check "valid" tabs:

    def is_valid(self):
        return self._websocket_url is not None

That way i have all available tabs from my browsers, if i want to reload one tab i just check first if is valid or not, it works wonderfully... That way i can run my scripts while other tabs have opened the chrome-dev-tools, workflow is fast.

from chromote.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.