2013-09-24 38 views
0

我試圖讓工作與你的寶石,並在Windows 7中,我做了以下內容:browsermob代理得到.har文件權限被拒絕

gem install browsermob-proxy 

所有成功 走到後來我嘗試推出代碼:

require 'selenium/webdriver' 
require 'browsermob/proxy' 

server = BrowserMob::Proxy::Server.new('C:/Ruby193/lib/ruby/gems/1.9.1/gems/browsermob-proxy-0.1.3/lib/browsermob-proxy.rb') #=> #<BrowserMob::Proxy::Server:0x000001022c6ea8 ...> 
server.start 

proxy = server.create_proxy #=> #<BrowserMob::Proxy::Client:0x0000010224bdc0 ...> 

profile = Selenium::WebDriver::Firefox::Profile.new #=> #<Selenium::WebDriver::Firefox::Profile:0x000001022bf748 ...> 
profile.proxy = proxy.selenium_proxy 

driver = Selenium::WebDriver.for :firefox, :profile => profile 

proxy.new_har "google" 
driver.get "http://google.com" 

har = proxy.har #=> #<HAR::Archive:0x-27066c42d7e75fa6> 
har.entries.first.request.url #=> "http://google.com" 
har.save_to "/tmp/google.har" 

proxy.close 
driver.quit 

,並得到錯誤:

C:/Ruby193/lib/ruby/gems/1.9.1/gems/browsermob-proxy-0.1.3/lib/browsermob/proxy/server.rb:16:in ´initialize' : Permission denied - not executable: C:/Ruby193/lib/ruby/gems/1.9.1/gems/browsermob-proxy-0.1.3/lib/browsermob-proxy.rb (Errno::EACCES) 
from gethar.rb:in 'new' 
from gethar.rb:in '<main>' 

我認爲有Windows無權限像在Linux? 所以任何幫助請

回答

1

錯誤信息是誤導。這不是權限問題;您需要指向與寶石分離的browsermob bat文件。

您可以在這裏下載:http://bmp.lightbody.net/

然後指向該文件的位置,我的是這樣的:

server = BrowserMob::Proxy::Server.new('C:/browsermob-proxy/bin/browsermob-proxy.bat') 

這應該解決您的問題。