Class: Scoutui::Base::QHarMgr

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/scoutui/base/q_har_mgr.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeQHarMgr

Returns a new instance of QHarMgr.



15
16
17
18
# File 'lib/scoutui/base/q_har_mgr.rb', line 15

def initialize()
  puts __FILE__ + (__LINE__).to_s + " -- start BrowserMob --" if Scoutui::Utils::TestUtils.instance.isDebug?
  @proxy_binary = BrowserMob::Proxy::Server.new(ENV['BROWSER_MOB_BIN'], { :port => 8088 })
end

Instance Attribute Details

#proxyObject

Returns the value of attribute proxy.



11
12
13
# File 'lib/scoutui/base/q_har_mgr.rb', line 11

def proxy
  @proxy
end

#proxy_binaryObject

Returns the value of attribute proxy_binary.



10
11
12
# File 'lib/scoutui/base/q_har_mgr.rb', line 10

def proxy_binary
  @proxy_binary
end

#seleniumProfileObject

Returns the value of attribute seleniumProfile.



12
13
14
# File 'lib/scoutui/base/q_har_mgr.rb', line 12

def seleniumProfile
  @seleniumProfile
end

Instance Method Details

#capture_trafficObject



46
47
48
49
50
# File 'lib/scoutui/base/q_har_mgr.rb', line 46

def capture_traffic
 # @proxy.new_har
  yield
 @proxy.har
end

#getSeleniumProfileObject



30
31
32
33
# File 'lib/scoutui/base/q_har_mgr.rb', line 30

def getSeleniumProfile()
  puts __FILE__ + (__LINE__).to_s + " == getSeleniumProfile() => #{@seleniumProfile} --"
  @seleniumProfile
end

#run(n) ⇒ Object



52
53
54
55
56
57
# File 'lib/scoutui/base/q_har_mgr.rb', line 52

def run(n)
  puts __FILE__ + (__LINE__).to_s + " -- run --"
  @har = capture_traffic { yield }
#      @proxy.close
#      @har.save_to(n)
end

#startObject



20
21
22
23
24
25
26
27
# File 'lib/scoutui/base/q_har_mgr.rb', line 20

def start()
  puts __FILE__ + (__LINE__).to_s + " --start --"
  @proxy_binary.start
  @proxy = @proxy_binary.create_proxy
  @seleniumProfile = @proxy.selenium_proxy  # Needed by Selenium instance

  @proxy.new_har(:capture_headers => true)
end

#stop(save_as = nil) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/scoutui/base/q_har_mgr.rb', line 35

def stop(save_as=nil)
  puts __FILE__ + (__LINE__).to_s + " -- stop(#{save_as.to_s} --"
#  @proxy.close

  if !save_as.nil?
    @proxy.har.save_to(save_as)
  end

  @proxy.close
end