Ruby watir webdriver browsermob/proxy har文件几乎为空

Ruby watir webdriver browsermob/proxy har文件几乎为空,ruby,watir-webdriver,browsermob-proxy,Ruby,Watir Webdriver,Browsermob Proxy,您好,我想在重定向发生时捕获所有重定向。 假设它先转到example.com,然后重定向到example1.com,然后再转到example3.com 我使用的是watir webdriver和browsermob/proxy。 我尝试了google.com,但没有重定向,但是har文件应该比我得到的多得多 hier是代码: server = BrowserMob::Proxy::Server.new("/home/da/Downloads/browsermob-proxy-2.0.0/bin/

您好,我想在重定向发生时捕获所有重定向。 假设它先转到example.com,然后重定向到example1.com,然后再转到example3.com

我使用的是watir webdriver和browsermob/proxy。 我尝试了google.com,但没有重定向,但是har文件应该比我得到的多得多

hier是代码:

server = BrowserMob::Proxy::Server.new("/home/da/Downloads/browsermob-proxy-2.0.0/bin/browsermob-proxy") #=> #<BrowserMob::Proxy::Server:0x000001022c6ea8 ...>
        server.start
  @@proxy = server.create_proxy(9090)
        puts @@proxy.inspect
  profile = Selenium::WebDriver::Firefox::Profile.new
        puts "going on #{dv}"
  profile['general.useragent.override'] = dv['useragent']
        #'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:27.0) Gecko/20100101 Firefox/27.0'#device['useragent']
  puts dv['useragent']
  profile.proxy = Selenium::WebDriver::Proxy.new :http => 'localhost:9090', :ssl => 'localhost:9090'#9091
  time = Time.now.to_i #Time.now.getutc
  puts APP_ROOT
  @@proxy.new_har time
  @@b = Watir::Browser.new :firefox, :profile => profile
        @@har = @@proxy.har #=> #<HAR::Archive:0x-27066c42d7e75fa6>
        #har.entries.first.request.url
        #har.entries.first.request.url #=> "http://google.com"
        @@b.goto "google.com"
        puts @@har.inspect
        @@har.save_to "#{APP_ROOT}/har/google.har"
        exit
我尝试过像上面提到的example1.com到Example2.com这样的重定向,但是har文件并没有给出太多:(

以下是我进行的一些测试:

好的,下面是一些测试结果: Firefox492.0.0根本不起作用 Firefox492.1.2根本不起作用 Firefox482.1.2根本不工作

Firefox472.1.2可以工作,但har很小 firefox 47 2.0.0的工作文件更大 Firefox472.1.0的工作原理是中等规模 Firefox472.1.1运行正常,是最大的

然后我也用Firefox46进行了测试,得到了相同的结果


我记得几年前,我也得到了同样代码的重定向,现在可以得到了:(

您是否尝试过通过Browsermob创建WebDriver::Proxy

e、 g

另外,BrowsermobProxy本身通常在9090上运行,因此当您尝试在9090上创建代理时,我预计会出现端口冲突。如果您使用上述代码,则无需指定端口

e、 g

{"log":{"version":"1.2","creator":{"name":"BrowserMob Proxy","version":"2.0","comment":""},"browser":{"name":"IE","version":"11.0","comment":""},"pages":[{"id":"1479767515","startedDateTime":"2016-11-21T23:31:56.561+01:00","title":"","pageTimings":{"comment":""},"comment":""}],"entries":[{"pageref":"1479767515","startedDateTime":"2016-11-21T23:32:02.146+01:00","request":{"method":"GET","url":"https://tiles.services.mozilla.com/v3/links/fetch/en-US/release","httpVersion":"HTTP/1.1","cookies":[],"headers":[],"queryString":[],"headersSize":370,"bodySize":0,"comment":""},"response":{"status":303,"statusText":"SEE OTHER","httpVersion":"HTTP/1.1","cookies":[],"headers":[],"content":{"size":0,"mimeType":"text/html; charset=utf-8","comment":""},"redirectURL":"","headersSize":266,"bodySize":0,"comment":""},"cache":{},"timings":{"blocked":101,"dns":266,"connect":238,"send":1,"wait":205,"receive":832,"ssl":0,"comment":""},"serverIPAddress":"52.32.150.180","comment":"","time":1643},{"pageref":"1479767515","startedDateTime":"2016-11-21T23:32:02.791+01:00","request":{"method":"POST","url":"https://location.services.mozilla.com/v1/country?key=7e40f68c-7938-4c5d-9f95-e61647c213eb","httpVersion":"HTTP/1.1","cookies":[],"headers":[],"queryString":[{"name":"key","value":"7e40f68c-7938-4c5d-9f95-e61647c213eb"}],"headersSize":419,"bodySize":2,"comment":""},"response":{"status":200,"statusText":"OK","httpVersion":"HTTP/1.1","cookies":[],"headers":[],"content":{"size":49,"mimeType":"application/json; charset=UTF-8","comment":""},"redirectURL":"","headersSize":227,"bodySize":49,"comment":""},"cache":{},"timings":{"blocked":0,"dns":9,"connect":45,"send":17,"wait":60,"receive":511,"ssl":0,"comment":""},"serverIPAddress":"52.19.86.22","comment":"","time":642}],"comment":""}}
profile.proxy = @@proxy.selenium_proxy :http, :ssl
@@proxy = server.create_proxy