1 2 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 3 <html><head><title>Python: module telemetry.page.page_test</title> 4 </head><body bgcolor="#f0f0f8"> 5 6 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> 7 <tr bgcolor="#7799ee"> 8 <td valign=bottom> <br> 9 <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="telemetry.html"><font color="#ffffff">telemetry</font></a>.<a href="telemetry.page.html"><font color="#ffffff">page</font></a>.page_test</strong></big></big></font></td 10 ><td align=right valign=bottom 11 ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="../telemetry/page/page_test.py">telemetry/page/page_test.py</a></font></td></tr></table> 12 <p><tt># Copyright (c) 2012 The Chromium Authors. All rights reserved.<br> 13 # Use of this source code is governed by a BSD-style license that can be<br> 14 # found in the LICENSE file.</tt></p> 15 <p> 16 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 17 <tr bgcolor="#aa55cc"> 18 <td colspan=3 valign=bottom> <br> 19 <font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr> 20 21 <tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td> 22 <td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="telemetry.page.actions.all_page_actions.html">telemetry.page.actions.all_page_actions</a><br> 23 <a href="telemetry.core.command_line.html">telemetry.core.command_line</a><br> 24 </td><td width="25%" valign=top><a href="telemetry.page.actions.interact.html">telemetry.page.actions.interact</a><br> 25 <a href="logging.html">logging</a><br> 26 </td><td width="25%" valign=top><a href="telemetry.page.actions.navigate.html">telemetry.page.actions.navigate</a><br> 27 <a href="telemetry.page.actions.page_action.html">telemetry.page.actions.page_action</a><br> 28 </td><td width="25%" valign=top><a href="telemetry.page.test_expectations.html">telemetry.page.test_expectations</a><br> 29 </td></tr></table></td></tr></table><p> 30 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 31 <tr bgcolor="#ee77aa"> 32 <td colspan=3 valign=bottom> <br> 33 <font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr> 34 35 <tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td> 36 <td width="100%"><dl> 37 <dt><font face="helvetica, arial"><a href="exceptions.html#Exception">exceptions.Exception</a>(<a href="exceptions.html#BaseException">exceptions.BaseException</a>) 38 </font></dt><dd> 39 <dl> 40 <dt><font face="helvetica, arial"><a href="telemetry.page.page_test.html#Failure">Failure</a> 41 </font></dt></dl> 42 </dd> 43 <dt><font face="helvetica, arial"><a href="telemetry.core.command_line.html#ArgumentHandlerMixIn">telemetry.core.command_line.ArgumentHandlerMixIn</a>(<a href="__builtin__.html#object">__builtin__.object</a>) 44 </font></dt><dd> 45 <dl> 46 <dt><font face="helvetica, arial"><a href="telemetry.page.page_test.html#PageTest">PageTest</a> 47 </font></dt></dl> 48 </dd> 49 </dl> 50 <p> 51 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 52 <tr bgcolor="#ffc8d8"> 53 <td colspan=3 valign=bottom> <br> 54 <font color="#000000" face="helvetica, arial"><a name="Failure">class <strong>Failure</strong></a>(<a href="exceptions.html#Exception">exceptions.Exception</a>)</font></td></tr> 55 56 <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> 57 <td colspan=2><tt><a href="exceptions.html#Exception">Exception</a> that can be thrown from PageMeasurement to indicate an<br> 58 undesired but designed-for problem.<br> </tt></td></tr> 59 <tr><td> </td> 60 <td width="100%"><dl><dt>Method resolution order:</dt> 61 <dd><a href="telemetry.page.page_test.html#Failure">Failure</a></dd> 62 <dd><a href="exceptions.html#Exception">exceptions.Exception</a></dd> 63 <dd><a href="exceptions.html#BaseException">exceptions.BaseException</a></dd> 64 <dd><a href="__builtin__.html#object">__builtin__.object</a></dd> 65 </dl> 66 <hr> 67 Data descriptors defined here:<br> 68 <dl><dt><strong>__weakref__</strong></dt> 69 <dd><tt>list of weak references to the object (if defined)</tt></dd> 70 </dl> 71 <hr> 72 Methods inherited from <a href="exceptions.html#Exception">exceptions.Exception</a>:<br> 73 <dl><dt><a name="Failure-__init__"><strong>__init__</strong></a>(...)</dt><dd><tt>x.<a href="#Failure-__init__">__init__</a>(...) initializes x; see help(type(x)) for signature</tt></dd></dl> 74 75 <hr> 76 Data and other attributes inherited from <a href="exceptions.html#Exception">exceptions.Exception</a>:<br> 77 <dl><dt><strong>__new__</strong> = <built-in method __new__ of type object><dd><tt>T.<a href="#Failure-__new__">__new__</a>(S, ...) -> a new object with type S, a subtype of T</tt></dl> 78 79 <hr> 80 Methods inherited from <a href="exceptions.html#BaseException">exceptions.BaseException</a>:<br> 81 <dl><dt><a name="Failure-__delattr__"><strong>__delattr__</strong></a>(...)</dt><dd><tt>x.<a href="#Failure-__delattr__">__delattr__</a>('name') <==> del x.name</tt></dd></dl> 82 83 <dl><dt><a name="Failure-__getattribute__"><strong>__getattribute__</strong></a>(...)</dt><dd><tt>x.<a href="#Failure-__getattribute__">__getattribute__</a>('name') <==> x.name</tt></dd></dl> 84 85 <dl><dt><a name="Failure-__getitem__"><strong>__getitem__</strong></a>(...)</dt><dd><tt>x.<a href="#Failure-__getitem__">__getitem__</a>(y) <==> x[y]</tt></dd></dl> 86 87 <dl><dt><a name="Failure-__getslice__"><strong>__getslice__</strong></a>(...)</dt><dd><tt>x.<a href="#Failure-__getslice__">__getslice__</a>(i, j) <==> x[i:j]<br> 88 <br> 89 Use of negative indices is not supported.</tt></dd></dl> 90 91 <dl><dt><a name="Failure-__reduce__"><strong>__reduce__</strong></a>(...)</dt></dl> 92 93 <dl><dt><a name="Failure-__repr__"><strong>__repr__</strong></a>(...)</dt><dd><tt>x.<a href="#Failure-__repr__">__repr__</a>() <==> repr(x)</tt></dd></dl> 94 95 <dl><dt><a name="Failure-__setattr__"><strong>__setattr__</strong></a>(...)</dt><dd><tt>x.<a href="#Failure-__setattr__">__setattr__</a>('name', value) <==> x.name = value</tt></dd></dl> 96 97 <dl><dt><a name="Failure-__setstate__"><strong>__setstate__</strong></a>(...)</dt></dl> 98 99 <dl><dt><a name="Failure-__str__"><strong>__str__</strong></a>(...)</dt><dd><tt>x.<a href="#Failure-__str__">__str__</a>() <==> str(x)</tt></dd></dl> 100 101 <dl><dt><a name="Failure-__unicode__"><strong>__unicode__</strong></a>(...)</dt></dl> 102 103 <hr> 104 Data descriptors inherited from <a href="exceptions.html#BaseException">exceptions.BaseException</a>:<br> 105 <dl><dt><strong>__dict__</strong></dt> 106 </dl> 107 <dl><dt><strong>args</strong></dt> 108 </dl> 109 <dl><dt><strong>message</strong></dt> 110 </dl> 111 </td></tr></table> <p> 112 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 113 <tr bgcolor="#ffc8d8"> 114 <td colspan=3 valign=bottom> <br> 115 <font color="#000000" face="helvetica, arial"><a name="PageTest">class <strong>PageTest</strong></a>(<a href="telemetry.core.command_line.html#ArgumentHandlerMixIn">telemetry.core.command_line.ArgumentHandlerMixIn</a>)</font></td></tr> 116 117 <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> 118 <td colspan=2><tt>A class styled on unittest.TestCase for creating page-specific tests.<br> </tt></td></tr> 119 <tr><td> </td> 120 <td width="100%"><dl><dt>Method resolution order:</dt> 121 <dd><a href="telemetry.page.page_test.html#PageTest">PageTest</a></dd> 122 <dd><a href="telemetry.core.command_line.html#ArgumentHandlerMixIn">telemetry.core.command_line.ArgumentHandlerMixIn</a></dd> 123 <dd><a href="__builtin__.html#object">__builtin__.object</a></dd> 124 </dl> 125 <hr> 126 Methods defined here:<br> 127 <dl><dt><a name="PageTest-CanRunForPage"><strong>CanRunForPage</strong></a>(self, page)</dt><dd><tt>Override to customize if the test can be ran for the given page.</tt></dd></dl> 128 129 <dl><dt><a name="PageTest-CleanUpAfterPage"><strong>CleanUpAfterPage</strong></a>(self, page, tab)</dt><dd><tt>Called after the test run method was run, even if it failed.</tt></dd></dl> 130 131 <dl><dt><a name="PageTest-CreateExpectations"><strong>CreateExpectations</strong></a>(self, page_set)</dt><dd><tt>Override to make this test generate its own expectations instead of<br> 132 any that may have been defined in the page set.</tt></dd></dl> 133 134 <dl><dt><a name="PageTest-CreatePageSet"><strong>CreatePageSet</strong></a>(self, args, options)</dt><dd><tt>Override to make this test generate its own page set instead of<br> 135 allowing arbitrary page sets entered from the command-line.</tt></dd></dl> 136 137 <dl><dt><a name="PageTest-CustomizeBrowserOptions"><strong>CustomizeBrowserOptions</strong></a>(self, options)</dt><dd><tt>Override to add test-specific options to the BrowserOptions object</tt></dd></dl> 138 139 <dl><dt><a name="PageTest-CustomizeBrowserOptionsForPageSet"><strong>CustomizeBrowserOptionsForPageSet</strong></a>(self, page_set, options)</dt><dd><tt>Set options required for this page set.<br> 140 <br> 141 These options will be used every time the browser is started while running<br> 142 this page set. They may, however, be further modified by<br> 143 CustomizeBrowserOptionsForSinglePage or by the profiler.</tt></dd></dl> 144 145 <dl><dt><a name="PageTest-CustomizeBrowserOptionsForSinglePage"><strong>CustomizeBrowserOptionsForSinglePage</strong></a>(self, page, options)</dt><dd><tt>Set options specific to the test and the given page.<br> 146 <br> 147 This will be called with the current page when the browser is (re)started.<br> 148 Changing options at this point only makes sense if the browser is being<br> 149 restarted for each page. Note that if page has a startup_url, the browser<br> 150 will always be restarted for each run.</tt></dd></dl> 151 152 <dl><dt><a name="PageTest-DidNavigateToPage"><strong>DidNavigateToPage</strong></a>(self, page, tab)</dt><dd><tt>Override to do operations right after the page is navigated and after<br> 153 all waiting for completion has occurred.</tt></dd></dl> 154 155 <dl><dt><a name="PageTest-DidRunAction"><strong>DidRunAction</strong></a>(self, page, tab, action)</dt><dd><tt>Override to do operations after running the action on the page.</tt></dd></dl> 156 157 <dl><dt><a name="PageTest-DidRunActions"><strong>DidRunActions</strong></a>(self, page, tab)</dt><dd><tt>Override to do operations after running the actions on the page.</tt></dd></dl> 158 159 <dl><dt><a name="PageTest-DidRunPageRepeats"><strong>DidRunPageRepeats</strong></a>(self, page)</dt><dd><tt>Override to do operations after each page is iterated over.</tt></dd></dl> 160 161 <dl><dt><a name="PageTest-DidRunTest"><strong>DidRunTest</strong></a>(self, browser, results)</dt><dd><tt>Override to do operations after all page set(s) are completed.<br> 162 <br> 163 This will occur before the browser is torn down.</tt></dd></dl> 164 165 <dl><dt><a name="PageTest-DidStartBrowser"><strong>DidStartBrowser</strong></a>(self, browser)</dt><dd><tt>Override to customize the browser right after it has launched.</tt></dd></dl> 166 167 <dl><dt><a name="PageTest-DidStartHTTPServer"><strong>DidStartHTTPServer</strong></a>(self, tab)</dt><dd><tt>Override to do operations after the HTTP server is started.</tt></dd></dl> 168 169 <dl><dt><a name="PageTest-IsExiting"><strong>IsExiting</strong></a>(self)</dt></dl> 170 171 <dl><dt><a name="PageTest-RequestExit"><strong>RequestExit</strong></a>(self)</dt></dl> 172 173 <dl><dt><a name="PageTest-RestartBrowserBeforeEachPage"><strong>RestartBrowserBeforeEachPage</strong></a>(self)</dt><dd><tt>Should the browser be restarted for the page?<br> 174 <br> 175 This returns true if the test needs to unconditionally restart the<br> 176 browser for each page. It may be called before the browser is started.</tt></dd></dl> 177 178 <dl><dt><a name="PageTest-Run"><strong>Run</strong></a>(self, page, tab, results)</dt></dl> 179 180 <dl><dt><a name="PageTest-RunNavigateSteps"><strong>RunNavigateSteps</strong></a>(self, page, tab)</dt><dd><tt>Navigates the tab to the page URL attribute.<br> 181 <br> 182 Runs the 'navigate_steps' page attribute as a compound action.</tt></dd></dl> 183 184 <dl><dt><a name="PageTest-StopBrowserAfterPage"><strong>StopBrowserAfterPage</strong></a>(self, browser, page)</dt><dd><tt>Should the browser be stopped after the page is run?<br> 185 <br> 186 This is called after a page is run to decide whether the browser needs to<br> 187 be stopped to clean up its state. If it is stopped, then it will be<br> 188 restarted to run the next page.<br> 189 <br> 190 A test that overrides this can look at both the page and the browser to<br> 191 decide whether it needs to stop the browser.</tt></dd></dl> 192 193 <dl><dt><a name="PageTest-TabForPage"><strong>TabForPage</strong></a>(self, page, browser)</dt><dd><tt>Override to select a different tab for the page. For instance, to<br> 194 create a new tab for every page, return browser.tabs.New().</tt></dd></dl> 195 196 <dl><dt><a name="PageTest-ValidatePageSet"><strong>ValidatePageSet</strong></a>(self, page_set)</dt><dd><tt>Override to examine the page set before the test run. Useful for<br> 197 example to validate that the pageset can be used with the test.</tt></dd></dl> 198 199 <dl><dt><a name="PageTest-WillNavigateToPage"><strong>WillNavigateToPage</strong></a>(self, page, tab)</dt><dd><tt>Override to do operations before the page is navigated, notably Telemetry<br> 200 will already have performed the following operations on the browser before<br> 201 calling this function:<br> 202 * Ensure only one tab is open.<br> 203 * Call WaitForDocumentReadyStateToComplete on the tab.</tt></dd></dl> 204 205 <dl><dt><a name="PageTest-WillRunAction"><strong>WillRunAction</strong></a>(self, page, tab, action)</dt><dd><tt>Override to do operations before running the action on the page.</tt></dd></dl> 206 207 <dl><dt><a name="PageTest-WillRunActions"><strong>WillRunActions</strong></a>(self, page, tab)</dt><dd><tt>Override to do operations before running the actions on the page.</tt></dd></dl> 208 209 <dl><dt><a name="PageTest-WillRunPageRepeats"><strong>WillRunPageRepeats</strong></a>(self, page)</dt><dd><tt>Override to do operations before each page is iterated over.</tt></dd></dl> 210 211 <dl><dt><a name="PageTest-WillRunTest"><strong>WillRunTest</strong></a>(self, options)</dt><dd><tt>Override to do operations before the page set(s) are navigated.</tt></dd></dl> 212 213 <dl><dt><a name="PageTest-WillStartBrowser"><strong>WillStartBrowser</strong></a>(self, browser)</dt><dd><tt>Override to manipulate the browser environment before it launches.</tt></dd></dl> 214 215 <dl><dt><a name="PageTest-__init__"><strong>__init__</strong></a>(self, test_method_name, action_name_to_run<font color="#909090">=''</font>, needs_browser_restart_after_each_page<font color="#909090">=False</font>, discard_first_result<font color="#909090">=False</font>, clear_cache_before_each_run<font color="#909090">=False</font>, attempts<font color="#909090">=3</font>, max_failures<font color="#909090">=None</font>, max_errors<font color="#909090">=None</font>)</dt></dl> 216 217 <hr> 218 Data descriptors defined here:<br> 219 <dl><dt><strong>action_name_to_run</strong></dt> 220 </dl> 221 <dl><dt><strong>attempts</strong></dt> 222 <dd><tt>Maximum number of times test will be attempted.</tt></dd> 223 </dl> 224 <dl><dt><strong>clear_cache_before_each_run</strong></dt> 225 <dd><tt>When set to True, the browser's disk and memory cache will be cleared<br> 226 before each run.</tt></dd> 227 </dl> 228 <dl><dt><strong>close_tabs_before_run</strong></dt> 229 <dd><tt>When set to True, all tabs are closed before running the test for the<br> 230 first time.</tt></dd> 231 </dl> 232 <dl><dt><strong>discard_first_result</strong></dt> 233 <dd><tt>When set to True, the first run of the test is discarded. This is<br> 234 useful for cases where it's desirable to have some test resource cached so<br> 235 the first run of the test can warm things up.</tt></dd> 236 </dl> 237 <dl><dt><strong>max_errors</strong></dt> 238 <dd><tt>Maximum number of errors allowed for the page set.</tt></dd> 239 </dl> 240 <dl><dt><strong>max_failures</strong></dt> 241 <dd><tt>Maximum number of failures allowed for the page set.</tt></dd> 242 </dl> 243 <hr> 244 Class methods inherited from <a href="telemetry.core.command_line.html#ArgumentHandlerMixIn">telemetry.core.command_line.ArgumentHandlerMixIn</a>:<br> 245 <dl><dt><a name="PageTest-AddCommandLineArgs"><strong>AddCommandLineArgs</strong></a>(cls, parser)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt><dd><tt>Override to accept custom command-line arguments.</tt></dd></dl> 246 247 <dl><dt><a name="PageTest-ProcessCommandLineArgs"><strong>ProcessCommandLineArgs</strong></a>(cls, parser, args)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt><dd><tt>Override to process command-line arguments.<br> 248 <br> 249 We pass in parser so we can call parser.error().</tt></dd></dl> 250 251 <hr> 252 Data descriptors inherited from <a href="telemetry.core.command_line.html#ArgumentHandlerMixIn">telemetry.core.command_line.ArgumentHandlerMixIn</a>:<br> 253 <dl><dt><strong>__dict__</strong></dt> 254 <dd><tt>dictionary for instance variables (if defined)</tt></dd> 255 </dl> 256 <dl><dt><strong>__weakref__</strong></dt> 257 <dd><tt>list of weak references to the object (if defined)</tt></dd> 258 </dl> 259 </td></tr></table></td></tr></table><p> 260 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 261 <tr bgcolor="#eeaa77"> 262 <td colspan=3 valign=bottom> <br> 263 <font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr> 264 265 <tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td> 266 <td width="100%"><dl><dt><a name="-GetCompoundActionFromPage"><strong>GetCompoundActionFromPage</strong></a>(page, action_name, interactive<font color="#909090">=False</font>)</dt></dl> 267 <dl><dt><a name="-GetSubactionFromData"><strong>GetSubactionFromData</strong></a>(page, subaction_data, interactive)</dt></dl> 268 </td></tr></table> 269 </body></html>