Class: Watir::Browser
- Inherits:
-
Object
- Object
- Watir::Browser
- Defined in:
- lib/test_performance.rb
Instance Method Summary collapse
- #performance ⇒ Object
- #performance_data ⇒ Object (also: #performance_supported?)
- #performance_error ⇒ Object
- #performance_test ⇒ Object
- #performance_test_for_ie ⇒ Object
- #with_performance {|PerformanceData.new(performance_data).mapping| ... } ⇒ Object
Instance Method Details
#performance ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/test_performance.rb', line 157 def performance data = case driver.browser when :internet_explorer Object::JSON.parse(driver.execute_script(performance_test_for_ie)) else driver.execute_script(performance_test) end performance_error if data.nil? PerformanceData.new(data).mapping end |
#performance_data ⇒ Object Also known as: performance_supported?
173 174 175 |
# File 'lib/test_performance.rb', line 173 def performance_data driver.execute_script(performance_test) end |
#performance_error ⇒ Object
179 180 181 182 183 |
# File 'lib/test_performance.rb', line 179 def performance_error raise "Unable to collect performance metrics from the current "\ "browser. Make sure the browser you are using supports collecting "\ "performance metrics." end |
#performance_test ⇒ Object
185 186 187 188 189 |
# File 'lib/test_performance.rb', line 185 def performance_test "return window.performance || "\ "window.webkitPerformance || window.mozPerformance || "\ "window.msPerformance;" end |
#performance_test_for_ie ⇒ Object
191 192 193 |
# File 'lib/test_performance.rb', line 191 def performance_test_for_ie "return JSON.stringify(window.performance.toJSON());" end |
#with_performance {|PerformanceData.new(performance_data).mapping| ... } ⇒ Object
169 170 171 |
# File 'lib/test_performance.rb', line 169 def with_performance yield PerformanceData.new(performance_data).mapping if performance_supported? end |