firefox native extension -- har export trigger

这两天想学习下如何在运行自动化脚本时去capture http traffic,google看到一篇博客介绍用browser mob proxy或者firefox+firebug+netexport,后来去netexport的github官网发现已经不维护了,你可以去到http://getfirebug.com/releases/netexport/ 下载最新版的netexport,但是安装的时候会提示你unverified add-ons,无法安装,参考http://winaero.com/blog/enable-unsigned-add-ons-disabled-by-firefox-43/,据说可以解决这个问题。但是在我的mac firefox53版本上并没有解决, 查看这篇博客 https://support.mozilla.org/en-US/questions/1101877 得知firefox 44以后就不能按照之前链接上说的做啦,需要sign in add-on in firefox https://support.mozilla.org/en-US/kb/add-on-signing-in-firefox,放弃,太繁琐了,这本来就是人气不维护的库了,而且以后firebug没人维护,迟早都会出问题。

http://www.softwareishard.com/blog/har-export-trigger/ 这是它的替代品har export trigger,  firefox 开发工具源生的插件,功能与net export一样,作者都是同一个。

尝试了下coding,

require 'selenium-webdriver'

profile = Selenium::WebDriver::Firefox::Profile.new
profile.add_extension '/Users/Tim/Library/Application Support/Firefox/Profiles/09kanu7u.watir/extensions/harexporttrigger@getfirebug.com.xpi'
profile["extensions.netmonitor.har.enableAutomation"] = true
profile["extensions.netmonitor.har.contentAPIToken"] = 'test'
profile["extensions.netmonitor.har.autoConnect"] = true
profile['devtools.netmonitor.har.enableAutoExportToFile'] = true
options = Selenium::WebDriver::Firefox::Options.new
options.profile = profile

b = Selenium::WebDriver.for :firefox, options: options
b.navigate.to "http://janodvarko.cz/har/tests/har-export-trigger/har-export-api.html"

b.close if b

 

发现在浏览器的profile目录下的/har/log并没有生成har文件,google后发现使用者忽略不计,然后还碰巧遇到一个童鞋遇到一样的问题,发现在selenium3.0上不支持,我猜测是因为firefox48 以上以后用的geckodriver,这个driver没记错的话是16年出来的,

而这2个firefox的插件都是15年就出来了,而且发现har export trigger也已经2年没更新维护了,估计不行,如果执着的童鞋可以降selenium版本到2.xx版本,firefox版本小于48试试

 

posted on 2017-07-20 10:47  tim_sheng  阅读(496)  评论(0编辑  收藏  举报

导航