Index: chrome/test/pyautolib/pyauto.py |
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py |
index 53d86ca6deccec640e6509ae856df418e1016e8d..ee94495ee3539257b77a494fa77cebc32f55e480 100755 |
--- a/chrome/test/pyautolib/pyauto.py |
+++ b/chrome/test/pyautolib/pyauto.py |
@@ -1062,6 +1062,94 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): |
raise JSONInterfaceError(ret_dict['error']) |
return ret_dict |
+ def NavigateToURL(self, url, windex=0, tab_index=0, navigation_count=1): |
Nirnimesh
2012/07/03 23:13:26
maintain the order of args. tab_index should come
craigdh
2012/07/11 19:10:26
If you look at pyautolib.h you'll see that previou
|
+ """Navigate the given tab to the given URL. |
+ |
+ Note that this method also activates the corresponding tab/window |
+ if it's not active already. Blocks until page has loaded. |
+ |
+ Args: |
+ url: The URL to which to navigate. |
+ windex: The index of the browser window to work on. Defaults to the first |
+ window. |
+ tab_index: The index of the tab to work on. Defaults to the first tab. |
+ navigation_count: the number of navigations to wait for. Defaults to 1. |
+ """ |
+ cmd_dict = { |
+ 'command': 'NavigateToURL', |
+ 'url': url, |
+ 'windex': windex, |
+ 'tab_index': tab_index, |
+ 'navigation_count': navigation_count, |
+ } |
+ self._GetResultFromJSONRequest(cmd_dict, windex=windex) |
Nirnimesh
2012/07/03 23:13:26
Can we return the result of the navigation in case
craigdh
2012/07/11 19:10:26
A quick grep of test/functional/* indicates no one
|
+ |
+ def ReloadTab(self, windex=0, tab_index=0): |
+ """Reload the given tab. |
+ |
+ Blocks until the page has reloaded. |
+ |
+ Args: |
+ windex: The index of the browser window to work on. Defaults to the first |
+ window. |
+ tab_index: The index of the tab to reload. Defaults to the first tab. |
+ """ |
+ cmd_dict = { |
+ 'command': 'Reload', |
+ 'windex': windex, |
+ 'tab_index': tab_index, |
+ } |
+ self._GetResultFromJSONRequest(cmd_dict, windex=windex) |
Nirnimesh
2012/07/03 23:13:26
windex=None here and all calls that are serviced f
craigdh
2012/07/11 19:10:26
Done.
|
+ |
+ def ReloadActiveTab(self, windex=0): |
+ """Reload an active tab. |
+ |
+ Args: |
+ windex: The index of the browser window to work on. Defaults to the first |
+ window. |
+ """ |
+ self.ReloadTab(windex, self.GetActiveTabIndex(windex)) |
+ |
+ def GetActiveTabIndex(self, windex=0): |
+ """Get the index of the currently active tab in the given browser window. |
Nirnimesh
2012/07/03 23:13:26
It's generally not good to rely on the concept of
craigdh
2012/07/11 19:10:26
Done.
|
+ |
+ Args: |
+ windex: The index of the browser window to work on. Defaults to the first |
+ window. |
+ |
+ Returns: |
+ An integer index for the currently active tab. |
+ """ |
+ cmd_dict = { |
+ 'command': 'GetActiveTabIndex', |
+ 'windex': windex, |
+ } |
+ return self._GetResultFromJSONRequest(cmd_dict, |
+ windex=windex).get('tab_index') |
+ |
+ def AppendTab(self, url, windex=0): |
+ """Append a new tab. |
+ |
+ Creates a new tab at the end of given browser window and activates |
+ it. Blocks until the specified |url| is loaded. |
+ |
+ Args: |
+ url: The url to load, can be string or a GURL object. |
+ windex: The index of the browser window to work on. Defaults to the first |
+ window. |
+ |
+ Returns: |
+ True if the url loads successfully in the new tab. False otherwise. |
+ """ |
+ if isinstance(url, GURL): |
+ url = url.spec() |
+ cmd_dict = { |
+ 'command': 'AppendTab', |
+ 'url': url, |
+ 'windex': windex, |
+ } |
+ return self._GetResultFromJSONRequest(cmd_dict, windex=windex).get('result') |
+ |
def GetBookmarkModel(self, windex=0): |
"""Return the bookmark model as a BookmarkModel object. |
@@ -3166,25 +3254,6 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): |
} |
return self._GetResultFromJSONRequest(cmd_dict, windex=None) |
- def AppendTab(self, url, windex=0): |
- """Create a new tab. |
- |
- Create a new tab at the end of given or first browser window |
- and activate it. Blocks until the url is loaded. |
- |
- Args: |
- url: The url to load, can be string or a GURL object. |
- windex: Index of the window to open a tab in. Default 0 - first window. |
- |
- Returns: |
- True on success. |
- """ |
- if type(url) is GURL: |
- gurl = url |
- else: |
- gurl = GURL(url) |
- return pyautolib.PyUITestBase.AppendTab(self, gurl, windex) |
- |
def WaitUntilNavigationCompletes(self, tab_index=0, windex=0): |
"""Wait until the specified tab is done navigating. |