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

Unified Diff: chrome/test/functional/passwords.py

Issue 9775001: Refactor tests that performs an action on the password infobar to identify the infobar by type and … (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/functional/passwords.py
===================================================================
--- chrome/test/functional/passwords.py (revision 127799)
+++ chrome/test/functional/passwords.py (working copy)
@@ -13,7 +13,7 @@
class PasswordTest(pyauto.PyUITest):
"""Tests that passwords work correctly."""
- INFOBAR_BUTTON_TEXT = 'Save password'
+ INFOBAR_TYPE = 'password_infobar'
def Debug(self):
"""Test method for experimentation.
@@ -81,24 +81,24 @@
self.ExecuteJavascript(js_template % 'Passwd',
tab_index, window_index) != ''))
- def _InfobarButtonContainsText(self, search_text, windex, tab_index):
- """Identifies whether an infobar button exists with the specified text.
+ def _GetInfobarIndexByType(self, infobar_type, windex, tab_index):
+ """Returns the index of the infobar of the given type.
Args:
- search_text: The text to search for on the infobar buttons.
+ infobar_type: The infobar type displayed.
dennis_jeffrey 2012/03/21 01:00:07 'displayed' --> 'to look for'
dyu1 2012/03/21 01:08:08 Done.
windex: Window index.
tab_index: Tab index.
Returns:
- True, if search_text is found in the buttons, or False otherwise.
+ Index of infobar for infobar type, or None if not found.
"""
- infobar = (
+ infobar_list = (
self.GetBrowserInfo()['windows'][windex]['tabs'][tab_index] \
['infobars'])
- for infobar_info in infobar:
- if search_text in infobar_info['buttons']:
- return True
- return False
+ for infobar in infobar_list:
+ if infobar_type == infobar['type']:
+ return infobar_list.index(infobar)
+ return None
def _WaitForSavePasswordInfobar(self, windex=0, tab_index=0):
"""Wait for and asserts that the save password infobar appears.
@@ -106,11 +106,17 @@
Args:
windex: Window index. Defaults to 0 (first window).
tab_index: Tab index. Defaults to 0 (first tab).
+
+ Returns:
+ Index of infobar for infobar type.
"""
self.assertTrue(
- self.WaitUntil(lambda: self._InfobarButtonContainsText(
- self.INFOBAR_BUTTON_TEXT, windex, tab_index)),
+ self.WaitUntil(lambda: self._InfobarTypeDisplayed(
+ self.INFOBAR_TYPE, windex, tab_index)),
msg='Save password infobar did not appear.')
+ # Return the infobar index.
+ return self._GetInfobarIndexByType(
+ self.INFOBAR_TYPE, windex, tab_index)
dennis_jeffrey 2012/03/21 01:00:07 Do we need to return this value? I just realized
dyu1 2012/03/21 01:08:08 Yes, since if there are multiple infobars we need
def testSavePassword(self):
"""Test saving a password and getting saved passwords."""
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698