基本上我需要的是一种自动化以下操作结果的方法:
通常,建议的解决方案涉及使用 PhantomJS , browsermob-proxy , 或 pcap2har ;这些不适合我的情况,因为我需要使用 SPDY交通。
我试图潜入Google Chrome Extensions API事实上,我设法自动化了一些任务,但对于 HAR 文件生成方面的问题仍然没有运气。现在this method特别有希望,但我仍然无法弄清楚我将如何使用它。
换句话说,我需要像 this experiment 这样的东西来自谷歌的家伙。请注意以下事项:
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 模块:chrome-har-capturer .这也让我有机会深入研究 Remote Debugging Protocol并为通用 Chrome 自动化编写一个较低级别的 Node.js 接口(interface):chrome-remote-interface .
最佳答案
简短的回答是,没有办法直接获取您所追求的数据。 getHAR
方法仅适用于旨在扩展 DevTools 本身的扩展。好消息是,您可以自己构建 HAR 文件而不会太麻烦 - 这正是 what phantom.js does .
为了抢先一步,我有一篇文章,其中包含示例 Ruby 代码,您应该从步骤 1-4 开始:http://www.igvita.com/2012/04/09/driving-google-chrome-via-websocket-api/
关于google-chrome - 从 Google Chrome 自动生成 HAR 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13537533/