How can I open the Google Chrome Console from Java

2019-01-19 10:17发布

问题:

This question already has an answer here:

  • Can I programmatically open the devtools from a Google Chrome extension? 3 answers

The question might sound weird but I kind of need this to happen. The alternative would be to ask people to press Ctrl+Shift+i but I would prefer to avoid that and just provide a link.

The link would show up in a Chrome Extension so I'm only interested for Google Chrome.

回答1:

Sorry, not likely to happen (except as a security hole). Your in-page JavaScript is deliberately sandboxed and limited - it can interact with the page, and with the network through AJAX, but it cannot and should not interact with other things that happen in your computer - including the browser.



回答2:

It is not clear why you need to provide such link. DevTools is not a tool for the end user. If you don't like keyboard shortcuts, then there is a page chrome://inspect/ which has the list of pages and extensions, and each entry has a link that opens devtools.

Also, you may use remote debugging page which opens devtools in a page. https://developers.google.com/chrome-developer-tools/docs/remote-debugging



回答3:

Have you tried Firebug Lite. It is an in-browser tool similar to that found in Chrome.

http://getfirebug.com/firebuglite

It will give you most of the capabilities you are looking for (most likely), and will allow you to programmatically enable it and destroy it.

What do you think?