'Test behaviour of a text field.'

def _test_text_field(self, field_id, title, initial_value, new_invalid_value, new_valid_values, success_message=SUCCESS_MESSAGE, assert_after_reload=True):

    self.assertEqual(self.account_settings_page.title_for_field(field_id), title)
    self.assertEqual(self.account_settings_page.value_for_text_field(field_id), initial_value)
    self.assertEqual(self.account_settings_page.value_for_text_field(field_id, new_invalid_value), new_invalid_value)
    self.account_settings_page.wait_for_indicator(field_id, 'validation-error')
    self.browser.refresh()
    self.assertNotEqual(self.account_settings_page.value_for_text_field(field_id), new_invalid_value)
    for new_value in new_valid_values:
        self.assertEqual(self.account_settings_page.value_for_text_field(field_id, new_value), new_value)
        self.account_settings_page.wait_for_message(field_id, success_message)
        if assert_after_reload:
            self.browser.refresh()
            self.assertEqual(self.account_settings_page.value_for_text_field(field_id), new_value)
