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

Unified Diff: chrome/test/webdriver/chromedriver_tests.py

Issue 6770023: Added a test for Autofill to check the postal code and state label change based on corresponding ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 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
Index: chrome/test/webdriver/chromedriver_tests.py
===================================================================
--- chrome/test/webdriver/chromedriver_tests.py (revision 79746)
+++ chrome/test/webdriver/chromedriver_tests.py (working copy)
@@ -351,6 +351,52 @@
self.assertEquals(data['sessionId'], url_parts[4])
+class AutofillTest(unittest.TestCase):
+ """Autofill tests that interacts with web UI."""
+ AUTOFILL_EDIT_ADDRESS = 'chrome://settings/autoFillEditAddress'
+
+ def setUp(self):
+ self._launcher = ChromeDriverLauncher()
+
+ def tearDown(self):
+ self._launcher.Kill()
+
+ def NewDriver(self):
Huyen 2011/03/30 19:17:02 Fold the code here into where you're calling NewDr
dyu1 2011/03/30 21:51:45 What do you mean by fold the code here? If I didn'
Huyen 2011/03/30 22:08:03 Inline WebDriver(self._launcher.GetUrl(), {}) wher
dyu1 2011/03/30 22:33:10 If I fold it in then instead of driver.get for all
Huyen 2011/03/30 23:23:12 When you add more tests later you can add that met
+ return WebDriver(self._launcher.GetURL(), {})
+
+ def testPostalCodeAndStateLabelsBasedOnCountry(self):
+ """Verify postal code and state labels based on selected country."""
+ file_path = os.path.join('state_zip_labels.txt')
+ import simplejson
+ print dir(simplejson)
Huyen 2011/03/30 19:17:02 Do you need this print? Remove if it is for debugg
dyu1 2011/03/30 21:51:45 Done.
+ test_data = simplejson.loads(open(file_path).read())
+
+ driver = self.NewDriver()
+ driver.get(self.AUTOFILL_EDIT_ADDRESS)
+ state_label = driver.find_element_by_id('state-label').text
+ self.assertEqual('State', state_label)
+ for country_code in test_data:
+ query = '//option[@value="%s"]' % country_code
+ driver.find_element_by_id(
Huyen 2011/03/30 19:17:02 This is fine but if multiple postal codes are not
dyu1 2011/03/30 21:51:45 What do you mean by multiple postal codes? In this
Huyen 2011/03/30 22:08:03 You're looping through the list of postal codes to
+ 'country').find_element_by_xpath(query).select()
+
+ # Compare postal labels.
+ actual_postal_label = driver.find_element_by_id(
+ 'postal-code-label').text
+ expected_postal_label = test_data[country_code]['postalCodeLabel']
+ self.assertEqual(
+ actual_postal_label, expected_postal_label,
+ 'Postal code label on the UI does not correspond to the selected \
Huyen 2011/03/30 19:17:02 This is a UI test so you don't need to say "on the
dyu1 2011/03/30 21:51:45 Done.
+ Country "%s"' % country_code)
+ # Compare state labels.
+ actual_state_label = driver.find_element_by_id('state-label').text
+ expected_state_label = test_data[country_code]['stateLabel']
+ self.assertEqual(
+ actual_state_label, expected_state_label,
+ 'State label on the UI does not correspond to the selected \
Huyen 2011/03/30 19:17:02 Same as above.
dyu1 2011/03/30 21:51:45 Done.
+ Country "%s"' % country_code)
+
Huyen 2011/03/30 19:17:02 You might want to call driver.quit() here.
dyu1 2011/03/30 21:51:45 The driver quits on it's own when I run the test.
+
# TODO(jleyba): Port this to WebDriver's own python test suite.
class ElementEqualityTest(unittest.TestCase):
"""Tests that the server properly checks element equality."""
« no previous file with comments | « no previous file | chrome/test/webdriver/state_zip_labels.txt » ('j') | chrome/test/webdriver/state_zip_labels.txt » ('J')

Powered by Google App Engine
This is Rietveld 408576698