The Chrome web browser contains a powerful tracer tool, which not only allows tracing and debugging web pages but also allows your own programs to create a specially formatted JSON file and display it as a visual timeline of events in your program, which is extremely useful for debugging performance bottlenecks in a multiprocess/multithreaded system. I am trying to make this tool as accessible and hassle free as possible for users.
Suppose I have created a JSON file in my external program, and now I wish to view it in the tracer. The steps would be:
Open a Chrome window or tab.
Type chrome://tracing in the URL bar.
Click 'Load', browse to my file, and open.
My question is: Can this process be automated from the command line? I have looked it up and found nothing. Perhaps some javascript wizardry is required here.
For background reading:
http://www.gamasutra.com/view/news/176420/Indepth_Using_Chrometracing_to_view_your_inline_profiling_data.php
https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview#
If you want an example input file for the tracer, copy the following text and name it mytimeline.json. Follow the steps above to view it.
[ {"cat":"1", "pid":1000,"tid":1001,"ts":100000,"ph":"B","name":"UpdateLayoutTree","args":{"timestamp-s":"jun 2 12:12:12","frame":10034} }
, {"cat":"1", "pid":1000,"tid":1001,"ts":102000,"ph":"B","name":"subfunc","args":{"timestamp-e":"jun 2 12:12:13", "elementCount":4} }
, {"cat":"1", "pid":1000,"tid":1001,"ts":108000,"ph":"E","args":{"timestamp-e":"jun 2 12:12:13"} }
, {"cat":"1", "pid":1000,"tid":1001,"ts":110000,"ph":"E","args":{"timestamp-e":"jun 2 12:12:13"} }
, {"cat":"1", "pid":1000,"tid":1002,"ts":120000,"dur":15000,"ph":"X","name":"Something","args":{"elementCount":4} }
, {"cat":"2", "pid":1003,"tid":1004,"ts":125000,"ph":"i","name":"Boom","args":{"elementCount":4}, "s": "t" }
]
Related
I'm trying out to build my first firefox addon, to solve a problem that I have at work :
I'm trying to automate a part of my daily work on a website I'm using (not developping). I have to crawl several lists on the website, dig an item in the list, to check some values, and do it again and again ...
Im used to developping in Powershell and python, not with a web browser. I have limited rights on the machine I'm working on. The only solution I can easily deploy is a firefox addon on a firefox portable. I'd like to use this to catch the json answers of the website (all of them), parse the answers for some values, and automate some kind of popup "Hey, This item in the list is between 90 and 100 !"
The network console allows me to see the jsons, and I know how to parse it well (I'm actually using a powershell script for this, but I can't connect it to the network console AFAIK)
I found a way to trigger the work at the right time :
function logJson(requestDetails) {
console.log("Chargement : " + requestDetails.url);
}
browser.webRequest.onCompleted.addListener(
logRequests,
{urls: ["*://*.crappywebsi.te/*"],
types: ["xmlhttprequest"]
}
);
This code logs the url at the right moment (every time a json is loaded)
Is it possible to catch the json on the fly, to parse it, look for specific values in a path, calculate something, and popup the result ?
Or just save the json somewhere ?
How ?
I dont want to add a button on the webpage. I want a signal that some values are right. a popup or console log is an good solution for me.
Thanks for your help !
I am utilizing an extension called Azure Event Hub Explorer in Visual Studio Code. The extension allows me to see messages from an Azure Event Hub within the VS Code Output.
There are a lot of messages and you have to scroll through them to find what you want. There is no way to filter the results. I am looking for a way to export the output into something like a csv file so that I can easily filter my results.
Please let me know if there is a way.
Click on "Open log file" button on right upper corner of output window. Also you can canfigure key bindings for commands:
Whenever I open chrome, I want:
All my previous pages are there
Another page, with a custom URL, is there. (With the possibility of me setting it to be chrome://newtab.)
Is this possible?
Is there a way that on open specific set of pages, I can add previous pages?
I have tried looking. The closest thing I could find was this. This is not exactly what I wanted.
I would like a simple and easy way of doing this. (I don't mind extensions but I couldn't find any.)
I want this to be done without any input from me every time. So no CtrlShiftT please.
Thank you in advance.
If you need to automate Chrome GUI, it's possible using pywinauto. My student wrote an example dragging file from explorer.exe to Google Disk opened in Chrome. There are some tricks used here.
test_explorer_google_drive.py
Chrome requires command line parameter --force-renderer-accessibility to enable MS UI Automation support in Chrome. So if you're starting Chrome it should work for you. If you're trying to connect to existing Chrome window this might be a problem.
Need to use backend='uia' explicitly for pywinauto.Application object. See the Getting Started Guide for more details, core concept and other useful things.
The relevant part of the mentioned script:
from pywinauto import Application
chrome_dir = r'"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"'
# start Chrome
chrome = Application(backend='uia')
chrome.start(chrome_dir + ' --force-renderer-accessibility --incognito --start-maximized <URL>')
# wait while page is loading (up to 10 sec.)
chrome['<Tab caption>'].child_window(title_re='Reload.*', control_type='Button').wait('visible', timeout=10)
the details of this may depend on your operating system but on windows I can access a "master_preferences" file in C: > Program Files > Google > Chrome > application.
the contents of the file looks like:
{
"homepage": "http://www.google.com/",
"homepage_is_newtabpage": false,
"distribution": {
"suppress_first_run_bubble": false,
"import_search_engine": false,
"import_history": false,
"do_not_launch_chrome": true,
"make_chrome_default": false,
"verbose_logging": false,
"ping_delay": -60
},
"sync_promo": {
"show_on_first_run_allowed": false
},
"session": {
"restore_on_startup": 4,
"startup_urls": ["http://www.google.com/"]
},
"first_run_tabs": ["http://www.google.com/", "http://welcome_page"]
}
You can see there are settings for restore_on_startup
and startup_urls under the "session" heading
try editing those settings so the look like this:
"restore_on_startup": 2,
"startup_urls": ["http://www.google.com/", "http://www.theurlyouwant.com"]
You may not be able to configure these settings on your work or school computer as it requires administrator privileges. And also if you're not familiar with JSON pay especial close attention to the syntax (commas, quotation marks etc) I've used in my examples.
I don't know if this will help, it's certainly not as technical a response as everyone else, but I use the OneTab Chrome extension to do some of the stuff you're talking about.
I have a handful of pages saved to it, and I click the Restore All button and they all load in. You can save groups of tabs, and lock those groups so they're not easily deleted on accident, and name groups of saved tabs as well. I think it's pretty helpful, but it might not be exactly what you need/are looking for. Hope it helps though!
I'm running Windows 8. I have a file named "test.tcl".
If I open a shell, type "wish", then 2 windows open. In one of them, I can type Tcl code and open the file test.tcl. If I open this file, its code is executed.
If I double click on test.tcl to open the file with "Wish Application", then 1 blank window open, and nothing happens.
Do you know why please?
On Windows, Wish is built as a GUI-only application; it has no real standard output available. Tk fakes one for you though; just put this in your script to show the fake console:
console show
The fake console shows up by default when you launch without a script file, but launching with a script file doesn't show it (so your script file can implement an application, of course).
This can catch people out when they produce a lot of output on stdout. Tk may well be keeping it all faithfully just in case the code does console show later on, though it looks and smells a lot like a memory leak if you're not prepared for it…
So I started using FlexPMD for static code analysis, and I want to add it to my team's build process. I have it running nicely from a shell script, and can view the results by clicking a button and uploading the desired (pmd.xml) output file in the Violations Viewer that comes with it (note there is also one online here: http://opensource.adobe.com/svn/opensource/flexpmd/bin/flex-pmd-violations-viewer.html).
But I'd like to view the results directly without having to take the extra step of clicking the upload button. I imagine there is some black magic URL parameter that works, but (if so) what is it? This site:
http://blogs.adobe.com/xagnetti/2009/09/load_pmd_results_directly_in_t.html
mentions referencing pmd.xml with a "report" URL param, like so:
http://opensource.adobe.com/svn/opensource/flexpmd/bin/flex-pmd-violations-viewer.html?report=path/to/my/pmd.xml
but it's not working for me. Has anyone encountered this problem and triumphed, by chance?
EDIT: More info...
The latter (opensource.adobe.com...) webpage has the following JavaScript:
function getReport()
{
if ( window.location.href.indexOf('=') == -1 )
{
return "";
}
var hashes = window.location.href.slice(window.location.href.indexOf('=') + 1);
return hashes;
}
var report = getReport();
which it passes into flashvars. Perhaps the format with which I'm passing pmd.xml is incorrect?
Okay, figured it out. The version of the violations viewer that ships with the open source FlexPMD does not allow for automatic viewing of reports (the HTML wrapper doesn't pass in the report filepath, and the SWF doesn't take it in). The solution that worked for me was to download the files from the online violations viewer here:
http://opensource.adobe.com/svn/opensource/flexpmd/bin/flex-pmd-violations-viewer.html?report=path/to/my/pmd.xml
by using your browser to just save the webpage, and then curl to save the SWF file (directly trying to save from the browser will not work - appears to redirect to a null address) to like so:
curl -O http://opensource.adobe.com/svn/opensource/flexpmd/bin/flex-pmd-violations-viewer-1.1.swf
and place in the same directory as the violations viewer html file you downloaded. Then you can read your reports automatically! Here is an example (absolute filepath on Mac):
file:///path/to/your/violations-viewer/ViolationsViewer.html?report=/Users/joverton/some/project/path/bin-debug/pmd_reports/pmd.xml