| Index: chrome/test/pyautolib/pyauto.py
|
| ===================================================================
|
| --- chrome/test/pyautolib/pyauto.py (revision 152261)
|
| +++ chrome/test/pyautolib/pyauto.py (working copy)
|
| @@ -3214,235 +3214,6 @@
|
|
|
| return self.WaitUntil(lambda: _IsExtensionViewClosed())
|
|
|
| - def FillAutofillProfile(self, profiles=None, credit_cards=None,
|
| - tab_index=0, window_index=0):
|
| - """Set the autofill profile to contain the given profiles and credit cards.
|
| -
|
| - If profiles or credit_cards are specified, they will overwrite existing
|
| - profiles and credit cards. To update profiles and credit cards, get the
|
| - existing ones with the GetAutofillProfile function and then append new
|
| - profiles to the list and call this function.
|
| -
|
| - Autofill profiles (not credit cards) support multiple values for some of the
|
| - fields. To account for this, all values in a profile must be specified as
|
| - a list of strings. If a form field only has a single value associated with
|
| - it, that value must still be specified as a list containing a single string.
|
| -
|
| - Args:
|
| - profiles: (optional) a list of dictionaries representing each profile to
|
| - add. Example:
|
| - [{
|
| - 'NAME_FIRST': ['Bob',],
|
| - 'NAME_LAST': ['Smith',],
|
| - 'ADDRESS_HOME_ZIP': ['94043',],
|
| - },
|
| - {
|
| - 'EMAIL_ADDRESS': ['sue@example.com',],
|
| - 'COMPANY_NAME': ['Company X',],
|
| - }]
|
| -
|
| - Other possible keys are:
|
| - 'NAME_FIRST', 'NAME_MIDDLE', 'NAME_LAST', 'EMAIL_ADDRESS',
|
| - 'COMPANY_NAME', 'ADDRESS_HOME_LINE1', 'ADDRESS_HOME_LINE2',
|
| - 'ADDRESS_HOME_CITY', 'ADDRESS_HOME_STATE', 'ADDRESS_HOME_ZIP',
|
| - 'ADDRESS_HOME_COUNTRY', 'PHONE_HOME_WHOLE_NUMBER'
|
| -
|
| - credit_cards: (optional) a list of dictionaries representing each credit
|
| - card to add. Example:
|
| - [{
|
| - 'CREDIT_CARD_NAME': 'Bob C. Smith',
|
| - 'CREDIT_CARD_NUMBER': '5555555555554444',
|
| - 'CREDIT_CARD_EXP_MONTH': '12',
|
| - 'CREDIT_CARD_EXP_4_DIGIT_YEAR': '2011'
|
| - },
|
| - {
|
| - 'CREDIT_CARD_NAME': 'Bob C. Smith',
|
| - 'CREDIT_CARD_NUMBER': '4111111111111111',
|
| - 'CREDIT_CARD_TYPE': 'Visa'
|
| - }
|
| -
|
| - Other possible keys are:
|
| - 'CREDIT_CARD_NAME', 'CREDIT_CARD_NUMBER', 'CREDIT_CARD_EXP_MONTH',
|
| - 'CREDIT_CARD_EXP_4_DIGIT_YEAR'
|
| -
|
| - All values must be strings.
|
| -
|
| - tab_index: tab index, defaults to 0.
|
| -
|
| - window_index: window index, defaults to 0.
|
| -
|
| - Raises:
|
| - pyauto_errors.JSONInterfaceError if the automation call returns an error.
|
| - """
|
| - cmd_dict = { # Prepare command for the json interface
|
| - 'command': 'FillAutofillProfile',
|
| - 'tab_index': tab_index,
|
| - 'profiles': profiles,
|
| - 'credit_cards': credit_cards
|
| - }
|
| - self._GetResultFromJSONRequest(cmd_dict, windex=window_index)
|
| -
|
| - def GetAutofillProfile(self, tab_index=0, window_index=0):
|
| - """Returns all autofill profile and credit card information.
|
| -
|
| - The format of the returned dictionary is described above in
|
| - FillAutofillProfile. The general format is:
|
| - {'profiles': [list of profile dictionaries as described above],
|
| - 'credit_cards': [list of credit card dictionaries as described above]}
|
| -
|
| - Args:
|
| - tab_index: tab index, defaults to 0.
|
| - window_index: window index, defaults to 0.
|
| -
|
| - Raises:
|
| - pyauto_errors.JSONInterfaceError if the automation call returns an error.
|
| - """
|
| - cmd_dict = { # Prepare command for the json interface
|
| - 'command': 'GetAutofillProfile',
|
| - 'tab_index': tab_index
|
| - }
|
| - return self._GetResultFromJSONRequest(cmd_dict, windex=window_index)
|
| -
|
| - def SubmitAutofillForm(self, js, frame_xpath='', tab_index=0, windex=0):
|
| - """Submits a webpage autofill form and waits for autofill to be updated.
|
| -
|
| - This function should be called when submitting autofill profiles via
|
| - webpage forms. It waits until the autofill data has been updated internally
|
| - before returning.
|
| -
|
| - Args:
|
| - js: The string Javascript code that can be injected into the given webpage
|
| - to submit an autofill form. This Javascript MUST submit the form.
|
| - frame_xpath: The string xpath for the frame in which to inject javascript.
|
| - tab_index: Integer index of the tab to work on; defaults to 0 (first tab).
|
| - windex: Integer index of the browser window to use; defaults to 0
|
| - (first window).
|
| - """
|
| - cmd_dict = { # Prepare command for the json interface.
|
| - 'command': 'SubmitAutofillForm',
|
| - 'javascript': js,
|
| - 'frame_xpath': frame_xpath,
|
| - 'tab_index': tab_index,
|
| - }
|
| - self._GetResultFromJSONRequest(cmd_dict, windex=windex)
|
| -
|
| - def AutofillTriggerSuggestions(self, field_id=None, tab_index=0, windex=0):
|
| - """Focuses a webpage form field and triggers the autofill popup in it.
|
| -
|
| - This function focuses the specified input field in a webpage form, then
|
| - causes the autofill popup to appear in that field. The underlying
|
| - automation hook sends a "down arrow" keypress event to trigger the autofill
|
| - popup. This function waits until the popup is displayed before returning.
|
| -
|
| - Args:
|
| - field_id: The string ID of the webpage form field to focus. Can be
|
| - 'None' (the default), in which case nothing is focused. This
|
| - can be useful if the field has already been focused by other
|
| - means.
|
| - tab_index: Integer index of the tab to work on; defaults to 0 (first tab).
|
| - windex: Integer index of the browser window to work on; defaults to 0
|
| - (first window).
|
| -
|
| - Returns:
|
| - True, if no errors were encountered, or False otherwise.
|
| -
|
| - Raises:
|
| - pyauto_errors.JSONInterfaceError if the automation call returns an error.
|
| - """
|
| - # Focus the field with the specified ID, if necessary.
|
| - if field_id:
|
| - if not self.JavascriptFocusElementById(field_id, tab_index, windex):
|
| - return False
|
| -
|
| - # Cause the autofill popup to be shown in the focused form field.
|
| - cmd_dict = {
|
| - 'command': 'AutofillTriggerSuggestions',
|
| - 'tab_index': tab_index,
|
| - }
|
| - self._GetResultFromJSONRequest(cmd_dict, windex=windex)
|
| - return True
|
| -
|
| - def AutofillHighlightSuggestion(self, direction, tab_index=0, windex=0):
|
| - """Highlights the previous or next suggestion in an existing autofill popup.
|
| -
|
| - This function assumes that an existing autofill popup is currently displayed
|
| - in a webpage form. The underlying automation hook sends either a
|
| - "down arrow" or an "up arrow" keypress event to cause the next or previous
|
| - suggestion to be highlighted, respectively. This function waits until
|
| - autofill displays a preview of the form's filled state before returning.
|
| -
|
| - Use AutofillTriggerSuggestions() to trigger the autofill popup before
|
| - calling this function. Use AutofillAcceptSelection() after calling this
|
| - function to accept a selection.
|
| -
|
| - Args:
|
| - direction: The string direction in which to highlight an autofill
|
| - suggestion. Must be either "up" or "down".
|
| - tab_index: Integer index of the tab to work on; defaults to 0 (first tab).
|
| - windex: Integer index of the browser window to work on; defaults to 0
|
| - (first window).
|
| -
|
| - Raises:
|
| - pyauto_errors.JSONInterfaceError if the automation call returns an error.
|
| - """
|
| - assert direction in ('up', 'down')
|
| - cmd_dict = {
|
| - 'command': 'AutofillHighlightSuggestion',
|
| - 'direction': direction,
|
| - 'tab_index': tab_index,
|
| - }
|
| - self._GetResultFromJSONRequest(cmd_dict, windex=windex)
|
| -
|
| - def AutofillAcceptSelection(self, tab_index=0, windex=0):
|
| - """Accepts the current selection in an already-displayed autofill popup.
|
| -
|
| - This function assumes that a profile is already highlighted in an existing
|
| - autofill popup in a webpage form. The underlying automation hook sends a
|
| - "return" keypress event to cause the highlighted profile to be accepted.
|
| - This function waits for the webpage form to be filled in with autofill data
|
| - before returning. This function does not submit the webpage form.
|
| -
|
| - Raises:
|
| - pyauto_errors.JSONInterfaceError if the automation call returns an error.
|
| - """
|
| - cmd_dict = {
|
| - 'command': 'AutofillAcceptSelection',
|
| - 'tab_index': tab_index,
|
| - }
|
| - self._GetResultFromJSONRequest(cmd_dict, windex=windex)
|
| -
|
| - def AutofillPopulateForm(self, field_id, profile_index=0, tab_index=0,
|
| - windex=0):
|
| - """Populates a webpage form using autofill data and keypress events.
|
| -
|
| - This function focuses the specified input field in the form, and then
|
| - sends keypress events to the associated tab to cause the form to be
|
| - populated with information from the requested autofill profile.
|
| -
|
| - Args:
|
| - field_id: The string ID of the webpage form field to focus for autofill
|
| - purposes.
|
| - profile_index: The index of the profile in the autofill popup to use to
|
| - populate the form; defaults to 0 (first profile).
|
| - tab_index: Integer index of the tab to work on; defaults to 0 (first tab).
|
| - windex: Integer index of the browser window to work on; defaults to 0
|
| - (first window).
|
| -
|
| - Returns:
|
| - True, if the webpage form is populated successfully, or False if not.
|
| -
|
| - Raises:
|
| - pyauto_errors.JSONInterfaceError if an automation call returns an error.
|
| - """
|
| - if not self.AutofillTriggerSuggestions(field_id, tab_index, windex):
|
| - return False
|
| -
|
| - for _ in range(profile_index + 1):
|
| - self.AutofillHighlightSuggestion('down', tab_index, windex)
|
| -
|
| - self.AutofillAcceptSelection(tab_index, windex)
|
| - return True
|
| -
|
| def AddHistoryItem(self, item):
|
| """Forge a history item for Chrome.
|
|
|
| @@ -4303,29 +4074,6 @@
|
| logging.debug('Executing javascript: %s', js)
|
| return self.ExecuteJavascript(js, tab_index, windex)
|
|
|
| - def JavascriptFocusElementById(self, field_id, tab_index=0, windex=0):
|
| - """Uses Javascript to focus an element with the given ID in a webpage.
|
| -
|
| - Args:
|
| - field_id: The string ID of the webpage form field to focus.
|
| - tab_index: Integer index of the tab to work on; defaults to 0 (first tab).
|
| - windex: Integer index of the browser window to work on; defaults to 0
|
| - (first window).
|
| -
|
| - Returns:
|
| - True, on success, or False on failure.
|
| - """
|
| - focus_field_js = """
|
| - var field = document.getElementById("%s");
|
| - if (!field) {
|
| - window.domAutomationController.send("error");
|
| - } else {
|
| - field.focus();
|
| - window.domAutomationController.send("done");
|
| - }
|
| - """ % field_id
|
| - return self.ExecuteJavascript(focus_field_js, tab_index, windex) == 'done'
|
| -
|
| def SignInToSync(self, username, password):
|
| """Signs in to sync using the given username and password.
|
|
|
|
|