Module: SeleniumStatistics
- Extended by:
- SeleniumStatistics
- Included in:
- SeleniumStatistics
- Defined in:
- lib/selenium_statistics.rb,
lib/selenium_statistics/logger.rb,
lib/selenium_statistics/statistics.rb
Overview
Code adapted from Selenium Implementation github.com/SeleniumHQ/selenium/blob/master/rb/lib/selenium/webdriver/common/logger.rb
Defined Under Namespace
Classes: Logger
Constant Summary collapse
- COMMANDS =
Selenium::WebDriver::Remote::Bridge::COMMANDS.keys + Selenium::WebDriver::Remote::W3C::Bridge::COMMANDS.keys + Selenium::WebDriver::Remote::OSS::Bridge::COMMANDS.keys
Instance Attribute Summary collapse
-
#executions ⇒ Object
readonly
Returns the value of attribute executions.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Class Method Summary collapse
Instance Method Summary collapse
- #get_element_location_once_scrolled_into_view=(*args) ⇒ Object
- #get_element_value_of_css_property=(*args) ⇒ Object
- #print_results(sort = nil) ⇒ Object
- #reset! ⇒ Object
- #results(sort = nil) ⇒ Object
Instance Attribute Details
#executions ⇒ Object (readonly)
Returns the value of attribute executions.
5 6 7 |
# File 'lib/selenium_statistics/statistics.rb', line 5 def executions @executions end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
5 6 7 |
# File 'lib/selenium_statistics/statistics.rb', line 5 def time @time end |
Class Method Details
.logger ⇒ Object
11 12 13 |
# File 'lib/selenium_statistics.rb', line 11 def self.logger @logger ||= SeleniumStatistics::Logger.new end |
Instance Method Details
#get_element_location_once_scrolled_into_view=(*args) ⇒ Object
47 48 49 |
# File 'lib/selenium_statistics/statistics.rb', line 47 def get_element_location_once_scrolled_into_view=(*args) self.get_element_location= args.first end |
#get_element_value_of_css_property=(*args) ⇒ Object
51 52 53 |
# File 'lib/selenium_statistics/statistics.rb', line 51 def get_element_value_of_css_property=(*args) self.get_element_css_value= args.first end |
#print_results(sort = nil) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/selenium_statistics/statistics.rb', line 63 def print_results(sort=nil) str = "Executed a total of #{executions} commands in #{time.round(1)} seconds\n\n" results(sort).each do |k,v| str << "#{k.to_s}:".ljust(27, ' ') str << "executions: #{v[:count].to_s.rjust(executions.size, ' ')}; " str << "total seconds: #{v[:time].round(1).to_s.rjust(time.round(1).to_s.size, ' ')}; " str << "avg sec/cmd: #{v[:average].round(3).to_s.rjust(5, ' ')}; " str << "total: #{(100*v[:average_total]).round(2).to_s.rjust(5, ' ')}%\n" end SeleniumStatistics.logger.warn str end |
#reset! ⇒ Object
77 78 79 80 81 82 |
# File 'lib/selenium_statistics/statistics.rb', line 77 def reset! @commands = {} @time = 0 @executions = 0 @test_start = Time.now end |
#results(sort = nil) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/selenium_statistics/statistics.rb', line 55 def results(sort=nil) sort ||= :count @test_time = Time.now - @test_start @commands.each { |_k, v| v[:average_total] = v[:time]/@test_time} @commands.sort_by { |_k, v| v[sort] }.reverse.to_h end |