telemetry.internal.browser.tab | index telemetry/internal/browser/tab.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.internal.image_processing.video | telemetry.internal.browser.web_contents |  |

Classes
`` |  |

telemetry.internal.browser.web_contents.WebContents(__builtin__.object)
  Tab

class Tab(telemetry.internal.browser.web_contents.WebContents)
`` | `Represents a tab in the browser The important parts of the Tab object are in the runtime and page objects. E.g.: # Navigates the tab to a given url. tab.Navigate('http://www.google.com/')
# Evaluates 1+1 in the tab's JavaScript context.
tab.Evaluate('1+1')
`

Method resolution order:
  Tab
  telemetry.internal.browser.web_contents.WebContents
  __builtin__.object

Methods defined here:

Activate(self)
  `Brings this tab to the foreground asynchronously.
  Not all browsers or browser versions support this method.
  Be sure to check browser.supports_tab_control.
  Please note: this is asynchronous. There is a delay between this call
  and the page's documentVisibilityState becoming 'visible', and yet more
  delay until the actual tab is visible to the user. None of these delays
  are included in this call.
  Raises:
  devtools_http.DevToolsClientConnectionError
  devtools_client_backend.TabNotFoundError
  tab_list_backend.TabUnexpectedResponseException`

ClearCache(self, force)
  `Clears the browser's networking related disk, memory and other caches.
  Args:
  force: Iff true, navigates to about:blank which destroys the previous
  renderer, ensuring that even "live" resources in the memory cache are
  cleared.
  Raises:
  exceptions.EvaluateException
  exceptions.WebSocketDisconnected
  exceptions.TimeoutException
  exceptions.DevtoolsTargetCrashException
  errors.DeviceUnresponsiveError`

ClearHighlight(self, color)
  `Clears a highlight of the given bitmap.RgbaColor.
  Raises:
  exceptions.EvaluateException
  exceptions.WebSocketDisconnected
  exceptions.TimeoutException
  exceptions.DevtoolsTargetCrashException`

Close(self)
  `Closes this tab.
  Not all browsers or browser versions support this method.
  Be sure to check browser.supports_tab_control.
  Raises:
  devtools_http.DevToolsClientConnectionError
  devtools_client_backend.TabNotFoundError
  tab_list_backend.TabUnexpectedResponseException
  exceptions.TimeoutException`

CollectGarbage(self)
  `Forces a garbage collection.
  Raises:
  exceptions.WebSocketDisconnected
  exceptions.TimeoutException
  exceptions.DevtoolsTargetCrashException`

GetCookieByName(self, name, timeout=60)
  `Returns the value of the cookie by the given |name|.
  Raises:
  exceptions.WebSocketDisconnected
  exceptions.TimeoutException
  exceptions.DevtoolsTargetCrashException`

Highlight(self, color)
  `Synchronously highlights entire tab contents with the given RgbaColor.
  TODO(tonyg): It is possible that the z-index hack here might not work for
  all pages. If this happens, DevTools also provides a method for this.
  Raises:
  exceptions.EvaluateException
  exceptions.WebSocketDisconnected
  exceptions.TimeoutException
  exceptions.DevtoolsTargetCrashException`

Screenshot(self, timeout=60)
  `Capture a screenshot of the tab's contents.
  Returns:
  A telemetry.core.Bitmap.
  Raises:
  exceptions.WebSocketDisconnected
  exceptions.TimeoutException
  exceptions.DevtoolsTargetCrashException`

StartVideoCapture(self, min_bitrate_mbps, highlight_bitmap=RgbaColor(r=222, g=100, b=13, a=255))
  `Starts capturing video of the tab's contents.
  This works by flashing the entire tab contents to a arbitrary color and then
  starting video recording. When the frames are processed, we can look for
  that flash as the content bounds.
  Args:
  min_bitrate_mbps: The minimum caputre bitrate in MegaBits Per Second.
  The platform is free to deliver a higher bitrate if it can do so
  without increasing overhead.
  Raises:
  exceptions.EvaluateException
  exceptions.WebSocketDisconnected
  exceptions.TimeoutException
  exceptions.DevtoolsTargetCrashException
  ValueError: If the required |min_bitrate_mbps| can't be achieved.`

StopVideoCapture(self)
  `Stops recording video of the tab's contents.
  This looks for the initial color flash in the first frame to establish the
  tab content boundaries and then omits all frames displaying the flash.
  Returns:
  video: A video object which is a telemetry.core.Video`

__init__(self, inspector_backend, tab_list_backend, browser)

Data descriptors defined here:

browser
  `The browser in which this tab resides.`

dom_stats
  `A dictionary populated with measured DOM statistics.
  Currently this dictionary contains:
  {
  'document_count': integer,
  'node_count': integer,
  'event_listener_count': integer
  }
  Raises:
  inspector_memory.InspectorMemoryException
  exceptions.TimeoutException
  exceptions.DevtoolsTargetCrashException`

is_video_capture_running

screenshot_supported
  `True if the browser instance is capable of capturing screenshots.`

url
  `Returns the URL of the tab, as reported by devtools.
  Raises:
  devtools_http.DevToolsClientConnectionError`

video_capture_supported
  `True if the browser instance is capable of capturing video.`

Methods inherited from telemetry.internal.browser.web_contents.WebContents:

CloseConnections(self)
  `Closes all TCP sockets held open by the browser.
  Raises:
  exceptions.DevtoolsTargetCrashException if the tab is not alive.`

EnableAllContexts(self)
  `Enable all contexts in a page. Returns the number of available contexts.
  Raises:
  exceptions.WebSocketDisconnected
  exceptions.TimeoutException
  exceptions.DevtoolsTargetCrashException`

EvaluateJavaScript(self, expr, timeout=90)
  `Evalutes expr in JavaScript and returns the JSONized result.
  Consider using ExecuteJavaScript for cases where the result of the
  expression is not needed.
  If evaluation throws in JavaScript, a Python EvaluateException will
  be raised.
  If the result of the evaluation cannot be JSONized, then an
  EvaluationException will be raised.
  Raises:
  exceptions.Error: See EvaluateJavaScriptInContext() for a detailed list
  of possible exceptions.`

EvaluateJavaScriptInContext(self, expr, context_id, timeout=90)
  `Similar to ExecuteJavaScript, except context_id can refer to an iframe.
  The main page has context_id=1, the first iframe context_id=2, etc.
  Raises:
  exceptions.EvaluateException
  exceptions.WebSocketDisconnected
  exceptions.TimeoutException
  exceptions.DevtoolsTargetCrashException`

ExecuteJavaScript(self, statement, timeout=90)
  `Executes statement in JavaScript. Does not return the result.
  If the statement failed to evaluate, EvaluateException will be raised.
  Raises:
  exceptions.Error: See ExecuteJavaScriptInContext() for a detailed list of
  possible exceptions.`

ExecuteJavaScriptInContext(self, expr, context_id, timeout=90)
  `Similar to ExecuteJavaScript, except context_id can refer to an iframe.
  The main page has context_id=1, the first iframe context_id=2, etc.
  Raises:
  exceptions.EvaluateException
  exceptions.WebSocketDisconnected
  exceptions.TimeoutException
  exceptions.DevtoolsTargetCrashException`

GetUrl(self)
  `Returns the URL to which the WebContents is connected.
  Raises:
  exceptions.Error: If there is an error in inspector backend connection.`

GetWebviewContexts(self)
  `Returns a list of webview contexts within the current inspector backend.
  Returns:
  A list of WebContents objects representing the webview contexts.
  Raises:
  exceptions.Error: If there is an error in inspector backend connection.`

HasReachedQuiescence(self)
  `Determine whether the page has reached quiescence after loading.
  Returns:
  True if 2 seconds have passed since last resource received, false
  otherwise.
  Raises:
  exceptions.Error: See EvaluateJavaScript() for a detailed list of
  possible exceptions.`

IsAlive(self)
  `Whether the WebContents is still operating normally.
  Since WebContents function asynchronously, this method does not guarantee
  that the WebContents will still be alive at any point in the future.
  Returns:
  A boolean indicating whether the WebContents is opearting normally.`

Navigate(self, url, script_to_evaluate_on_commit=None, timeout=90)
  `Navigates to url.
  If |script_to_evaluate_on_commit| is given, the script source string will be
  evaluated when the navigation is committed. This is after the context of
  the page exists, but before any script on the page itself has executed.
  Raises:
  exceptions.TimeoutException
  exceptions.DevtoolsTargetCrashException`

StartTimelineRecording(self)
  `Starts timeline recording.
  Raises:
  exceptions.TimeoutException
  exceptions.DevtoolsTargetCrashException`

StopTimelineRecording(self)
  `Stops timeline recording.
  Raises:
  exceptions.TimeoutException
  exceptions.DevtoolsTargetCrashException`

SynthesizeScrollGesture(self, x=100, y=800, xDistance=0, yDistance=-500, xOverscroll=None, yOverscroll=None, preventFling=True, speed=None, gestureSourceType=None, repeatCount=None, repeatDelayMs=None, interactionMarkerName=None)
  `Runs an inspector command that causes a repeatable browser driven scroll.
  Args:
  x: X coordinate of the start of the gesture in CSS pixels.
  y: Y coordinate of the start of the gesture in CSS pixels.
  xDistance: Distance to scroll along the X axis (positive to scroll left).
  yDistance: Ddistance to scroll along the Y axis (positive to scroll up).
  xOverscroll: Number of additional pixels to scroll back along the X axis.
  xOverscroll: Number of additional pixels to scroll back along the Y axis.
  preventFling: Prevents a fling gesture.
  speed: Swipe speed in pixels per second.
  gestureSourceType: Which type of input events to be generated.
  repeatCount: Number of additional repeats beyond the first scroll.
  repeatDelayMs: Number of milliseconds delay between each repeat.
  interactionMarkerName: The name of the interaction markers to generate.
  Raises:
  exceptions.TimeoutException
  exceptions.DevtoolsTargetCrashException`

WaitForDocumentReadyStateToBeComplete(self, timeout=90)
  `Waits for the document to finish loading.
  Raises:
  exceptions.Error: See WaitForJavaScriptExpression() for a detailed list
  of possible exceptions.`

WaitForDocumentReadyStateToBeInteractiveOrBetter(self, timeout=90)
  `Waits for the document to be interactive.
  Raises:
  exceptions.Error: See WaitForJavaScriptExpression() for a detailed list
  of possible exceptions.`

WaitForJavaScriptExpression(self, expr, timeout, dump_page_state_on_timeout=True)
  `Waits for the given JavaScript expression to be True.
  This method is robust against any given Evaluation timing out.
  Args:
  expr: The expression to evaluate.
  timeout: The number of seconds to wait for the expression to be True.
  dump_page_state_on_timeout: Whether to provide additional information on
  the page state if a TimeoutException is thrown.
  Raises:
  exceptions.TimeoutException: On a timeout.
  exceptions.Error: See EvaluateJavaScript() for a detailed list of
  possible exceptions.`

WaitForNavigate(self, timeout=90)
  `Waits for the navigation to complete.
  The current page is expect to be in a navigation.
  This function returns when the navigation is complete or when
  the timeout has been exceeded.
  Raises:
  exceptions.TimeoutException
  exceptions.DevtoolsTargetCrashException`

Data descriptors inherited from telemetry.internal.browser.web_contents.WebContents:

__dict__
  `dictionary for instance variables (if defined)`

__weakref__
  `list of weak references to the object (if defined)`

id
  `Return the unique id string for this tab object.`

message_output_stream

timeline_model

Data
`` |  | DEFAULT_TAB_TIMEOUT = 60