1 2<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 3<html><head><title>Python: module telemetry.internal.browser.web_contents</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.internal.html"><font color="#ffffff">internal</font></a>.<a href="telemetry.internal.browser.html"><font color="#ffffff">browser</font></a>.web_contents</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/internal/browser/web_contents.py">telemetry/internal/browser/web_contents.py</a></font></td></tr></table> 13 <p><tt># Copyright 2012 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="telemetry.core.exceptions.html">telemetry.core.exceptions</a><br> 24</td><td width="25%" valign=top><a href="os.html">os</a><br> 25</td><td width="25%" valign=top><a href="telemetry.core.util.html">telemetry.core.util</a><br> 26</td><td width="25%" valign=top></td></tr></table></td></tr></table><p> 27<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 28<tr bgcolor="#ee77aa"> 29<td colspan=3 valign=bottom> <br> 30<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr> 31 32<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td> 33<td width="100%"><dl> 34<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a> 35</font></dt><dd> 36<dl> 37<dt><font face="helvetica, arial"><a href="telemetry.internal.browser.web_contents.html#WebContents">WebContents</a> 38</font></dt></dl> 39</dd> 40</dl> 41 <p> 42<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 43<tr bgcolor="#ffc8d8"> 44<td colspan=3 valign=bottom> <br> 45<font color="#000000" face="helvetica, arial"><a name="WebContents">class <strong>WebContents</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> 46 47<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> 48<td colspan=2><tt>Represents web contents in the browser<br> </tt></td></tr> 49<tr><td> </td> 50<td width="100%">Methods defined here:<br> 51<dl><dt><a name="WebContents-CloseConnections"><strong>CloseConnections</strong></a>(self)</dt><dd><tt>Closes all TCP sockets held open by the browser.<br> 52 <br> 53Raises:<br> 54 exceptions.DevtoolsTargetCrashException if the tab is not alive.</tt></dd></dl> 55 56<dl><dt><a name="WebContents-EnableAllContexts"><strong>EnableAllContexts</strong></a>(self)</dt><dd><tt>Enable all contexts in a page. Returns the number of available contexts.<br> 57 <br> 58Raises:<br> 59 exceptions.WebSocketDisconnected<br> 60 exceptions.TimeoutException<br> 61 exceptions.DevtoolsTargetCrashException</tt></dd></dl> 62 63<dl><dt><a name="WebContents-EvaluateJavaScript"><strong>EvaluateJavaScript</strong></a>(self, expr, timeout<font color="#909090">=90</font>)</dt><dd><tt>Evalutes expr in JavaScript and returns the JSONized result.<br> 64 <br> 65Consider using ExecuteJavaScript for cases where the result of the<br> 66expression is not needed.<br> 67 <br> 68If evaluation throws in JavaScript, a Python EvaluateException will<br> 69be raised.<br> 70 <br> 71If the result of the evaluation cannot be JSONized, then an<br> 72EvaluationException will be raised.<br> 73 <br> 74Raises:<br> 75 exceptions.Error: See <a href="#WebContents-EvaluateJavaScriptInContext">EvaluateJavaScriptInContext</a>() for a detailed list<br> 76 of possible exceptions.</tt></dd></dl> 77 78<dl><dt><a name="WebContents-EvaluateJavaScriptInContext"><strong>EvaluateJavaScriptInContext</strong></a>(self, expr, context_id, timeout<font color="#909090">=90</font>)</dt><dd><tt>Similar to ExecuteJavaScript, except context_id can refer to an iframe.<br> 79The main page has context_id=1, the first iframe context_id=2, etc.<br> 80 <br> 81Raises:<br> 82 exceptions.EvaluateException<br> 83 exceptions.WebSocketDisconnected<br> 84 exceptions.TimeoutException<br> 85 exceptions.DevtoolsTargetCrashException</tt></dd></dl> 86 87<dl><dt><a name="WebContents-ExecuteJavaScript"><strong>ExecuteJavaScript</strong></a>(self, statement, timeout<font color="#909090">=90</font>)</dt><dd><tt>Executes statement in JavaScript. Does not return the result.<br> 88 <br> 89If the statement failed to evaluate, EvaluateException will be raised.<br> 90 <br> 91Raises:<br> 92 exceptions.Error: See <a href="#WebContents-ExecuteJavaScriptInContext">ExecuteJavaScriptInContext</a>() for a detailed list of<br> 93 possible exceptions.</tt></dd></dl> 94 95<dl><dt><a name="WebContents-ExecuteJavaScriptInContext"><strong>ExecuteJavaScriptInContext</strong></a>(self, expr, context_id, timeout<font color="#909090">=90</font>)</dt><dd><tt>Similar to ExecuteJavaScript, except context_id can refer to an iframe.<br> 96The main page has context_id=1, the first iframe context_id=2, etc.<br> 97 <br> 98Raises:<br> 99 exceptions.EvaluateException<br> 100 exceptions.WebSocketDisconnected<br> 101 exceptions.TimeoutException<br> 102 exceptions.DevtoolsTargetCrashException</tt></dd></dl> 103 104<dl><dt><a name="WebContents-GetUrl"><strong>GetUrl</strong></a>(self)</dt><dd><tt>Returns the URL to which the <a href="#WebContents">WebContents</a> is connected.<br> 105 <br> 106Raises:<br> 107 exceptions.Error: If there is an error in inspector backend connection.</tt></dd></dl> 108 109<dl><dt><a name="WebContents-GetWebviewContexts"><strong>GetWebviewContexts</strong></a>(self)</dt><dd><tt>Returns a list of webview contexts within the current inspector backend.<br> 110 <br> 111Returns:<br> 112 A list of <a href="#WebContents">WebContents</a> objects representing the webview contexts.<br> 113 <br> 114Raises:<br> 115 exceptions.Error: If there is an error in inspector backend connection.</tt></dd></dl> 116 117<dl><dt><a name="WebContents-HasReachedQuiescence"><strong>HasReachedQuiescence</strong></a>(self)</dt><dd><tt>Determine whether the page has reached quiescence after loading.<br> 118 <br> 119Returns:<br> 120 True if 2 seconds have passed since last resource received, false<br> 121 otherwise.<br> 122Raises:<br> 123 exceptions.Error: See <a href="#WebContents-EvaluateJavaScript">EvaluateJavaScript</a>() for a detailed list of<br> 124 possible exceptions.</tt></dd></dl> 125 126<dl><dt><a name="WebContents-IsAlive"><strong>IsAlive</strong></a>(self)</dt><dd><tt>Whether the <a href="#WebContents">WebContents</a> is still operating normally.<br> 127 <br> 128Since <a href="#WebContents">WebContents</a> function asynchronously, this method does not guarantee<br> 129that the <a href="#WebContents">WebContents</a> will still be alive at any point in the future.<br> 130 <br> 131Returns:<br> 132 A boolean indicating whether the <a href="#WebContents">WebContents</a> is opearting normally.</tt></dd></dl> 133 134<dl><dt><a name="WebContents-Navigate"><strong>Navigate</strong></a>(self, url, script_to_evaluate_on_commit<font color="#909090">=None</font>, timeout<font color="#909090">=90</font>)</dt><dd><tt>Navigates to url.<br> 135 <br> 136If |script_to_evaluate_on_commit| is given, the script source string will be<br> 137evaluated when the navigation is committed. This is after the context of<br> 138the page exists, but before any script on the page itself has executed.<br> 139 <br> 140Raises:<br> 141 exceptions.TimeoutException<br> 142 exceptions.DevtoolsTargetCrashException</tt></dd></dl> 143 144<dl><dt><a name="WebContents-StartTimelineRecording"><strong>StartTimelineRecording</strong></a>(self)</dt><dd><tt>Starts timeline recording.<br> 145 <br> 146Raises:<br> 147 exceptions.TimeoutException<br> 148 exceptions.DevtoolsTargetCrashException</tt></dd></dl> 149 150<dl><dt><a name="WebContents-StopTimelineRecording"><strong>StopTimelineRecording</strong></a>(self)</dt><dd><tt>Stops timeline recording.<br> 151 <br> 152Raises:<br> 153 exceptions.TimeoutException<br> 154 exceptions.DevtoolsTargetCrashException</tt></dd></dl> 155 156<dl><dt><a name="WebContents-SynthesizeScrollGesture"><strong>SynthesizeScrollGesture</strong></a>(self, x<font color="#909090">=100</font>, y<font color="#909090">=800</font>, xDistance<font color="#909090">=0</font>, yDistance<font color="#909090">=-500</font>, xOverscroll<font color="#909090">=None</font>, yOverscroll<font color="#909090">=None</font>, preventFling<font color="#909090">=True</font>, speed<font color="#909090">=None</font>, gestureSourceType<font color="#909090">=None</font>, repeatCount<font color="#909090">=None</font>, repeatDelayMs<font color="#909090">=None</font>, interactionMarkerName<font color="#909090">=None</font>)</dt><dd><tt>Runs an inspector command that causes a repeatable browser driven scroll.<br> 157 <br> 158Args:<br> 159 x: X coordinate of the start of the gesture in CSS pixels.<br> 160 y: Y coordinate of the start of the gesture in CSS pixels.<br> 161 xDistance: Distance to scroll along the X axis (positive to scroll left).<br> 162 yDistance: Ddistance to scroll along the Y axis (positive to scroll up).<br> 163 xOverscroll: Number of additional pixels to scroll back along the X axis.<br> 164 xOverscroll: Number of additional pixels to scroll back along the Y axis.<br> 165 preventFling: Prevents a fling gesture.<br> 166 speed: Swipe speed in pixels per second.<br> 167 gestureSourceType: Which type of input events to be generated.<br> 168 repeatCount: Number of additional repeats beyond the first scroll.<br> 169 repeatDelayMs: Number of milliseconds delay between each repeat.<br> 170 interactionMarkerName: The name of the interaction markers to generate.<br> 171 <br> 172Raises:<br> 173 exceptions.TimeoutException<br> 174 exceptions.DevtoolsTargetCrashException</tt></dd></dl> 175 176<dl><dt><a name="WebContents-WaitForDocumentReadyStateToBeComplete"><strong>WaitForDocumentReadyStateToBeComplete</strong></a>(self, timeout<font color="#909090">=90</font>)</dt><dd><tt>Waits for the document to finish loading.<br> 177 <br> 178Raises:<br> 179 exceptions.Error: See <a href="#WebContents-WaitForJavaScriptExpression">WaitForJavaScriptExpression</a>() for a detailed list<br> 180 of possible exceptions.</tt></dd></dl> 181 182<dl><dt><a name="WebContents-WaitForDocumentReadyStateToBeInteractiveOrBetter"><strong>WaitForDocumentReadyStateToBeInteractiveOrBetter</strong></a>(self, timeout<font color="#909090">=90</font>)</dt><dd><tt>Waits for the document to be interactive.<br> 183 <br> 184Raises:<br> 185 exceptions.Error: See <a href="#WebContents-WaitForJavaScriptExpression">WaitForJavaScriptExpression</a>() for a detailed list<br> 186 of possible exceptions.</tt></dd></dl> 187 188<dl><dt><a name="WebContents-WaitForJavaScriptExpression"><strong>WaitForJavaScriptExpression</strong></a>(self, expr, timeout, dump_page_state_on_timeout<font color="#909090">=True</font>)</dt><dd><tt>Waits for the given JavaScript expression to be True.<br> 189 <br> 190This method is robust against any given Evaluation timing out.<br> 191 <br> 192Args:<br> 193 expr: The expression to evaluate.<br> 194 timeout: The number of seconds to wait for the expression to be True.<br> 195 dump_page_state_on_timeout: Whether to provide additional information on<br> 196 the page state if a TimeoutException is thrown.<br> 197 <br> 198Raises:<br> 199 exceptions.TimeoutException: On a timeout.<br> 200 exceptions.Error: See <a href="#WebContents-EvaluateJavaScript">EvaluateJavaScript</a>() for a detailed list of<br> 201 possible exceptions.</tt></dd></dl> 202 203<dl><dt><a name="WebContents-WaitForNavigate"><strong>WaitForNavigate</strong></a>(self, timeout<font color="#909090">=90</font>)</dt><dd><tt>Waits for the navigation to complete.<br> 204 <br> 205The current page is expect to be in a navigation.<br> 206This function returns when the navigation is complete or when<br> 207the timeout has been exceeded.<br> 208 <br> 209Raises:<br> 210 exceptions.TimeoutException<br> 211 exceptions.DevtoolsTargetCrashException</tt></dd></dl> 212 213<dl><dt><a name="WebContents-__init__"><strong>__init__</strong></a>(self, inspector_backend)</dt></dl> 214 215<hr> 216Data descriptors defined here:<br> 217<dl><dt><strong>__dict__</strong></dt> 218<dd><tt>dictionary for instance variables (if defined)</tt></dd> 219</dl> 220<dl><dt><strong>__weakref__</strong></dt> 221<dd><tt>list of weak references to the object (if defined)</tt></dd> 222</dl> 223<dl><dt><strong>id</strong></dt> 224<dd><tt>Return the unique id string for this tab object.</tt></dd> 225</dl> 226<dl><dt><strong>message_output_stream</strong></dt> 227</dl> 228<dl><dt><strong>timeline_model</strong></dt> 229</dl> 230</td></tr></table></td></tr></table><p> 231<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 232<tr bgcolor="#55aa55"> 233<td colspan=3 valign=bottom> <br> 234<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr> 235 236<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td> 237<td width="100%"><strong>DEFAULT_WEB_CONTENTS_TIMEOUT</strong> = 90</td></tr></table> 238</body></html>