So I am looking at trying to integrate Browsermob into a Ruby project so i can edit http responses. I have been following the setup with Selenium instructions from the Github and another article I found about performance testing - which I also want to do.
For this, I have gone with the code from the performance testing article but the results I am getting are the same. The code is
require 'selenium-webdriver'
require 'browsermob/proxy'
require 'rspec-expectations'
include RSpec::Matchers
require 'json'
def configure_proxy
proxy_binary = BrowserMob::Proxy::Server.new('my/path/to/browsermob-proxy-2.1.4/bin/browsermob-proxy')
proxy_binary.start
proxy_binary.create_proxy
end
def browser_profile
browser_profile = Selenium::WebDriver::Firefox::Profile.new
browser_profile.proxy = @proxy.selenium_proxy
browser_profile
end
def setup
@proxy = configure_proxy
@driver = Selenium::WebDriver.for :firefox, profile: browser_profile
end
def teardown
@driver.quit
@proxy.close
end
def capture_traffic
@proxy.new_har
yield
@proxy.har
end
def run
setup
har = capture_traffic { yield }
@har_file = "./selenium_#{Time.now.strftime("%m%d%y_%H%M%S")}.har"
har.save_to @har_file
teardown
end
run do
@driver.get 'http://the-internet.herokuapp.com/dynamic_loading/2'
@driver.find_element(css: '#start button').click
Selenium::WebDriver::Wait.new(timeout: 8).until do
@driver.find_element(css: '#finish')
end
end
performance_results = JSON.parse `yslow --info basic --format json #{@har_file}`
performance_grade = performance_results["o"]
performance_grade.should be > 90
Now, the problem I get is that as soon as I try to run this code (isolated away from my project or even within it) I get:
(.rvm/gems/ruby-2.5.3/gems/rest-client-2.0.2/lib/restclient/abstract_response.rb:220:in 'rescue in exception_with_response': HTTP status code 550 (RestClient::RequestFailed)
Does anyone know why I would be getting this? I understand that a 550 is an action not taken code but I'm confused as to why I would be getting this?
Any help would be VERY much appreciated!