PhantomJS 1.x does not support WebSockets 1 so you cannot control them. If a page uses some backups for WebSockets, it page.onResourceRequestedand page.onResourceReceivedcan be used for registration of metadata messages. PhantomJS does not disclose factual data sent in any way.
WebSockets PhantomJS 2. , . . - WebSocket :
page.onInitialized = function(){
page.evaluate(function(){
(function(w){
var oldWS = w.WebSocket;
w.WebSocket = function(uri){
this.ws = new oldWS(uri);
...
};
w.WebSocket.prototype.send = function(msg){
w.callPhantom({type: "ws", sent: "msg"});
this.ws.send(msg);
};
...
})(window);
});
};
page.onCallback = function(data){
console.log(JSON.stringify(data, undefined, 4));
};
1 , - - v1.9.6 , v1.9.0.