OLD | NEW |
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 Loading... |
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. All implementation tests of ChromeDriver |
| 380 should go above. |
| 381 |
| 382 TODO(dyu): Move these tests out of here when pyauto has these capabilities. |
| 383 """ |
| 384 |
| 385 |
| 386 class AutofillTest(unittest.TestCase): |
| 387 AUTOFILL_EDIT_ADDRESS = 'chrome://settings/autoFillEditAddress' |
| 388 |
| 389 def setUp(self): |
| 390 self._launcher = ChromeDriverLauncher() |
| 391 |
| 392 def tearDown(self): |
| 393 self._launcher.Kill() |
| 394 |
| 395 def testPostalCodeAndStateLabelsBasedOnCountry(self): |
| 396 """Verify postal code and state labels based on selected country.""" |
| 397 file_path = os.path.join('state_zip_labels.txt') |
| 398 import simplejson |
| 399 test_data = simplejson.loads(open(file_path).read()) |
| 400 |
| 401 driver = WebDriver(self._launcher.GetURL(), {}) |
| 402 driver.get(self.AUTOFILL_EDIT_ADDRESS) |
| 403 state_label = driver.find_element_by_id('state-label').text |
| 404 self.assertEqual('State', state_label) |
| 405 for country_code in test_data: |
| 406 query = '//option[@value="%s"]' % country_code |
| 407 driver.find_element_by_id('country').find_element_by_xpath(query).select() |
| 408 # Compare postal labels. |
| 409 actual_postal_label = driver.find_element_by_id( |
| 410 'postal-code-label').text |
| 411 expected_postal_label = test_data[country_code]['postalCodeLabel'] |
| 412 self.assertEqual( |
| 413 actual_postal_label, expected_postal_label, |
| 414 'Postal code label does not match Country "%s"' % country_code) |
| 415 # Compare state labels. |
| 416 actual_state_label = driver.find_element_by_id('state-label').text |
| 417 expected_state_label = test_data[country_code]['stateLabel'] |
| 418 self.assertEqual( |
| 419 actual_state_label, expected_state_label, |
| 420 'State label does not match Country "%s"' % country_code) |
| 421 |
379 if __name__ == '__main__': | 422 if __name__ == '__main__': |
380 unittest.main(module='chromedriver_tests', | 423 unittest.main(module='chromedriver_tests', |
381 testRunner=GTestTextTestRunner(verbosity=1)) | 424 testRunner=GTestTextTestRunner(verbosity=1)) |
OLD | NEW |