Skip to content

Instantly share code, notes, and snippets.

@axemclion
Created October 4, 2014 23:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save axemclion/d41b884cd4fce723647d to your computer and use it in GitHub Desktop.
Save axemclion/d41b884cd4fce723647d to your computer and use it in GitHub Desktop.
Capture Chrome timeline for CSS triggers.com
// Remeber to do npm install wd and run a web server where the pages are hosted.
var wd = require('wd');
var path = require('path');
var browser = wd.promiseRemote();
var caps = {
browserName: 'chrome',
loggingPrefs: {
performance: 'ALL'
}
};
browser.init(caps).then(function() {
return browser.get('http://localhost:8080/align-content-initial.html'); // CHANGE THIS
}).then(function() {
return browser.sleep(1000);
}).then(function() {
return browser.log('performance');
}).then(function() {
return browser.eval('go();');
}).then(function() {
return browser.sleep(1200);
}).then(function() {
return browser.waitForConditionInBrowser('window.isDone===true', 1000, 5000);
}).then(function() {
return browser.log('performance');
}).then(function(logs) {
return logs.map(function(log) {
return JSON.parse(log.message).message.params.record;
});
}).then(parseLogs).fin(function() {
server.close();
browser.close();
}).done();
var props = ['Layout', 'Paint', 'CompositeLayers'];
function parseLogs(logs) {
logs.forEach(function(log) {
console.log(log.type);
if (Array.isArray(log.children)) {
parseLogs(log.children);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment