Skip to content

Instantly share code, notes, and snippets.

@ewollesen
Created November 1, 2012 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ewollesen/3995472 to your computer and use it in GitHub Desktop.
Save ewollesen/3995472 to your computer and use it in GitHub Desktop.
# OLD run_test
def run_test
if @headless
headless = Headless.new
headless.start
end
if @browser == :safari
b = Watir::Safari.new
else
# Clear the cache for every test run
c = Selenium::WebDriver::Firefox::Profile.new
c["browser.cache.memory.enable"] = false
c["browser.cache.disk.enable"] = false
driver = Selenium::WebDriver.for :firefox, :profile => c
b = Watir::Browser.new(driver)
end
@run_time = Benchmark::Tms.new()
#b.cookies.clear
b.driver.manage.delete_all_cookies
if @quiet_mode
# To run in quiet mode, must use the measure method
@test_actions.each do |t|
ta = Benchmark.measure { eval(t.code) }
@run_time = @run_time + ta
t.total_real_time << ta.real
end
else
Benchmark.benchmark(" ".ljust(@pad_size)+CAPTION, @pad_size, FORMAT, "TOTAL") do |x|
@test_actions.each do |t|
ta = out(x, t.desc) { eval(t.code) }
t.total_real_time << ta.real
end
[@run_time]
end
end
b.close
if @headless
headless.destroy
end
return @run_time
end
# NEW run_test
def run_test
headlessly do
in_browser do |b|
with_benchmarking(@quiet_mode, @pad_size) do |bench|
@test_actions.map do |action|
bench.benchmark(action.desc) {eval(action.code)}.tap do |time|
action.total_real_time << time.real
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment