Reputation: 31
I referred http://code.google.com/chrome/devtools/docs/remote-debugging.html.
First, I started a new chrome process.
chrome --remote-debugging-port=9222 --user-data-dir=remote-profile
Then I want to try some options written in http://code.google.com/intl/ja/chrome/devtools/docs/protocol/tot/index.html, but how can I use them? I already know how to use those methods in WebSocket, but I have to use it in HTTP.
I tried this nodejs code but failed.
var http = require('http');
var options = {
host: 'localhost',
port: 9222,
path: '/devtools/page/0',
method: 'POST'
};
var req = http.request(options, function (res) {
console.log(res.headers);
res.on('data', function (chunk) {
console.log(chunk);
});
});
req.on('error', function (e) { console.log('problem' + e.message); });
req.write(JSON.stringify({
'id': 1,
'method': "Page.enable"
}));
req.end();
Is it wrong?
Upvotes: 3
Views: 5372
Reputation: 46
There is also a fantastic NPM module called Weinre that allows you to easily use the Chrome debugging/ remote debugging tools. If you have to test cross browser too it allows you to use the Chrome tools even on certain versions of IE. There is some more information on the MSDN blog.
Upvotes: 0
Reputation: 54427
I know this is a fairly old question, but I ran into it when I was trying to do something similar.
There's an npm module called chrome-remote-interface
, which makes using the Chrome Remote Debugging API a lot easier: https://github.com/cyrus-and/chrome-remote-interface
npm install chrome-remote-interface
Then you can use the module in your code like this:
var Chrome = require('chrome-remote-interface');
Chrome(function (chrome) {
with (chrome) {
on('Network.requestWillBeSent', function (message) {
console.log(message.request.url);
});
on('Page.loadEventFired', close);
Network.enable();
Page.enable();
Page.navigate({'url': 'https://github.com'});
}
}).on('error', function () {
console.error('Cannot connect to Chrome');
});
Upvotes: 4
Reputation: 1040
I think it says "Note that we are currently working on exposing an HTTP-based protocol that does not require client WebSocket implementation."
I'm not sure it means that you can have HTTP instead of WebSocket now.
Upvotes: 0