Index: chrome/test/pyautolib/pyauto.py |
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py |
index 1bef6ba28e6bea071274a7f70d9612b67c59a729..a957885ba6084c19700307334e51fda6f7f3ec24 100755 |
--- a/chrome/test/pyautolib/pyauto.py |
+++ b/chrome/test/pyautolib/pyauto.py |
@@ -1367,6 +1367,68 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): |
} |
self._GetResultFromJSONRequest(cmd_dict, windex=windex) |
+ def GetCookie(self, url, windex=0, tab_index=0): |
+ """Get the value of the cookie at url for the specified tab. |
+ |
+ Args: |
+ windex: The index of the browser window to work on. Defaults to the first |
+ window. |
+ |
+ Raises: |
+ pyauto_errors.JSONInterfaceError if the automation call returns an error. |
+ """ |
+ if isinstance(url, GURL): |
+ url = url.spec() |
+ cmd_dict = { |
+ 'command': 'GetTabCookies', |
+ 'url': url, |
+ 'tab_index': tab_index, |
+ 'windex': windex, |
+ } |
+ return self._GetResultFromJSONRequest(cmd_dict, windex=windex)['cookies'] |
Nirnimesh
2012/07/20 22:16:20
this should probably be windex=None?
craigdh
2012/07/20 23:23:42
Done.
|
+ |
+ def DeleteCookie(self, url, cookie_name, windex=0, tab_index=0): |
+ """Delete the the cookie at url with name cookie_name for the given tab. |
+ |
+ Args: |
+ windex: The index of the browser window to work on. Defaults to the first |
+ window. |
+ |
+ Raises: |
+ pyauto_errors.JSONInterfaceError if the automation call returns an error. |
+ """ |
+ if isinstance(url, GURL): |
+ url = url.spec() |
+ cmd_dict = { |
+ 'command': 'DeleteTabCookie', |
+ 'url': url, |
+ 'cookie_name': cookie_name, |
+ 'tab_index': tab_index, |
+ 'windex': windex, |
+ } |
+ self._GetResultFromJSONRequest(cmd_dict, windex=windex) |
+ |
+ def SetCookie(self, url, value, windex=0, tab_index=0): |
+ """Set the value of the cookie at url to value for the specified tab. |
+ |
+ Args: |
+ windex: The index of the browser window to work on. Defaults to the first |
+ window. |
+ |
+ Raises: |
+ pyauto_errors.JSONInterfaceError if the automation call returns an error. |
+ """ |
+ if isinstance(url, GURL): |
+ url = url.spec() |
+ cmd_dict = { |
+ 'command': 'SetTabCookie', |
+ 'url': url, |
+ 'value': value, |
+ 'windex': windex, |
+ 'tab_index': tab_index, |
+ } |
+ self._GetResultFromJSONRequest(cmd_dict, windex=windex) |
+ |
def GetInstantInfo(self): |
"""Return info about the instant overlay tab. |
@@ -1681,6 +1743,67 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): |
# Sending request for a char. |
self._GetResultFromJSONRequest(cmd_dict, windex=None) |
+ def SetDownloadShelfVisible(self, is_visible, windex=0): |
+ """Set download shelf visibility for the specified browser window. |
+ |
+ Args: |
+ is_visible: A boolean indicating the desired shelf visibility. |
+ windex: The window index, defaults to 0 (the first window). |
+ |
+ Raises: |
+ pyauto_errors.JSONInterfaceError if the automation call returns an error. |
+ """ |
+ cmd_dict = { |
+ 'command': 'SetDownloadShelfVisible', |
+ 'is_visible': is_visible, |
+ 'windex': windex, |
+ } |
+ self._GetResultFromJSONRequest(cmd_dict, windex=None) |
+ |
+ def IsDownloadShelfVisible(self, windex=0): |
+ """Determine whether the download shelf is visible in the given window. |
+ |
+ Args: |
+ windex: The window index, defaults to 0 (the first window). |
+ |
+ Returns: |
+ A boolean indicating the shelf visibility. |
+ |
+ Raises: |
+ pyauto_errors.JSONInterfaceError if the automation call returns an error. |
+ """ |
+ cmd_dict = { |
+ 'command': 'IsDownloadShelfVisible', |
+ 'windex': windex, |
+ } |
+ return self._GetResultFromJSONRequest(cmd_dict, windex=None)['is_visible'] |
+ |
+ def GetDownloadDirectory(self, tab_index=None, windex=0): |
+ """Get the path to the download directory. |
+ |
+ Warning: Depending on the concept of an active tab is dangerous as it can |
+ change during the test. Always supply a tab_index explicitly. |
+ |
+ Args: |
+ tab_index: The index of the tab to work on. Defaults to the active tab. |
+ windex: The index of the browser window to work on. Defaults to 0. |
+ |
+ Returns: |
+ The path to the download directory as a FilePath object. |
+ |
+ Raises: |
+ pyauto_errors.JSONInterfaceError if the automation call returns an error. |
+ """ |
+ if tab_index is None: |
+ tab_index = self.GetActiveTabIndex(windex) |
+ cmd_dict = { |
+ 'command': 'GetDownloadDirectory', |
+ 'tab_index': tab_index, |
+ 'windex': windex, |
+ } |
+ return FilePath(self._GetResultFromJSONRequest(cmd_dict, |
+ windex=None)['path']) |
+ |
def WaitForAllDownloadsToComplete(self, pre_download_ids=[], windex=0, |
timeout=-1): |
"""Wait for all pending downloads to complete. |