Debugging JSON using Chrome's Dev Tools - json

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)

Related

Chrome: JSON (or other object) into chrome_debug.log

when I use chrome.exe with --enable-logging parameter it enables chrome to log console messages into debug file.
Sadly it missing the object details:
Example:
[1208:1164:1028/12048.086:INFO:CONSOLE(1)] "%c[WS Message] something color: #7c7c7c", source:something.js (1)
The (1) Stands for the JSON object inside I want to explore in real time in Python. Anyone have idea how to make chrome to save object as string for example in chrome_debug.log?? (Extension or some console command?)
Or any other solution that would enable to view the object in realtime in python?
(Yes i know you can right click on in actual chrome console by mouse then use "copy object", So yes, technicaly, i can make a macro which would do it in real time, but that woud be completely crazy.
I solved this by making Chome extension in Java, that copy-paste JSON objects from dev console. Little bit workaround, but better working that Selenium.

Cordova File Download and open it using cordova

Please forgive my ignorance, Any advice/directional assistance would be greatly appreciated.
I have a small app that reads data from an API with json requests.
One of the actions the app needs to do is to download a given PDF and open it either in the app, or in the OS default viewer.
I have followed several guides, but I think I am not including all needed files or something. The guides don't speak of including files of any type, but I still get errors.
In this link for example I followed the steps, but I am getting an error when I add these two lines in to the script at the bottom of the page:
var fileTransfer = new FileTransfer();
console.log(FileTransfer);
When running that I get the error Uncaught ReferenceError: FileTransfer is not defined at employee_documents.html:102
I am sure that either i am not including the files correctly in netbeans or I am missing something simple...
Any advise would be greatly appreciated.
To answer the question specifically. In order to solve the error, you need to run the cordova app using the CLI. In that way, the plugins installed from your cordova will be used otherwise if you're only running it via refresh or something similar it will produce an error like this.
In other words, type this command in your CLI:
cordova run browser
You can change this to your preferred platform (android, ios)

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.

Automate Chrome console from Desktop app?

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")'})