<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><title>Python: module telemetry.internal.browser.web_contents</title> <meta charset="utf-8"> </head><body bgcolor="#f0f0f8"> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> <tr bgcolor="#7799ee"> <td valign=bottom> <br> <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 ><td align=right valign=bottom ><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> <p><tt># Copyright 2012 The Chromium Authors. All rights reserved.<br> # Use of this source code is governed by a BSD-style license that can be<br> # found in the LICENSE file.</tt></p> <p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#aa55cc"> <td colspan=3 valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr> <tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td> <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> </td><td width="25%" valign=top><a href="os.html">os</a><br> </td><td width="25%" valign=top><a href="telemetry.core.util.html">telemetry.core.util</a><br> </td><td width="25%" valign=top></td></tr></table></td></tr></table><p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ee77aa"> <td colspan=3 valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr> <tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td> <td width="100%"><dl> <dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a> </font></dt><dd> <dl> <dt><font face="helvetica, arial"><a href="telemetry.internal.browser.web_contents.html#WebContents">WebContents</a> </font></dt></dl> </dd> </dl> <p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <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> <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> <td colspan=2><tt>Represents web contents in the browser<br> </tt></td></tr> <tr><td> </td> <td width="100%">Methods defined here:<br> <dl><dt><a name="WebContents-CloseConnections"><strong>CloseConnections</strong></a>(self)</dt><dd><tt>Closes all TCP sockets held open by the browser.<br> <br> Raises:<br> exceptions.DevtoolsTargetCrashException if the tab is not alive.</tt></dd></dl> <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> <br> Raises:<br> exceptions.WebSocketDisconnected<br> exceptions.TimeoutException<br> exceptions.DevtoolsTargetCrashException</tt></dd></dl> <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> <br> Consider using ExecuteJavaScript for cases where the result of the<br> expression is not needed.<br> <br> If evaluation throws in JavaScript, a Python EvaluateException will<br> be raised.<br> <br> If the result of the evaluation cannot be JSONized, then an<br> EvaluationException will be raised.<br> <br> Raises:<br> exceptions.Error: See <a href="#WebContents-EvaluateJavaScriptInContext">EvaluateJavaScriptInContext</a>() for a detailed list<br> of possible exceptions.</tt></dd></dl> <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> The main page has context_id=1, the first iframe context_id=2, etc.<br> <br> Raises:<br> exceptions.EvaluateException<br> exceptions.WebSocketDisconnected<br> exceptions.TimeoutException<br> exceptions.DevtoolsTargetCrashException</tt></dd></dl> <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> <br> If the statement failed to evaluate, EvaluateException will be raised.<br> <br> Raises:<br> exceptions.Error: See <a href="#WebContents-ExecuteJavaScriptInContext">ExecuteJavaScriptInContext</a>() for a detailed list of<br> possible exceptions.</tt></dd></dl> <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> The main page has context_id=1, the first iframe context_id=2, etc.<br> <br> Raises:<br> exceptions.EvaluateException<br> exceptions.WebSocketDisconnected<br> exceptions.TimeoutException<br> exceptions.DevtoolsTargetCrashException</tt></dd></dl> <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> <br> Raises:<br> exceptions.Error: If there is an error in inspector backend connection.</tt></dd></dl> <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> <br> Returns:<br> A list of <a href="#WebContents">WebContents</a> objects representing the webview contexts.<br> <br> Raises:<br> exceptions.Error: If there is an error in inspector backend connection.</tt></dd></dl> <dl><dt><a name="WebContents-HasReachedQuiescence"><strong>HasReachedQuiescence</strong></a>(self)</dt><dd><tt>Determine whether the page has reached quiescence after loading.<br> <br> Returns:<br> True if 2 seconds have passed since last resource received, false<br> otherwise.<br> Raises:<br> exceptions.Error: See <a href="#WebContents-EvaluateJavaScript">EvaluateJavaScript</a>() for a detailed list of<br> possible exceptions.</tt></dd></dl> <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> <br> Since <a href="#WebContents">WebContents</a> function asynchronously, this method does not guarantee<br> that the <a href="#WebContents">WebContents</a> will still be alive at any point in the future.<br> <br> Returns:<br> A boolean indicating whether the <a href="#WebContents">WebContents</a> is opearting normally.</tt></dd></dl> <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> <br> If |script_to_evaluate_on_commit| is given, the script source string will be<br> evaluated when the navigation is committed. This is after the context of<br> the page exists, but before any script on the page itself has executed.<br> <br> Raises:<br> exceptions.TimeoutException<br> exceptions.DevtoolsTargetCrashException</tt></dd></dl> <dl><dt><a name="WebContents-StartTimelineRecording"><strong>StartTimelineRecording</strong></a>(self)</dt><dd><tt>Starts timeline recording.<br> <br> Raises:<br> exceptions.TimeoutException<br> exceptions.DevtoolsTargetCrashException</tt></dd></dl> <dl><dt><a name="WebContents-StopTimelineRecording"><strong>StopTimelineRecording</strong></a>(self)</dt><dd><tt>Stops timeline recording.<br> <br> Raises:<br> exceptions.TimeoutException<br> exceptions.DevtoolsTargetCrashException</tt></dd></dl> <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> <br> Args:<br> x: X coordinate of the start of the gesture in CSS pixels.<br> y: Y coordinate of the start of the gesture in CSS pixels.<br> xDistance: Distance to scroll along the X axis (positive to scroll left).<br> yDistance: Ddistance to scroll along the Y axis (positive to scroll up).<br> xOverscroll: Number of additional pixels to scroll back along the X axis.<br> xOverscroll: Number of additional pixels to scroll back along the Y axis.<br> preventFling: Prevents a fling gesture.<br> speed: Swipe speed in pixels per second.<br> gestureSourceType: Which type of input events to be generated.<br> repeatCount: Number of additional repeats beyond the first scroll.<br> repeatDelayMs: Number of milliseconds delay between each repeat.<br> interactionMarkerName: The name of the interaction markers to generate.<br> <br> Raises:<br> exceptions.TimeoutException<br> exceptions.DevtoolsTargetCrashException</tt></dd></dl> <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> <br> Raises:<br> exceptions.Error: See <a href="#WebContents-WaitForJavaScriptExpression">WaitForJavaScriptExpression</a>() for a detailed list<br> of possible exceptions.</tt></dd></dl> <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> <br> Raises:<br> exceptions.Error: See <a href="#WebContents-WaitForJavaScriptExpression">WaitForJavaScriptExpression</a>() for a detailed list<br> of possible exceptions.</tt></dd></dl> <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> <br> This method is robust against any given Evaluation timing out.<br> <br> Args:<br> expr: The expression to evaluate.<br> timeout: The number of seconds to wait for the expression to be True.<br> dump_page_state_on_timeout: Whether to provide additional information on<br> the page state if a TimeoutException is thrown.<br> <br> Raises:<br> exceptions.TimeoutException: On a timeout.<br> exceptions.Error: See <a href="#WebContents-EvaluateJavaScript">EvaluateJavaScript</a>() for a detailed list of<br> possible exceptions.</tt></dd></dl> <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> <br> The current page is expect to be in a navigation.<br> This function returns when the navigation is complete or when<br> the timeout has been exceeded.<br> <br> Raises:<br> exceptions.TimeoutException<br> exceptions.DevtoolsTargetCrashException</tt></dd></dl> <dl><dt><a name="WebContents-__init__"><strong>__init__</strong></a>(self, inspector_backend)</dt></dl> <hr> Data descriptors defined here:<br> <dl><dt><strong>__dict__</strong></dt> <dd><tt>dictionary for instance variables (if defined)</tt></dd> </dl> <dl><dt><strong>__weakref__</strong></dt> <dd><tt>list of weak references to the object (if defined)</tt></dd> </dl> <dl><dt><strong>id</strong></dt> <dd><tt>Return the unique id string for this tab object.</tt></dd> </dl> <dl><dt><strong>message_output_stream</strong></dt> </dl> <dl><dt><strong>timeline_model</strong></dt> </dl> </td></tr></table></td></tr></table><p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#55aa55"> <td colspan=3 valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr> <tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td> <td width="100%"><strong>DEFAULT_WEB_CONTENTS_TIMEOUT</strong> = 90</td></tr></table> </body></html>