使自动化HAR文件代从谷歌浏览器 [英] Automatize HAR files generation from Google Chrome

查看:3492
本文介绍了使自动化HAR文件代从谷歌浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我需要的是使自动化的的结果的方法的下列操作:

Basically what I need is a way to automatize the result of the following operations:


  1. 打开一个新标签;

  1. open a new tab;

打开开发工具网络选项卡;

open the Network tab in the developer tools;

加载一个URL;

选择保存所有为HAR。

select "Save All as HAR".

通常情况下,提出的解决方案包括使用 PhantomJS ,的 browsermob代理 pcap2har ;因为我需要 SPDY 交通工作的那些不适合我的情况。

Often, proposed solutions involves the use of PhantomJS, browsermob-proxy, or pcap2har; those won't fit my case since I need to work with SPDY traffic.

我试图潜入谷歌Chrome扩展API 而事实上我设法使自动化某些任务,但仍没有运气什么涉及HAR文件生成。现在这种方法是特别有希望的,但我还是想不通怎么会我用它。

I tried to dive into the Google Chrome Extensions API and indeed I managed to automatize some tasks, but still no luck for what concerns the HAR files generation. Now this method is particularly promising but I still can't figure out how would I use it.

在换句话说,我需要像从的的谷歌家伙这个实验 的。请注意以下几点:

In other words, I need something like this experiment from the Google guys. Note the following:

我们使用Chrome的远程调试接口与启动浏览器中的自定义客户端在手机上,清除缓存等国家,将启动一个网页加载,并接收Chrome开发者工具的消息,以确定页面加载时间和其他性能指标。

We used Chrome's remote debugging interface with a custom client that starts up the browser on the phone, clears its cache and other state, initiates a web page load, and receives the Chrome developer tools messages to determine the page load times and other performance metrics.

任何想法?

有关的好奇,我结束了一个Node.js的模块,自动此类测试:铬作答-capturer 。这也给了我机会,深入了解了远程调试协议并写了一个较低Node.js的级别接口,用于通用型镀铬自动化:铬远程接口

For the curious, I ended up with a Node.js module that automates such kind of tests: chrome-har-capturer. This also gave me the opportunity to dig deeper into the Remote Debugging Protocol and to write a lower-level Node.js interface for general-purpose Chrome automation: chrome-remote-interface.

推荐答案

简单的回答是,有没有办法让你直接后的数据。在 getHAR 方法只适用于扩展意味着延长DevTools本身。好消息是,你可以构造HAR文件中自己没有太多的麻烦 - 这正是什么幻象.js文件不的。

The short answer is, there is no way to get at the data you are after directly. The getHAR method is only applicable to extensions meant to extend DevTools itself. The good news is, you can construct the HAR file yourself without too much trouble - this is exactly what phantom.js does.


  1. Chrome启动远程调试

  2. 连接到Chrome浏览器与WebSocket连接调试端口

  3. 启用网络的调试,还可以清除缓存,等等 - 见网络API

  4. 告诉浏览器导航到你想要捕捉的页面,Chrome将传输所有请求的元数据还给你。

  5. 按摩网络数据转换成HAR格式,ALA phantom.js

  6. ...

  7. 利润。

有关一个良好的开端,我有一个帖子说样品红宝石code应该您开始使用步骤1-4:<一href=\"http://www.igvita.com/2012/04/09/driving-google-chrome-via-websocket-api/\">http://www.igvita.com/2012/04/09/driving-google-chrome-via-websocket-api/

For a head start, I have a post that with sample Ruby code that should you get started with steps 1-4: http://www.igvita.com/2012/04/09/driving-google-chrome-via-websocket-api/

这篇关于使自动化HAR文件代从谷歌浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆