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

Unified Diff: chrome/test/pyautolib/pyauto.py

Issue 10790055: Convert more PyAuto proxy calls to the JSON interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.cc ('k') | chrome/test/pyautolib/pyautolib.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/pyautolib/pyauto.py
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py
index 1bef6ba28e6bea071274a7f70d9612b67c59a729..44f9e9422799c433717c6e3614a2ed7365482288 100755
--- a/chrome/test/pyautolib/pyauto.py
+++ b/chrome/test/pyautolib/pyauto.py
@@ -1213,6 +1213,46 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
return self._GetResultFromJSONRequest(cmd_dict,
windex=None).get('tab_index')
+ def ActivateTab(self, tab_index=0, windex=0):
+ """Activates the given tab in the specified window.
+
+ Warning: Depending on the concept of an active tab is dangerous as it can
+ change during the test. Instead use functions that accept a tab_index
+ explicitly.
+
+ Args:
+ tab_index: Integer index of the tab to activate; defaults to the first
Nirnimesh 2012/07/18 19:22:56 'first tab' -> 0
craigdh 2012/07/18 19:45:25 Done.
+ tab.
+ windex: Integer index of the browser window to use; defaults to the first
+ window.
+
+ Raises:
+ pyauto_errors.JSONInterfaceError if the automation call returns an error.
+ """
+ cmd_dict = {
+ 'command': 'ActivateTab',
+ 'tab_index': tab_index,
+ 'windex': windex,
+ }
+ self.BringBrowserToFront(windex)
Nirnimesh 2012/07/18 19:22:56 shouldn't this be done on the C++ side?
craigdh 2012/07/18 19:45:25 Bringing the browser to the front is available in
+ self._GetResultFromJSONRequest(cmd_dict, windex=None)
+
+ def BringBrowserToFront(self, windex=0):
+ """Activate the browser's window and bring it to front.
+
+ Args:
+ windex: Integer index of the browser window to use; defaults to the first
+ window.
+
+ Raises:
+ pyauto_errors.JSONInterfaceError if the automation call returns an error.
+ """
+ cmd_dict = {
+ 'command': 'BringBrowserToFront',
+ 'windex': windex,
+ }
+ self._GetResultFromJSONRequest(cmd_dict, windex=None)
+
def AppendTab(self, url, windex=0):
"""Append a new tab.
@@ -1239,6 +1279,86 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
}
return self._GetResultFromJSONRequest(cmd_dict, windex=None).get('result')
+ def GetTabCount(self, windex=0):
+ """Gets the number of tab in the given browser window.
+
+ Args:
+ windex: Integer index of the browser window to use; defaults to the first
+ window.
+
+ Returns:
+ The tab count.
+
+ Raises:
+ pyauto_errors.JSONInterfaceError if the automation call returns an error.
+ """
+ cmd_dict = {
+ 'command': 'GetTabCount',
+ 'windex': windex,
+ }
+ return self._GetResultFromJSONRequest(cmd_dict, windex=None)['tab_count']
+
+ def GetTabInfo(self, tab_index=0, windex=0):
+ """Gets information about the specified tab.
+
+ Args:
+ tab_index: Integer index of the tab to activate; defaults to the first
+ tab.
+ windex: Integer index of the browser window to use; defaults to the first
+ window.
+
+ Returns:
+ A dictionary containing information about the tab.
+ Example:
+ { u'title': "Hello World",
+ u'url': "http://foo.bar", }
+
+ Raises:
+ pyauto_errors.JSONInterfaceError if the automation call returns an error.
+ """
+ cmd_dict = {
+ 'command': 'GetTabInfo',
+ 'tab_index': tab_index,
+ 'windex': windex,
+ }
+ return self._GetResultFromJSONRequest(cmd_dict, windex=None)
+
+ def GetActiveTabTitle(self, windex=0):
+ """Gets the title of the active tab.
+
+ Warning: Depending on the concept of an active tab is dangerous as it can
+ change during the test. Use GetTabInfo and supply a tab_index explicitly.
+
+ Args:
+ windex: Integer index of the browser window to use; defaults to the first
+ window.
+
+ Returns:
+ The tab title as a string.
+
+ Raises:
+ pyauto_errors.JSONInterfaceError if the automation call returns an error.
+ """
+ return self.GetTabInfo(self.GetActiveTabIndex(windex), windex)['title']
+
+ def GetActiveTabURL(self, windex=0):
+ """Gets the URL of the active tab.
+
+ Warning: Depending on the concept of an active tab is dangerous as it can
+ change during the test. Use GetTabInfo and supply a tab_index explicitly.
+
+ Args:
+ windex: Integer index of the browser window to use; defaults to the first
+ window.
+
+ Returns:
+ The tab URL as a GURL object.
+
+ Raises:
+ pyauto_errors.JSONInterfaceError if the automation call returns an error.
+ """
+ return GURL(self.GetTabInfo(self.GetActiveTabIndex(windex), windex)['url'])
+
def GetBookmarkModel(self, windex=0):
"""Return the bookmark model as a BookmarkModel object.
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.cc ('k') | chrome/test/pyautolib/pyautolib.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698