telemetry.page.page_test | index telemetry/page/page_test.py

`# Copyright 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.`

Modules
`` |  |
telemetry.page.action_runner | telemetry.core.exceptions | logging |

Classes
`` |  | __builtin__.object PageTest exceptions.Exception(exceptions.BaseException) MultiTabTestAppCrashError TestNotSupportedOnPlatformError telemetry.web_perf.story_test.Failure(exceptions.Exception) MeasurementFailure
class MeasurementFailure(telemetry.web_perf.story_test.Failure)
`` | `PageTest Exception raised when an undesired but designed-for problem.`
| Method resolution order: MeasurementFailure telemetry.web_perf.story_test.Failure exceptions.Exception exceptions.BaseException __builtin__.object Data descriptors inherited from telemetry.web_perf.story_test.Failure: __weakref__ `list of weak references to the object (if defined)` Methods inherited from exceptions.Exception: __init__(...) `x.__init__(...) initializes x; see help(type(x)) for signature` Data and other attributes inherited from exceptions.Exception: __new__ = <built-in method __new__ of type object> `T.__new__(S, ...) -> a new object with type S, a subtype of T` Methods inherited from exceptions.BaseException: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __getitem__(...) `x.__getitem__(y) <==> x[y]` __getslice__(...) `x.__getslice__(i, j) <==> x[i:j] Use of negative indices is not supported.` __reduce__(...) __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` __setstate__(...) __str__(...) `x.__str__() <==> str(x)` __unicode__(...) Data descriptors inherited from exceptions.BaseException: __dict__ args message
class MultiTabTestAppCrashError(exceptions.Exception)
`` | `PageTest Exception raised after browser or tab crash for multi-tab tests. Used to abort the test rather than try to recover from an unknown state.`
| Method resolution order: MultiTabTestAppCrashError exceptions.Exception exceptions.BaseException __builtin__.object Data descriptors defined here: __weakref__ `list of weak references to the object (if defined)` Methods inherited from exceptions.Exception: __init__(...) `x.__init__(...) initializes x; see help(type(x)) for signature` Data and other attributes inherited from exceptions.Exception: __new__ = <built-in method __new__ of type object> `T.__new__(S, ...) -> a new object with type S, a subtype of T` Methods inherited from exceptions.BaseException: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __getitem__(...) `x.__getitem__(y) <==> x[y]` __getslice__(...) `x.__getslice__(i, j) <==> x[i:j] Use of negative indices is not supported.` __reduce__(...) __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` __setstate__(...) __str__(...) `x.__str__() <==> str(x)` __unicode__(...) Data descriptors inherited from exceptions.BaseException: __dict__ args message
class PageTest(__builtin__.object)
`` | `A class styled on unittest.TestCase for creating page-specific tests. Test should override ValidateAndMeasurePage to perform test validation and page measurement as necessary. class BodyChildElementMeasurement(PageTest): def ValidateAndMeasurePage(self, page, tab, results): body_child_count = tab.EvaluateJavaScript( 'document.body.children.length') results.AddValue(scalar.ScalarValue( page, 'body_children', 'count', body_child_count))`
| Methods defined here: CustomizeBrowserOptions(self, options) `Override to add test-specific options to the BrowserOptions object` DidNavigateToPage(self, page, tab) `Override to do operations right after the page is navigated and after all waiting for completion has occurred.` DidRunPage(self, platform) `Called after the test run method was run, even if it failed.` DidStartBrowser(self, browser) `Override to customize the browser right after it has launched.` RestartBrowserBeforeEachPage(self) `Should the browser be restarted for the page? This returns true if the test needs to unconditionally restart the browser for each page. It may be called before the browser is started.` RunNavigateSteps(self, page, tab) `Navigates the tab to the page URL attribute. Runs the 'navigate_steps' page attribute as a compound action.` SetOptions(self, options) `Sets the BrowserFinderOptions instance to use.` StopBrowserAfterPage(self, browser, page) `Should the browser be stopped after the page is run? This is called after a page is run to decide whether the browser needs to be stopped to clean up its state. If it is stopped, then it will be restarted to run the next page. A test that overrides this can look at both the page and the browser to decide whether it needs to stop the browser.` TabForPage(self, page, browser) `Override to select a different tab for the page. For instance, to create a new tab for every page, return browser.tabs.New().` ValidateAndMeasurePage(self, page, tab, results) `Override to check test assertions and perform measurement. When adding measurement results, call results.AddValue(...) for each result. Raise an exception or add a failure.FailureValue on failure. page_test.py also provides several base exception classes to use. Prefer metric value names that are in accordance with python variable style. e.g., metric_name. The name 'url' must not be used. Put together: def ValidateAndMeasurePage(self, page, tab, results): res = tab.EvaluateJavaScript('2+2') if res != 4: raise Exception('Oh, wow.') results.AddValue(scalar.ScalarValue( page, 'two_plus_two', 'count', res)) Args: page: A telemetry.page.Page instance. tab: A telemetry.core.Tab instance. results: A telemetry.results.PageTestResults instance.` WillNavigateToPage(self, page, tab) `Override to do operations before the page is navigated, notably Telemetry will already have performed the following operations on the browser before calling this function: * Ensure only one tab is open. * Call WaitForDocumentReadyStateToComplete on the tab.` WillStartBrowser(self, platform) `Override to manipulate the browser environment before it launches.` __init__(self, needs_browser_restart_after_each_page=False, clear_cache_before_each_run=False) Data descriptors defined here: __dict__ `dictionary for instance variables (if defined)` __weakref__ `list of weak references to the object (if defined)` clear_cache_before_each_run `When set to True, the browser's disk and memory cache will be cleared before each run.` close_tabs_before_run `When set to True, all tabs are closed before running the test for the first time.` is_multi_tab_test `Returns True if the test opens multiple tabs. If the test overrides TabForPage, it is deemed a multi-tab test. Multi-tab tests do not retry after tab or browser crashes, whereas, single-tab tests too. That is because the state of multi-tab tests (e.g., how many tabs are open, etc.) is unknown after crashes.`
class TestNotSupportedOnPlatformError(exceptions.Exception)
`` | `PageTest Exception raised when a required feature is unavailable. The feature required to run the test could be part of the platform, hardware configuration, or browser.`
| Method resolution order: TestNotSupportedOnPlatformError exceptions.Exception exceptions.BaseException __builtin__.object Data descriptors defined here: __weakref__ `list of weak references to the object (if defined)` Methods inherited from exceptions.Exception: __init__(...) `x.__init__(...) initializes x; see help(type(x)) for signature` Data and other attributes inherited from exceptions.Exception: __new__ = <built-in method __new__ of type object> `T.__new__(S, ...) -> a new object with type S, a subtype of T` Methods inherited from exceptions.BaseException: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __getitem__(...) `x.__getitem__(y) <==> x[y]` __getslice__(...) `x.__getslice__(i, j) <==> x[i:j] Use of negative indices is not supported.` __reduce__(...) __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` __setstate__(...) __str__(...) `x.__str__() <==> str(x)` __unicode__(...) Data descriptors inherited from exceptions.BaseException: __dict__ args message