1 2<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 3<html><head><title>Python: module telemetry.page.action_runner</title> 4<meta charset="utf-8"> 5</head><body bgcolor="#f0f0f8"> 6 7<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> 8<tr bgcolor="#7799ee"> 9<td valign=bottom> <br> 10<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>.action_runner</strong></big></big></font></td 11><td align=right valign=bottom 12><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="../telemetry/page/action_runner.py">telemetry/page/action_runner.py</a></font></td></tr></table> 13 <p><tt># Copyright 2014 The Chromium Authors. All rights reserved.<br> 14# Use of this source code is governed by a BSD-style license that can be<br> 15# found in the LICENSE file.</tt></p> 16<p> 17<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 18<tr bgcolor="#aa55cc"> 19<td colspan=3 valign=bottom> <br> 20<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr> 21 22<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td> 23<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="logging.html">logging</a><br> 24</td><td width="25%" valign=top><a href="time.html">time</a><br> 25</td><td width="25%" valign=top><a href="telemetry.web_perf.timeline_interaction_record.html">telemetry.web_perf.timeline_interaction_record</a><br> 26</td><td width="25%" valign=top><a href="urlparse.html">urlparse</a><br> 27</td></tr></table></td></tr></table><p> 28<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 29<tr bgcolor="#ee77aa"> 30<td colspan=3 valign=bottom> <br> 31<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr> 32 33<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td> 34<td width="100%"><dl> 35<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a> 36</font></dt><dd> 37<dl> 38<dt><font face="helvetica, arial"><a href="telemetry.page.action_runner.html#ActionRunner">ActionRunner</a> 39</font></dt><dt><font face="helvetica, arial"><a href="telemetry.page.action_runner.html#Interaction">Interaction</a> 40</font></dt></dl> 41</dd> 42</dl> 43 <p> 44<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 45<tr bgcolor="#ffc8d8"> 46<td colspan=3 valign=bottom> <br> 47<font color="#000000" face="helvetica, arial"><a name="ActionRunner">class <strong>ActionRunner</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> 48 49<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> 50<td width="100%">Methods defined here:<br> 51<dl><dt><a name="ActionRunner-ClickElement"><strong>ClickElement</strong></a>(self, selector<font color="#909090">=None</font>, text<font color="#909090">=None</font>, element_function<font color="#909090">=None</font>)</dt><dd><tt>Click an element.<br> 52 <br> 53The element may be selected via selector, text, or element_function.<br> 54Only one of these arguments must be specified.<br> 55 <br> 56Args:<br> 57 selector: A CSS selector describing the element.<br> 58 text: The element must contains this exact text.<br> 59 element_function: A JavaScript function (as string) that is used<br> 60 to retrieve the element. For example:<br> 61 '(function() { return foo.element; })()'.</tt></dd></dl> 62 63<dl><dt><a name="ActionRunner-CreateGestureInteraction"><strong>CreateGestureInteraction</strong></a>(self, label, repeatable<font color="#909090">=False</font>)</dt><dd><tt>Create an action.<a href="#Interaction">Interaction</a> <a href="__builtin__.html#object">object</a> that issues gesture-based<br> 64interaction record.<br> 65 <br> 66This is similar to normal interaction record, but it will<br> 67auto-narrow the interaction time period to only include the<br> 68synthetic gesture event output by Chrome. This is typically use to<br> 69reduce noise in gesture-based analysis (e.g., analysis for a<br> 70swipe/scroll).<br> 71 <br> 72The interaction record label will be prepended with 'Gesture_'.<br> 73 <br> 74e.g:<br> 75 with action_runner.<a href="#ActionRunner-CreateGestureInteraction">CreateGestureInteraction</a>('Scroll-1'):<br> 76 action_runner.<a href="#ActionRunner-ScrollPage">ScrollPage</a>()<br> 77 <br> 78Args:<br> 79 label: A label for this particular interaction. This can be any<br> 80 user-defined string, but must not contain '/'.<br> 81 repeatable: Whether other interactions may use the same logical name<br> 82 as this interaction. All interactions with the same logical name must<br> 83 have the same flags.<br> 84 <br> 85Returns:<br> 86 An instance of action_runner.<a href="#Interaction">Interaction</a></tt></dd></dl> 87 88<dl><dt><a name="ActionRunner-CreateInteraction"><strong>CreateInteraction</strong></a>(self, label, repeatable<font color="#909090">=False</font>)</dt><dd><tt>Create an action.<a href="#Interaction">Interaction</a> <a href="__builtin__.html#object">object</a> that issues interaction record.<br> 89 <br> 90An interaction record is a labeled time period containing<br> 91interaction that developers care about. Each set of metrics<br> 92specified in flags will be calculated for this time period.<br> 93 <br> 94To mark the start of interaction record, call Begin() method on the returned<br> 95<a href="__builtin__.html#object">object</a>. To mark the finish of interaction record, call End() method on<br> 96it. Or better yet, use the with statement to create an<br> 97interaction record that covers the actions in the with block.<br> 98 <br> 99e.g:<br> 100 with action_runner.<a href="#ActionRunner-CreateInteraction">CreateInteraction</a>('Animation-1'):<br> 101 action_runner.<a href="#ActionRunner-TapElement">TapElement</a>(...)<br> 102 action_runner.<a href="#ActionRunner-WaitForJavaScriptCondition">WaitForJavaScriptCondition</a>(...)<br> 103 <br> 104Args:<br> 105 label: A label for this particular interaction. This can be any<br> 106 user-defined string, but must not contain '/'.<br> 107 repeatable: Whether other interactions may use the same logical name<br> 108 as this interaction. All interactions with the same logical name must<br> 109 have the same flags.<br> 110 <br> 111Returns:<br> 112 An instance of action_runner.<a href="#Interaction">Interaction</a></tt></dd></dl> 113 114<dl><dt><a name="ActionRunner-DragPage"><strong>DragPage</strong></a>(self, left_start_ratio, top_start_ratio, left_end_ratio, top_end_ratio, speed_in_pixels_per_second<font color="#909090">=800</font>, use_touch<font color="#909090">=False</font>, selector<font color="#909090">=None</font>, text<font color="#909090">=None</font>, element_function<font color="#909090">=None</font>)</dt><dd><tt>Perform a drag gesture on the page.<br> 115 <br> 116You should specify a start and an end point in ratios of page width and<br> 117height (see drag.js for full implementation).<br> 118 <br> 119Args:<br> 120 left_start_ratio: The horizontal starting coordinate of the<br> 121 gesture, as a ratio of the visible bounding rectangle for<br> 122 document.body.<br> 123 top_start_ratio: The vertical starting coordinate of the<br> 124 gesture, as a ratio of the visible bounding rectangle for<br> 125 document.body.<br> 126 left_end_ratio: The horizontal ending coordinate of the<br> 127 gesture, as a ratio of the visible bounding rectangle for<br> 128 document.body.<br> 129 top_end_ratio: The vertical ending coordinate of the<br> 130 gesture, as a ratio of the visible bounding rectangle for<br> 131 document.body.<br> 132 speed_in_pixels_per_second: The speed of the gesture (in pixels/s).<br> 133 use_touch: Whether dragging should be done with touch input.</tt></dd></dl> 134 135<dl><dt><a name="ActionRunner-EvaluateJavaScript"><strong>EvaluateJavaScript</strong></a>(self, expression)</dt><dd><tt>Returns the evaluation result of the given JavaScript expression.<br> 136 <br> 137The evaluation results must be convertible to JSON. If the result<br> 138is not needed, use ExecuteJavaScript instead.<br> 139 <br> 140Example: num = runner.<a href="#ActionRunner-EvaluateJavaScript">EvaluateJavaScript</a>('document.location.href')<br> 141 <br> 142Args:<br> 143 expression: The expression to evaluate (provided as string).<br> 144 <br> 145Raises:<br> 146 EvaluationException: The statement expression failed to execute<br> 147 or the evaluation result can not be JSON-ized.</tt></dd></dl> 148 149<dl><dt><a name="ActionRunner-ExecuteJavaScript"><strong>ExecuteJavaScript</strong></a>(self, statement)</dt><dd><tt>Executes a given JavaScript expression. Does not return the result.<br> 150 <br> 151Example: runner.<a href="#ActionRunner-ExecuteJavaScript">ExecuteJavaScript</a>('var foo = 1;');<br> 152 <br> 153Args:<br> 154 statement: The statement to execute (provided as string).<br> 155 <br> 156Raises:<br> 157 EvaluationException: The statement failed to execute.</tt></dd></dl> 158 159<dl><dt><a name="ActionRunner-ForceGarbageCollection"><strong>ForceGarbageCollection</strong></a>(self)</dt><dd><tt>Forces JavaScript garbage collection on the page.</tt></dd></dl> 160 161<dl><dt><a name="ActionRunner-LoadMedia"><strong>LoadMedia</strong></a>(self, selector<font color="#909090">=None</font>, event_timeout_in_seconds<font color="#909090">=0</font>, event_to_await<font color="#909090">='canplaythrough'</font>)</dt><dd><tt>Invokes load() on media elements and awaits an event.<br> 162 <br> 163Args:<br> 164 selector: A CSS selector describing the element. If none is<br> 165 specified, play the first media element on the page. If the<br> 166 selector matches more than 1 media element, all of them will<br> 167 be played.<br> 168 event_timeout_in_seconds: Maximum waiting time for the event to be fired.<br> 169 0 means do not wait.<br> 170 event_to_await: Which event to await. For example: 'canplaythrough' or<br> 171 'loadedmetadata'.<br> 172 <br> 173Raises:<br> 174 TimeoutException: If the maximum waiting time is exceeded.</tt></dd></dl> 175 176<dl><dt><a name="ActionRunner-LoopMedia"><strong>LoopMedia</strong></a>(self, loop_count, selector<font color="#909090">=None</font>, timeout_in_seconds<font color="#909090">=None</font>)</dt><dd><tt>Loops a media playback.<br> 177 <br> 178Args:<br> 179 loop_count: The number of times to loop the playback.<br> 180 selector: A CSS selector describing the element. If none is<br> 181 specified, loop the first media element on the page. If the<br> 182 selector matches more than 1 media element, all of them will<br> 183 be looped.<br> 184 timeout_in_seconds: Maximum waiting time for the looped playback to<br> 185 complete. 0 means do not wait. None (the default) means to<br> 186 wait loop_count * 60 seconds.<br> 187 <br> 188Raises:<br> 189 TimeoutException: If the maximum waiting time is exceeded.</tt></dd></dl> 190 191<dl><dt><a name="ActionRunner-MouseClick"><strong>MouseClick</strong></a>(self, selector<font color="#909090">=None</font>)</dt><dd><tt>Mouse click the given element.<br> 192 <br> 193Args:<br> 194 selector: A CSS selector describing the element.</tt></dd></dl> 195 196<dl><dt><a name="ActionRunner-Navigate"><strong>Navigate</strong></a>(self, url, script_to_evaluate_on_commit<font color="#909090">=None</font>, timeout_in_seconds<font color="#909090">=60</font>)</dt><dd><tt>Navigates to url.<br> 197 <br> 198If |script_to_evaluate_on_commit| is given, the script source string will be<br> 199evaluated when the navigation is committed. This is after the context of<br> 200the page exists, but before any script on the page itself has executed.</tt></dd></dl> 201 202<dl><dt><a name="ActionRunner-PauseInteractive"><strong>PauseInteractive</strong></a>(self)</dt><dd><tt>Pause the page execution and wait for terminal interaction.<br> 203 <br> 204This is typically used for debugging. You can use this to pause<br> 205the page execution and inspect the browser state before<br> 206continuing.</tt></dd></dl> 207 208<dl><dt><a name="ActionRunner-PinchElement"><strong>PinchElement</strong></a>(self, selector<font color="#909090">=None</font>, text<font color="#909090">=None</font>, element_function<font color="#909090">=None</font>, left_anchor_ratio<font color="#909090">=0.5</font>, top_anchor_ratio<font color="#909090">=0.5</font>, scale_factor<font color="#909090">=None</font>, speed_in_pixels_per_second<font color="#909090">=800</font>)</dt><dd><tt>Perform the pinch gesture on an element.<br> 209 <br> 210It computes the pinch gesture automatically based on the anchor<br> 211coordinate and the scale factor. The scale factor is the ratio of<br> 212of the final span and the initial span of the gesture.<br> 213 <br> 214Args:<br> 215 selector: A CSS selector describing the element.<br> 216 text: The element must contains this exact text.<br> 217 element_function: A JavaScript function (as string) that is used<br> 218 to retrieve the element. For example:<br> 219 'function() { return foo.element; }'.<br> 220 left_anchor_ratio: The horizontal pinch anchor coordinate of the<br> 221 gesture, as a ratio of the visible bounding rectangle for<br> 222 the element.<br> 223 top_anchor_ratio: The vertical pinch anchor coordinate of the<br> 224 gesture, as a ratio of the visible bounding rectangle for<br> 225 the element.<br> 226 scale_factor: The ratio of the final span to the initial span.<br> 227 The default scale factor is<br> 228 3.0 / (window.outerWidth/window.innerWidth).<br> 229 speed_in_pixels_per_second: The speed of the gesture (in pixels/s).</tt></dd></dl> 230 231<dl><dt><a name="ActionRunner-PinchPage"><strong>PinchPage</strong></a>(self, left_anchor_ratio<font color="#909090">=0.5</font>, top_anchor_ratio<font color="#909090">=0.5</font>, scale_factor<font color="#909090">=None</font>, speed_in_pixels_per_second<font color="#909090">=800</font>)</dt><dd><tt>Perform the pinch gesture on the page.<br> 232 <br> 233It computes the pinch gesture automatically based on the anchor<br> 234coordinate and the scale factor. The scale factor is the ratio of<br> 235of the final span and the initial span of the gesture.<br> 236 <br> 237Args:<br> 238 left_anchor_ratio: The horizontal pinch anchor coordinate of the<br> 239 gesture, as a ratio of the visible bounding rectangle for<br> 240 document.body.<br> 241 top_anchor_ratio: The vertical pinch anchor coordinate of the<br> 242 gesture, as a ratio of the visible bounding rectangle for<br> 243 document.body.<br> 244 scale_factor: The ratio of the final span to the initial span.<br> 245 The default scale factor is<br> 246 3.0 / (window.outerWidth/window.innerWidth).<br> 247 speed_in_pixels_per_second: The speed of the gesture (in pixels/s).</tt></dd></dl> 248 249<dl><dt><a name="ActionRunner-PlayMedia"><strong>PlayMedia</strong></a>(self, selector<font color="#909090">=None</font>, playing_event_timeout_in_seconds<font color="#909090">=0</font>, ended_event_timeout_in_seconds<font color="#909090">=0</font>)</dt><dd><tt>Invokes the "play" action on media elements (such as video).<br> 250 <br> 251Args:<br> 252 selector: A CSS selector describing the element. If none is<br> 253 specified, play the first media element on the page. If the<br> 254 selector matches more than 1 media element, all of them will<br> 255 be played.<br> 256 playing_event_timeout_in_seconds: Maximum waiting time for the "playing"<br> 257 event (dispatched when the media begins to play) to be fired.<br> 258 0 means do not wait.<br> 259 ended_event_timeout_in_seconds: Maximum waiting time for the "ended"<br> 260 event (dispatched when playback completes) to be fired.<br> 261 0 means do not wait.<br> 262 <br> 263Raises:<br> 264 TimeoutException: If the maximum waiting time is exceeded.</tt></dd></dl> 265 266<dl><dt><a name="ActionRunner-ReloadPage"><strong>ReloadPage</strong></a>(self)</dt><dd><tt>Reloads the page.</tt></dd></dl> 267 268<dl><dt><a name="ActionRunner-RepaintContinuously"><strong>RepaintContinuously</strong></a>(self, seconds)</dt><dd><tt>Continuously repaints the visible content.<br> 269 <br> 270It does this by requesting animation frames until the given number<br> 271of seconds have elapsed AND at least three RAFs have been<br> 272fired. Times out after max(60, self.<strong>seconds</strong>), if less than three<br> 273RAFs were fired.</tt></dd></dl> 274 275<dl><dt><a name="ActionRunner-RepeatableBrowserDrivenScroll"><strong>RepeatableBrowserDrivenScroll</strong></a>(self, x_scroll_distance_ratio<font color="#909090">=0.0</font>, y_scroll_distance_ratio<font color="#909090">=0.5</font>, repeat_count<font color="#909090">=0</font>, repeat_delay_ms<font color="#909090">=250</font>)</dt><dd><tt>Perform a browser driven repeatable scroll gesture.<br> 276 <br> 277The scroll gesture is driven from the browser, this is useful because the<br> 278main thread often isn't resposive but the browser process usually is, so the<br> 279delay between the scroll gestures should be consistent.<br> 280 <br> 281Args:<br> 282 x_scroll_distance_ratio: The horizontal lenght of the scroll as a fraction<br> 283 of the screen width.<br> 284 y_scroll_distance_ratio: The vertical lenght of the scroll as a fraction<br> 285 of the screen height.<br> 286 repeat_count: The number of additional times to repeat the gesture.<br> 287 repeat_delay_ms: The delay in milliseconds between each scroll gesture.</tt></dd></dl> 288 289<dl><dt><a name="ActionRunner-ScrollBounceElement"><strong>ScrollBounceElement</strong></a>(self, selector<font color="#909090">=None</font>, text<font color="#909090">=None</font>, element_function<font color="#909090">=None</font>, left_start_ratio<font color="#909090">=0.5</font>, top_start_ratio<font color="#909090">=0.5</font>, direction<font color="#909090">='down'</font>, distance<font color="#909090">=100</font>, overscroll<font color="#909090">=10</font>, repeat_count<font color="#909090">=10</font>, speed_in_pixels_per_second<font color="#909090">=400</font>)</dt><dd><tt>Perform scroll bounce gesture on the element.<br> 290 <br> 291This gesture scrolls on the element by the number of pixels specified in<br> 292distance, in the given direction, followed by a scroll by<br> 293(distance + overscroll) pixels in the opposite direction.<br> 294The above gesture is repeated repeat_count times.<br> 295 <br> 296Args:<br> 297 selector: A CSS selector describing the element.<br> 298 text: The element must contains this exact text.<br> 299 element_function: A JavaScript function (as string) that is used<br> 300 to retrieve the element. For example:<br> 301 'function() { return foo.element; }'.<br> 302 left_start_ratio: The horizontal starting coordinate of the<br> 303 gesture, as a ratio of the visible bounding rectangle for<br> 304 document.body.<br> 305 top_start_ratio: The vertical starting coordinate of the<br> 306 gesture, as a ratio of the visible bounding rectangle for<br> 307 document.body.<br> 308 direction: The direction of scroll, either 'left', 'right',<br> 309 'up', 'down', 'upleft', 'upright', 'downleft', or 'downright'<br> 310 distance: The distance to scroll (in pixel).<br> 311 overscroll: The number of additional pixels to scroll back, in<br> 312 addition to the givendistance.<br> 313 repeat_count: How often we want to repeat the full gesture.<br> 314 speed_in_pixels_per_second: The speed of the gesture (in pixels/s).</tt></dd></dl> 315 316<dl><dt><a name="ActionRunner-ScrollBouncePage"><strong>ScrollBouncePage</strong></a>(self, left_start_ratio<font color="#909090">=0.5</font>, top_start_ratio<font color="#909090">=0.5</font>, direction<font color="#909090">='down'</font>, distance<font color="#909090">=100</font>, overscroll<font color="#909090">=10</font>, repeat_count<font color="#909090">=10</font>, speed_in_pixels_per_second<font color="#909090">=400</font>)</dt><dd><tt>Perform scroll bounce gesture on the page.<br> 317 <br> 318This gesture scrolls the page by the number of pixels specified in<br> 319distance, in the given direction, followed by a scroll by<br> 320(distance + overscroll) pixels in the opposite direction.<br> 321The above gesture is repeated repeat_count times.<br> 322 <br> 323Args:<br> 324 left_start_ratio: The horizontal starting coordinate of the<br> 325 gesture, as a ratio of the visible bounding rectangle for<br> 326 document.body.<br> 327 top_start_ratio: The vertical starting coordinate of the<br> 328 gesture, as a ratio of the visible bounding rectangle for<br> 329 document.body.<br> 330 direction: The direction of scroll, either 'left', 'right',<br> 331 'up', 'down', 'upleft', 'upright', 'downleft', or 'downright'<br> 332 distance: The distance to scroll (in pixel).<br> 333 overscroll: The number of additional pixels to scroll back, in<br> 334 addition to the givendistance.<br> 335 repeat_count: How often we want to repeat the full gesture.<br> 336 speed_in_pixels_per_second: The speed of the gesture (in pixels/s).</tt></dd></dl> 337 338<dl><dt><a name="ActionRunner-ScrollElement"><strong>ScrollElement</strong></a>(self, selector<font color="#909090">=None</font>, text<font color="#909090">=None</font>, element_function<font color="#909090">=None</font>, left_start_ratio<font color="#909090">=0.5</font>, top_start_ratio<font color="#909090">=0.5</font>, direction<font color="#909090">='down'</font>, distance<font color="#909090">=None</font>, distance_expr<font color="#909090">=None</font>, speed_in_pixels_per_second<font color="#909090">=800</font>, use_touch<font color="#909090">=False</font>, synthetic_gesture_source<font color="#909090">='DEFAULT'</font>)</dt><dd><tt>Perform scroll gesture on the element.<br> 339 <br> 340The element may be selected via selector, text, or element_function.<br> 341Only one of these arguments must be specified.<br> 342 <br> 343You may specify distance or distance_expr, but not both. If<br> 344neither is specified, the default scroll distance is variable<br> 345depending on direction (see scroll.js for full implementation).<br> 346 <br> 347Args:<br> 348 selector: A CSS selector describing the element.<br> 349 text: The element must contains this exact text.<br> 350 element_function: A JavaScript function (as string) that is used<br> 351 to retrieve the element. For example:<br> 352 'function() { return foo.element; }'.<br> 353 left_start_ratio: The horizontal starting coordinate of the<br> 354 gesture, as a ratio of the visible bounding rectangle for<br> 355 the element.<br> 356 top_start_ratio: The vertical starting coordinate of the<br> 357 gesture, as a ratio of the visible bounding rectangle for<br> 358 the element.<br> 359 direction: The direction of scroll, either 'left', 'right',<br> 360 'up', 'down', 'upleft', 'upright', 'downleft', or 'downright'<br> 361 distance: The distance to scroll (in pixel).<br> 362 distance_expr: A JavaScript expression (as string) that can be<br> 363 evaluated to compute scroll distance. Example:<br> 364 'window.scrollTop' or '(function() { return crazyMath(); })()'.<br> 365 speed_in_pixels_per_second: The speed of the gesture (in pixels/s).<br> 366 use_touch: Whether scrolling should be done with touch input.<br> 367 synthetic_gesture_source: the source input device type for the<br> 368 synthetic gesture: 'DEFAULT', 'TOUCH' or 'MOUSE'.</tt></dd></dl> 369 370<dl><dt><a name="ActionRunner-ScrollPage"><strong>ScrollPage</strong></a>(self, left_start_ratio<font color="#909090">=0.5</font>, top_start_ratio<font color="#909090">=0.5</font>, direction<font color="#909090">='down'</font>, distance<font color="#909090">=None</font>, distance_expr<font color="#909090">=None</font>, speed_in_pixels_per_second<font color="#909090">=800</font>, use_touch<font color="#909090">=False</font>, synthetic_gesture_source<font color="#909090">='DEFAULT'</font>)</dt><dd><tt>Perform scroll gesture on the page.<br> 371 <br> 372You may specify distance or distance_expr, but not both. If<br> 373neither is specified, the default scroll distance is variable<br> 374depending on direction (see scroll.js for full implementation).<br> 375 <br> 376Args:<br> 377 left_start_ratio: The horizontal starting coordinate of the<br> 378 gesture, as a ratio of the visible bounding rectangle for<br> 379 document.body.<br> 380 top_start_ratio: The vertical starting coordinate of the<br> 381 gesture, as a ratio of the visible bounding rectangle for<br> 382 document.body.<br> 383 direction: The direction of scroll, either 'left', 'right',<br> 384 'up', 'down', 'upleft', 'upright', 'downleft', or 'downright'<br> 385 distance: The distance to scroll (in pixel).<br> 386 distance_expr: A JavaScript expression (as string) that can be<br> 387 evaluated to compute scroll distance. Example:<br> 388 'window.scrollTop' or '(function() { return crazyMath(); })()'.<br> 389 speed_in_pixels_per_second: The speed of the gesture (in pixels/s).<br> 390 use_touch: Whether scrolling should be done with touch input.<br> 391 synthetic_gesture_source: the source input device type for the<br> 392 synthetic gesture: 'DEFAULT', 'TOUCH' or 'MOUSE'.</tt></dd></dl> 393 394<dl><dt><a name="ActionRunner-SeekMedia"><strong>SeekMedia</strong></a>(self, seconds, selector<font color="#909090">=None</font>, timeout_in_seconds<font color="#909090">=0</font>, log_time<font color="#909090">=True</font>, label<font color="#909090">=''</font>)</dt><dd><tt>Performs a seek action on media elements (such as video).<br> 395 <br> 396Args:<br> 397 seconds: The media time to seek to.<br> 398 selector: A CSS selector describing the element. If none is<br> 399 specified, seek the first media element on the page. If the<br> 400 selector matches more than 1 media element, all of them will<br> 401 be seeked.<br> 402 timeout_in_seconds: Maximum waiting time for the "seeked" event<br> 403 (dispatched when the seeked operation completes) to be<br> 404 fired. 0 means do not wait.<br> 405 log_time: Whether to log the seek time for the perf<br> 406 measurement. Useful when performing multiple seek.<br> 407 label: A suffix string to name the seek perf measurement.<br> 408 <br> 409Raises:<br> 410 TimeoutException: If the maximum waiting time is exceeded.</tt></dd></dl> 411 412<dl><dt><a name="ActionRunner-SwipeElement"><strong>SwipeElement</strong></a>(self, selector<font color="#909090">=None</font>, text<font color="#909090">=None</font>, element_function<font color="#909090">=None</font>, left_start_ratio<font color="#909090">=0.5</font>, top_start_ratio<font color="#909090">=0.5</font>, direction<font color="#909090">='left'</font>, distance<font color="#909090">=100</font>, speed_in_pixels_per_second<font color="#909090">=800</font>)</dt><dd><tt>Perform swipe gesture on the element.<br> 413 <br> 414The element may be selected via selector, text, or element_function.<br> 415Only one of these arguments must be specified.<br> 416 <br> 417Args:<br> 418 selector: A CSS selector describing the element.<br> 419 text: The element must contains this exact text.<br> 420 element_function: A JavaScript function (as string) that is used<br> 421 to retrieve the element. For example:<br> 422 'function() { return foo.element; }'.<br> 423 left_start_ratio: The horizontal starting coordinate of the<br> 424 gesture, as a ratio of the visible bounding rectangle for<br> 425 the element.<br> 426 top_start_ratio: The vertical starting coordinate of the<br> 427 gesture, as a ratio of the visible bounding rectangle for<br> 428 the element.<br> 429 direction: The direction of swipe, either 'left', 'right',<br> 430 'up', or 'down'<br> 431 distance: The distance to swipe (in pixel).<br> 432 speed_in_pixels_per_second: The speed of the gesture (in pixels/s).</tt></dd></dl> 433 434<dl><dt><a name="ActionRunner-SwipePage"><strong>SwipePage</strong></a>(self, left_start_ratio<font color="#909090">=0.5</font>, top_start_ratio<font color="#909090">=0.5</font>, direction<font color="#909090">='left'</font>, distance<font color="#909090">=100</font>, speed_in_pixels_per_second<font color="#909090">=800</font>)</dt><dd><tt>Perform swipe gesture on the page.<br> 435 <br> 436Args:<br> 437 left_start_ratio: The horizontal starting coordinate of the<br> 438 gesture, as a ratio of the visible bounding rectangle for<br> 439 document.body.<br> 440 top_start_ratio: The vertical starting coordinate of the<br> 441 gesture, as a ratio of the visible bounding rectangle for<br> 442 document.body.<br> 443 direction: The direction of swipe, either 'left', 'right',<br> 444 'up', or 'down'<br> 445 distance: The distance to swipe (in pixel).<br> 446 speed_in_pixels_per_second: The speed of the gesture (in pixels/s).</tt></dd></dl> 447 448<dl><dt><a name="ActionRunner-TapElement"><strong>TapElement</strong></a>(self, selector<font color="#909090">=None</font>, text<font color="#909090">=None</font>, element_function<font color="#909090">=None</font>)</dt><dd><tt>Tap an element.<br> 449 <br> 450The element may be selected via selector, text, or element_function.<br> 451Only one of these arguments must be specified.<br> 452 <br> 453Args:<br> 454 selector: A CSS selector describing the element.<br> 455 text: The element must contains this exact text.<br> 456 element_function: A JavaScript function (as string) that is used<br> 457 to retrieve the element. For example:<br> 458 '(function() { return foo.element; })()'.</tt></dd></dl> 459 460<dl><dt><a name="ActionRunner-Wait"><strong>Wait</strong></a>(self, seconds)</dt><dd><tt>Wait for the number of seconds specified.<br> 461 <br> 462Args:<br> 463 seconds: The number of seconds to wait.</tt></dd></dl> 464 465<dl><dt><a name="ActionRunner-WaitForElement"><strong>WaitForElement</strong></a>(self, selector<font color="#909090">=None</font>, text<font color="#909090">=None</font>, element_function<font color="#909090">=None</font>, timeout_in_seconds<font color="#909090">=60</font>)</dt><dd><tt>Wait for an element to appear in the document.<br> 466 <br> 467The element may be selected via selector, text, or element_function.<br> 468Only one of these arguments must be specified.<br> 469 <br> 470Args:<br> 471 selector: A CSS selector describing the element.<br> 472 text: The element must contains this exact text.<br> 473 element_function: A JavaScript function (as string) that is used<br> 474 to retrieve the element. For example:<br> 475 '(function() { return foo.element; })()'.<br> 476 timeout_in_seconds: The timeout in seconds (default to 60).</tt></dd></dl> 477 478<dl><dt><a name="ActionRunner-WaitForJavaScriptCondition"><strong>WaitForJavaScriptCondition</strong></a>(self, condition, timeout_in_seconds<font color="#909090">=60</font>)</dt><dd><tt>Wait for a JavaScript condition to become true.<br> 479 <br> 480Example: runner.<a href="#ActionRunner-WaitForJavaScriptCondition">WaitForJavaScriptCondition</a>('window.foo == 10');<br> 481 <br> 482Args:<br> 483 condition: The JavaScript condition (as string).<br> 484 timeout_in_seconds: The timeout in seconds (default to 60).</tt></dd></dl> 485 486<dl><dt><a name="ActionRunner-WaitForNavigate"><strong>WaitForNavigate</strong></a>(self, timeout_in_seconds_seconds<font color="#909090">=60</font>)</dt></dl> 487 488<dl><dt><a name="ActionRunner-__init__"><strong>__init__</strong></a>(self, tab, skip_waits<font color="#909090">=False</font>)</dt></dl> 489 490<hr> 491Data descriptors defined here:<br> 492<dl><dt><strong>__dict__</strong></dt> 493<dd><tt>dictionary for instance variables (if defined)</tt></dd> 494</dl> 495<dl><dt><strong>__weakref__</strong></dt> 496<dd><tt>list of weak references to the object (if defined)</tt></dd> 497</dl> 498<dl><dt><strong>tab</strong></dt> 499<dd><tt>Returns the tab on which actions are performed.</tt></dd> 500</dl> 501</td></tr></table> <p> 502<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 503<tr bgcolor="#ffc8d8"> 504<td colspan=3 valign=bottom> <br> 505<font color="#000000" face="helvetica, arial"><a name="Interaction">class <strong>Interaction</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> 506 507<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> 508<td width="100%">Methods defined here:<br> 509<dl><dt><a name="Interaction-Begin"><strong>Begin</strong></a>(self)</dt></dl> 510 511<dl><dt><a name="Interaction-End"><strong>End</strong></a>(self)</dt></dl> 512 513<dl><dt><a name="Interaction-__enter__"><strong>__enter__</strong></a>(self)</dt></dl> 514 515<dl><dt><a name="Interaction-__exit__"><strong>__exit__</strong></a>(self, exc_type, exc_value, traceback)</dt></dl> 516 517<dl><dt><a name="Interaction-__init__"><strong>__init__</strong></a>(self, action_runner, label, flags)</dt></dl> 518 519<hr> 520Data descriptors defined here:<br> 521<dl><dt><strong>__dict__</strong></dt> 522<dd><tt>dictionary for instance variables (if defined)</tt></dd> 523</dl> 524<dl><dt><strong>__weakref__</strong></dt> 525<dd><tt>list of weak references to the object (if defined)</tt></dd> 526</dl> 527</td></tr></table></td></tr></table><p> 528<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 529<tr bgcolor="#55aa55"> 530<td colspan=3 valign=bottom> <br> 531<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr> 532 533<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td> 534<td width="100%"><strong>GESTURE_SOURCE_DEFAULT</strong> = 'DEFAULT'<br> 535<strong>SUPPORTED_GESTURE_SOURCES</strong> = ('DEFAULT', 'MOUSE', 'TOUCH')</td></tr></table> 536</body></html>