

def choose_form(self, number=None, id=None, name=None, xpath=None):
    '\n        Set the default form.\n\n        :param number: number of form (starting from zero)\n        :param id: value of "id" attribute\n        :param name: value of "name" attribute\n        :param xpath: XPath query\n        :raises: :class:`DataNotFound` if form not found\n        :raises: :class:`GrabMisuseError`\n            if method is called without parameters\n\n        Selected form will be available via `form` attribute of `Grab`\n        instance. All form methods will work with default form.\n\n        Examples::\n\n            # Select second form\n            g.choose_form(1)\n\n            # Select by id\n            g.choose_form(id="register")\n\n            # Select by name\n            g.choose_form(name="signup")\n\n            # Select by xpath\n            g.choose_form(xpath=\'//form[contains(@action, "/submit")]\')\n        '
    if (id is not None):
        try:
            self._lxml_form = self.select(('//form[@id="%s"]' % id)).node()
        except IndexError:
            raise DataNotFound(('There is no form with id: %s' % xpath))
    elif (name is not None):
        try:
            self._lxml_form = self.select(('//form[@name="%s"]' % name)).node()
        except IndexError:
            raise DataNotFound(('There is no form with name: %s' % name))
    elif (number is not None):
        try:
            self._lxml_form = self.tree.forms[number]
        except IndexError:
            raise DataNotFound(('There is no form with number: %s' % number))
    elif (xpath is not None):
        try:
            self._lxml_form = self.select(xpath).node()
        except IndexError:
            raise DataNotFound(('Could not find form with xpath: %s' % xpath))
    else:
        raise GrabMisuseError('choose_form methods requires one of [number, id, name, xpath] arguments')

dataset/ETHPy150Open lorien/grab/grab/document.py FormExtension.choose_form/VarMisuse@73/403 `id`->`xpath`