summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authordyu@chromium.org <dyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-08 21:58:50 +0000
committerdyu@chromium.org <dyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-08 21:58:50 +0000
commitc220e911de3d672af4f1079ec1cdc763925ce345 (patch)
tree27d53639502944dece92e4d29400fcdf22cb5b6e /chrome/test
parent841cb37bc9da44be1cc009ba0ff47b946939ea50 (diff)
downloadchromium_src-c220e911de3d672af4f1079ec1cdc763925ce345.zip
chromium_src-c220e911de3d672af4f1079ec1cdc763925ce345.tar.gz
chromium_src-c220e911de3d672af4f1079ec1cdc763925ce345.tar.bz2
Revert 100253 - Add Autofill tests written in chrome driver.
- testPostalCodeAndStateLabelsBasedOnCountry - testDisplayLineItemForEntiresWithNoCCNum - testNoDuplicatePhoneNumsInPrefs BUG=none TEST=none Review URL: http://codereview.chromium.org/7761013 TBR=dyu@chromium.org git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100266 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/functional/PYAUTO_TESTS4
-rw-r--r--chrome/test/functional/autofill.py98
-rw-r--r--chrome/test/webdriver/test/chromedriver_tests.py85
-rw-r--r--chrome/test/webdriver/test/state_zip_labels.txt (renamed from chrome/test/data/autofill/functional/state_zip_labels.txt)1
4 files changed, 87 insertions, 101 deletions
diff --git a/chrome/test/functional/PYAUTO_TESTS b/chrome/test/functional/PYAUTO_TESTS
index c056184..b4be19c 100644
--- a/chrome/test/functional/PYAUTO_TESTS
+++ b/chrome/test/functional/PYAUTO_TESTS
@@ -418,10 +418,6 @@
],
'chromeos': [
- # These tests fail due to crosbug.com/19556
- '-autofill.AutofillTest.testPostalCodeAndStateLabelsBasedOnCountry',
- '-autofill.AutofillTest.testDisplayLineItemForEntriesWithNoCCNum',
- '-autofill.AutofillTest.testNoDuplicatePhoneNumsInPrefs',
],
},
diff --git a/chrome/test/functional/autofill.py b/chrome/test/functional/autofill.py
index c9bc5f7..55e37d9 100644
--- a/chrome/test/functional/autofill.py
+++ b/chrome/test/functional/autofill.py
@@ -193,7 +193,7 @@ class AutofillTest(pyauto.PyUITest):
Args:
number: the credit card number being validated, as a string.
- Returns:
+ Return:
boolean whether the credit card number is valid or not.
"""
# Filters out non-digit characters.
@@ -721,102 +721,6 @@ class AutofillTest(pyauto.PyUITest):
self.SubmitAutofillForm(js, tab_index=0, windex=0)
return len(list_of_dict)
- class AutoFillSettingsPage(object):
- ADDRESS_URL = 'chrome://settings/autofillEditAddress'
- CC_URL = 'chrome://settings/autofillEditCreditCard'
-
- def FillAddressFields(self, full_name, address_line1, address_line2, city,
- state, postal_code, country, phone, email,
- company_name):
- driver.find_element_by_id('full-name-list').find_element_by_tag_name(
- 'input').send_keys(full_name)
- driver.find_element_by_id('addr-line-1').send_keys(address_line1)
- driver.find_element_by_id('addr-line-2').send_keys(address_line2)
- driver.find_element_by_id('city').send_keys(city)
-
-
- def _SelectOptionXpath(self, value):
- """Returns an xpath query used to select an item from a dropdown list.
-
- Args:
- value: Option selected for the drop-down list field.
-
- Returns:
- The value of the xpath query.
- """
- return '//option[@value="%s"]' % value
-
- def testPostalCodeAndStateLabelsBasedOnCountry(self):
- """Verify postal code and state labels based on selected country."""
- data_file = os.path.join(self.DataDir(), 'autofill', 'functional',
- 'state_zip_labels.txt')
- import simplejson
- test_data = simplejson.loads(open(data_file).read())
-
- driver = self.NewWebDriver()
- self.NavigateToURL('chrome://settings/autofillEditAddress')
- # Initial check of State and ZIP labels.
- self.assertEqual('State', driver.find_element_by_id('state-label').text)
- self.assertEqual('ZIP code',
- driver.find_element_by_id('postal-code-label').text)
-
- for country_code in test_data:
- query = self._SelectOptionXpath(country_code)
- driver.find_element_by_id('country').find_element_by_xpath(query).click()
- # 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(
- expected_postal_label, actual_postal_labels,
- msg='Postal code label does not match 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(
- expected_state_label, actual_postal_labels,
- msg='State label does not match Country "%s"' % country_code)
-
- def testNoDuplicatePhoneNumsInPrefs(self):
- """Test duplicate phone numbers entered in prefs are removed."""
- driver = self.NewWebDriver()
- self.NavigateToURL('chrome://settings/autofillEditAddress')
- driver.find_element_by_id('full-name-list').find_element_by_tag_name(
- 'input').send_keys('John Doe')
- driver.find_element_by_id('addr-line-1').send_keys('123 Cherry St')
- driver.find_element_by_id('city').send_keys('Mountain View')
- driver.find_element_by_id('state').send_keys('CA')
- driver.find_element_by_id('postal-code').send_keys('94043')
- query = self._SelectOptionXpath('US')
- driver.find_element_by_id('country').find_element_by_xpath(query).click()
- driver.find_element_by_id('phone-list').find_elements_by_tag_name(
- 'input')[0].send_keys('650-555-1234\n') # Press Enter key after phone.
- phone_field2 = driver.find_element_by_id(
- 'phone-list').find_elements_by_tag_name('input')[1]
- phone_field2.send_keys('650-555-1234\n')
- self.assertEqual(phone_field2.get_attribute('value'), '',
- msg='Duplicate phone number in prefs unexpectedly saved.')
-
- def testDisplayLineItemForEntriesWithNoCCNum(self):
- """Verify Autofill creates a line item for CC entries with no CC number."""
- driver = self.NewWebDriver()
- self.NavigateToURL('chrome://settings/autofillEditCreditCard')
- driver.find_element_by_id('name-on-card').send_keys('Jane Doe')
- query_month = self._SelectOptionXpath('12')
- query_year = self._SelectOptionXpath('2014')
- driver.find_element_by_id('expiration-month').find_element_by_xpath(
- query_month).click()
- driver.find_element_by_id('expiration-year').find_element_by_xpath(
- query_year).click()
- driver.find_element_by_id(
- 'autofill-edit-credit-card-apply-button').click()
- # Refresh the page to ensure the UI is up-to-date.
- driver.refresh()
- list_entry = driver.find_element_by_class_name('autofill-list-item')
- self.assertTrue(list_entry.is_displayed)
- self.assertEqual('Jane Doe', list_entry.text,
- msg='Saved CC line item not same as what was entered.')
-
if __name__ == '__main__':
pyauto_functional.Main()
diff --git a/chrome/test/webdriver/test/chromedriver_tests.py b/chrome/test/webdriver/test/chromedriver_tests.py
index 1b90f87..7f36cf7 100644
--- a/chrome/test/webdriver/test/chromedriver_tests.py
+++ b/chrome/test/webdriver/test/chromedriver_tests.py
@@ -835,3 +835,88 @@ class AlertTest(ChromeDriverTest):
driver.switch_to_frame('subframe')
driver.execute_async_script('arguments[0](); window.alert("ok")')
driver.switch_to_alert().accept()
+
+
+"""Chrome functional test section. All implementation tests of ChromeDriver
+should go above.
+
+TODO(dyu): Move these tests out of here when pyauto has these capabilities.
+"""
+
+
+def GetPathForDataFile(relative_path):
+ """Returns the path for a test data file residing in this directory."""
+ return os.path.join(os.path.dirname(__file__), relative_path)
+
+
+class AutofillTest(ChromeDriverTest):
+ AUTOFILL_EDIT_ADDRESS = 'chrome://settings/autofillEditAddress'
+ AUTOFILL_EDIT_CC = 'chrome://settings/autofillEditCreditCard'
+
+ def _SelectOptionXpath(self, value):
+ """Returns an xpath query used to select an item from a dropdown list.
+
+ Args:
+ value: Option selected for the drop-down list field.
+ """
+ return '//option[@value="%s"]' % value
+
+ def testPostalCodeAndStateLabelsBasedOnCountry(self):
+ """Verify postal code and state labels based on selected country."""
+ data_file = os.path.join(test_paths.CHROMEDRIVER_TEST_DATA,
+ 'state_zip_labels.txt')
+ import simplejson
+ test_data = simplejson.loads(open(data_file).read())
+
+ driver = self.GetNewDriver()
+ driver.get(self.AUTOFILL_EDIT_ADDRESS)
+ # Initial check of State and ZIP labels.
+ state_label = driver.find_element_by_id('state-label').text
+ self.assertEqual('State', state_label)
+ zip_label = driver.find_element_by_id('postal-code-label').text
+ self.assertEqual('ZIP code', zip_label)
+
+ for country_code in test_data:
+ query = self._SelectOptionXpath(country_code)
+ driver.find_element_by_id('country').find_element_by_xpath(query).click()
+ # 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 does not match 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 does not match Country "%s"' % country_code)
+
+ def testDisplayLineItemForEntriesWithNoCCNum(self):
+ """Verify Autofill creates a line item for CC entries with no CC number."""
+ creditcard_data = {'CREDIT_CARD_NAME': 'Jane Doe',
+ 'CREDIT_CARD_EXP_MONTH': '12',
+ 'CREDIT_CARD_EXP_4_DIGIT_YEAR': '2014'}
+
+ driver = self.GetNewDriver()
+ driver.get(self.AUTOFILL_EDIT_CC)
+ driver.find_element_by_id('name-on-card').send_keys(
+ creditcard_data['CREDIT_CARD_NAME'])
+ query_month = self._SelectOptionXpath(
+ creditcard_data['CREDIT_CARD_EXP_MONTH'])
+ query_year = self._SelectOptionXpath(
+ creditcard_data['CREDIT_CARD_EXP_4_DIGIT_YEAR'])
+ driver.find_element_by_id('expiration-month').find_element_by_xpath(
+ query_month).click()
+ driver.find_element_by_id('expiration-year').find_element_by_xpath(
+ query_year).click()
+ driver.find_element_by_id(
+ 'autofill-edit-credit-card-apply-button').click()
+ # Refresh the page to ensure the UI is up-to-date.
+ driver.refresh()
+ list_entry = driver.find_element_by_class_name('autofill-list-item')
+ self.assertTrue(list_entry.is_displayed)
+ self.assertEqual(list_entry.text,
+ creditcard_data['CREDIT_CARD_NAME'],
+ 'Saved CC line item not same as what was entered.')
diff --git a/chrome/test/data/autofill/functional/state_zip_labels.txt b/chrome/test/webdriver/test/state_zip_labels.txt
index 8192679..ae2c3cc 100644
--- a/chrome/test/data/autofill/functional/state_zip_labels.txt
+++ b/chrome/test/webdriver/test/state_zip_labels.txt
@@ -19,3 +19,4 @@
"TW":{"name":"Taiwan","postalCodeLabel":"Postal code","stateLabel":"County"},
"US":{"name":"United States","postalCodeLabel":"ZIP code","stateLabel":"State"}
}
+