Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: tools/telemetry/telemetry/tab.py

Issue 12278015: [Telemetry] Reorganize everything. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-add shebangs. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4 from telemetry import web_contents
5
6 DEFAULT_TAB_TIMEOUT = 60
7
8 class Tab(web_contents.WebContents):
9 """Represents a tab in the browser
10
11 The important parts of the Tab object are in the runtime and page objects.
12 E.g.:
13 # Navigates the tab to a given url.
14 tab.Navigate('http://www.google.com/')
15
16 # Evaluates 1+1 in the tab's JavaScript context.
17 tab.Evaluate('1+1')
18 """
19 def __init__(self, inspector_backend):
20 super(Tab, self).__init__(inspector_backend)
21
22 def __del__(self):
23 super(Tab, self).__del__()
24
25 @property
26 def browser(self):
27 """The browser in which this tab resides."""
28 return self._inspector_backend.browser
29
30 @property
31 def url(self):
32 return self._inspector_backend.url
33
34 def Activate(self):
35 """Brings this tab to the foreground asynchronously.
36
37 Not all browsers or browser versions support this method.
38 Be sure to check browser.supports_tab_control.
39
40 Please note: this is asynchronous. There is a delay between this call
41 and the page's documentVisibilityState becoming 'visible', and yet more
42 delay until the actual tab is visible to the user. None of these delays
43 are included in this call."""
44 self._inspector_backend.Activate()
45
46 def Close(self):
47 """Closes this tab.
48
49 Not all browsers or browser versions support this method.
50 Be sure to check browser.supports_tab_control."""
51 self._inspector_backend.Close()
52
53 @property
54 def screenshot_supported(self):
55 """True if the browser instance is capable of capturing screenshots"""
56 return self._inspector_backend.screenshot_supported
57
58 def Screenshot(self, timeout=DEFAULT_TAB_TIMEOUT):
59 """Capture a screenshot of the window for rendering validation"""
60 return self._inspector_backend.Screenshot(timeout)
61
62 def PerformActionAndWaitForNavigate(
63 self, action_function, timeout=DEFAULT_TAB_TIMEOUT):
64 """Executes action_function, and waits for the navigation to complete.
65
66 action_function must be a Python function that results in a navigation.
67 This function returns when the navigation is complete or when
68 the timeout has been exceeded.
69 """
70 self._inspector_backend.PerformActionAndWaitForNavigate(
71 action_function, timeout)
72
73 def Navigate(self, url, timeout=DEFAULT_TAB_TIMEOUT):
74 """Navigates to url."""
75 self._inspector_backend.Navigate(url, timeout)
76
77 def GetCookieByName(self, name, timeout=DEFAULT_TAB_TIMEOUT):
78 """Returns the value of the cookie by the given |name|."""
79 return self._inspector_backend.GetCookieByName(name, timeout)
OLDNEW
« no previous file with comments | « tools/telemetry/telemetry/system_stub.py ('k') | tools/telemetry/telemetry/tab_crash_exception.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698