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

Side by Side 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, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/test/webdriver/state_zip_labels.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Tests for ChromeDriver. 7 """Tests for ChromeDriver.
8 8
9 If your test is testing a specific part of the WebDriver API, consider adding 9 If your test is testing a specific part of the WebDriver API, consider adding
10 it to the appropriate place in the WebDriver tree instead. 10 it to the appropriate place in the WebDriver tree instead.
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 body2 = self._driver.execute_script('return document.body') 369 body2 = self._driver.execute_script('return document.body')
370 370
371 # TODO(jleyba): WebDriver's python bindings should expose a proper API 371 # TODO(jleyba): WebDriver's python bindings should expose a proper API
372 # for this. 372 # for this.
373 result = body1.execute(Command.ELEMENT_EQUALS, { 373 result = body1.execute(Command.ELEMENT_EQUALS, {
374 'other': body2.id 374 'other': body2.id
375 }) 375 })
376 self.assertTrue(result['value']) 376 self.assertTrue(result['value'])
377 377
378 378
379 """Chrome functional test section. Put all tests of ChromeDriver below.
kkania 2011/03/31 03:33:25 except you got the wording wrong; how about: "all
dyu1 2011/03/31 03:46:23 Done.
380
381 TODO(dyu): Move these tests out of here when pyauto has these capabilities.
382 """
383 class AutofillTest(unittest.TestCase):
kkania 2011/03/31 03:33:25 two newlines above
dyu1 2011/03/31 03:46:23 Done.
384 """Autofill tests."""
kkania 2011/03/31 03:33:25 hehe, if this is the best you can do just drop the
dyu1 2011/03/31 03:46:23 Done.
385 AUTOFILL_EDIT_ADDRESS = 'chrome://settings/autoFillEditAddress'
386
387 def setUp(self):
388 self._launcher = ChromeDriverLauncher()
389
390 def tearDown(self):
391 self._launcher.Kill()
392
393 def testPostalCodeAndStateLabelsBasedOnCountry(self):
394 """Verify postal code and state labels based on selected country."""
395 file_path = os.path.join('state_zip_labels.txt')
396 import simplejson
397 test_data = simplejson.loads(open(file_path).read())
398
399 driver = WebDriver(self._launcher.GetURL(), {})
400 driver.get(self.AUTOFILL_EDIT_ADDRESS)
401 state_label = driver.find_element_by_id('state-label').text
402 self.assertEqual('State', state_label)
403 for country_code in test_data:
404 query = '//option[@value="%s"]' % country_code
405 driver.find_element_by_id('country').find_element_by_xpath(query).select()
406 # Compare postal labels.
407 actual_postal_label = driver.find_element_by_id(
408 'postal-code-label').text
409 expected_postal_label = test_data[country_code]['postalCodeLabel']
410 self.assertEqual(
411 actual_postal_label, expected_postal_label,
412 'Postal code label does not match Country "%s"' % country_code)
413 # Compare state labels.
414 actual_state_label = driver.find_element_by_id('state-label').text
415 expected_state_label = test_data[country_code]['stateLabel']
416 self.assertEqual(
417 actual_state_label, expected_state_label,
418 'State label does not match Country "%s"' % country_code)
419
379 if __name__ == '__main__': 420 if __name__ == '__main__':
380 unittest.main(module='chromedriver_tests', 421 unittest.main(module='chromedriver_tests',
381 testRunner=GTestTextTestRunner(verbosity=1)) 422 testRunner=GTestTextTestRunner(verbosity=1))
OLDNEW
« no previous file with comments | « no previous file | chrome/test/webdriver/state_zip_labels.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698