Class: Watir::Browser
- Inherits:
-
Object
- Object
- Watir::Browser
- Defined in:
- lib/watir-webdriver-performance.rb
Instance Method Summary collapse
- #performance ⇒ Object
- #performance_supported? ⇒ Boolean (also: #performance_data)
- #with_performance {|PerformanceHelper.new(performance_data).munge| ... } ⇒ Object
Instance Method Details
#performance ⇒ Object
88 89 90 91 92 93 94 95 96 97 |
# File 'lib/watir-webdriver-performance.rb', line 88 def performance data = case driver.browser when :internet_explorer Object::JSON.parse(driver.execute_script("return JSON.stringify(window.performance.toJSON());")) else driver.execute_script("return window.performance || window.webkitPerformance || window.mozPerformance || window.msPerformance;") end raise 'Could not collect performance metrics from your current browser. Please ensure the browser you are using supports collecting performance metrics.' if data.nil? PerformanceHelper.new(data).munge end |
#performance_supported? ⇒ Boolean Also known as: performance_data
99 100 101 |
# File 'lib/watir-webdriver-performance.rb', line 99 def performance_supported? driver.execute_script("return window.performance || window.webkitPerformance || window.mozPerformance || window.msPerformance;") end |
#with_performance {|PerformanceHelper.new(performance_data).munge| ... } ⇒ Object
104 105 106 |
# File 'lib/watir-webdriver-performance.rb', line 104 def with_performance yield PerformanceHelper.new(performance_data).munge if performance_supported? end |