Automate Chrome console from Desktop app? - google-chrome

I'd like to be able to send info to the Chrome developer console from my application.
For example, my app has some json. I'd like this json to show up in either an existing, or newly created instance of the chrome dev tools console.
Is this possible? If so, any pointers to examples? Note that the platform should be any language, not just javascript. And definitely not a site already running in Chrome. I'm interested in implementing this in another process.

Do you thought of running your app in an environment which is pretty much like a browser?
Node.js
or (this is a whole webkit browser)
phantom.js
Otherwise you could call Chrome directly via commandline and try to simulate the dev tools key stroke like explained here:
Is there a command line argument in Chrome to start the developer tools on startup?
The command of displaying something in the Chrome console is e.g. console.log and it is at the end Javascript. All Console commands are described here:
https://developers.google.com/chrome-developer-tools/docs/console-api

The closest I've seen so far is this library:
https://github.com/ccampbell/chromelogger
which seems to allow logging to the Chrome Console from lots of other server side apis, but no desktop APIs.

This can be done on Mac using osascript. Save the following as a script and run it:
#!/usr/bin/osascript -l JavaScript
var chrome = Application('Google Chrome');
//chrome.activate();
chrome.includeStandardAdditions = true;
var currentTab = chrome.windows[0].activeTab()
currentTab.execute({javascript: 'console.log("Hello")'})

Related

How do I tell figwheel to start and connect to Google Chrome instead of Firefox?

I'm taking some baby steps with figwheel.
When I fire up the tutorial application, it starts firefox, which then connects back to the figwheel process to get code to run on its JavaScript engine. If firefox is already running, a new tab is opened and the connection proceeds likewise. Figwheel probably just executes the firefox command with appropriate options. Or maybe it is using xdg-open.
The system is a Fedora Linux with KDE. Interestingly a "default browser" is not currently configured (how to configure the default browser is described in these KDE help pages): the application to start is selected based on URL contents. So I am not sure why figwheel selects firefox instead of Google Chrome, also installed.
Now, for testing purposes I sometimes want figwheeel to use a Google Chrome process instead. Is there a way to do that?
There seems to be no option regarding this.
You can use figwheel's :launch-js option to define what action should be taken for example:
:launch-js ["chrome" "--repl" :open-url]

Can i debug html page on run-time execution?

I am working on HTML page and using angular js.
I Want to see how many records my database collection has in run-time.
Is there any way to trace it, like we debug Java class.
You can set break point by using Chrome dev tool.
Open Chrome Dev Tool (Press F12)
Click Sources Tab
Select your JS file from left panel
Click on the line no to set the breakpoint
No..I think it's not available like u want to see data.
But u can do debug through the browser by inspecting elements.and My suggestion is to write business logic in ur language (C#,java....)and make service.And consume from client side.There u can debug easily.
In client side usually, we get an error in syntax or library compatibility.
You can debug all your JavaScript code using developer tools in Chrome for example and its debug functionality.
IDE like VSCode has also a built-in functionality for debugging JavaScript code directly from the IDE for example.
Then if your question is to see live your database from the browser. Nope, you cannot do that. There is nothing related between a front-end application and the connected database directly from the browser.
Then maybe there are few chrome extensions which could allow you to connect to your db and see real time it. But this is not a built-in feature.

pywinauto: accessing chrome gui

I am trying to select a printer and print on chrome browser, using pywinauto, but I am not able to access the gui components. I can see the components in Microsoft Inspect.exe in UIAutomation mode. (See screenshot).
I have started chrome with --force-renderer-accessibility flag.
I tried several things but I am not able to access anything in the chrome window. Is it possible to access the chrome gui components using pywinauto?
screenshot: ]1
Probably you use default backend="win32" which is used when you call Application(). To use MS UI Automation you have to set backend="uia" when instantiating Application object:
app = Application(backend='uia').start('chrome.exe <other params>')
My student wrote example script dragging file from explorer.exe to Google Drive in Chrome. Is it working for you?
P.S. If you already use backend='uia', please provide more detailed description with some code and output.

Selenium IDE doesn't open webpages that return a json response

I have a big Selenium test suite that's testing a web service. Given an input url, the web service returns either a regular html response or a json response. The test suite is being executed with Firefox's Selenium IDE. The tests call the open command on a given url and then verify stuff on the returned json/html. It used to work great until for some reason Firefox has stopped opening the jsons automatically. Instead of opening the json response as if it were a regular web page, Firefox asks "What should Firefox do with this file" and prompts me to select a program to open the file with.
How do I force Selenium IDE to make Firefox display the json responses as it used to?
Cases like these are usually Firefox & Selenium IDE version incompatibility. This can be from using a much newer version or an old version of Firefox that the IDE doesn't quite support.
In your case it appears to be an older version issue.
The first step you should do is update both the IDE & Firefox and take it from there.
The release notes also detail what version (range) of Firefox it generally supports.

Debugging JSON using Chrome's Dev Tools

How do I access the results array from the following page using Google Chrome's console?
twitter.com/search.json?q=stackexchange
I keep getting this error:
ReferenceError: results is not defined
If what you really want is to browse this result set in a convinient way, just install one of JSON viewers for Chrome (preferably JSONView).
If you don't want to install any plugins, just run this:
JSON.parse($('.webkit-line-content').innerHTML);
in the console on page:
view-source:https://search.twitter.com/search.json?q=stackexchange
You can use console.debug() function in chrome console tab.
example:
console.debug(results)