Check field keys: css, xpath and id.
        Return the first found along with it's value.
555885
def _parse_field_selector(field):
        
        for selector_type in ('css', 'xpath', 'id'):
            selector = field.get(selector_type)
            if selector:
                return selector_type, selector
        logger.warning("Form field does not define any selector "
                       "(id, css and xpath available): %r",
                       field)
        return None, None
251878
def find_elements(self, by=By.ID, value=None):
        
        if self._w3c:
            if by == By.ID:
                by = By.CSS_SELECTOR
                value = '[id="%s"]' % value
            elif by == By.TAG_NAME:
                by = By.CSS_SELECTOR
            elif by == By.CLASS_NAME:
                by = By.CSS_SELECTOR
                value = ".%s" % value
            elif by == By.NAME:
                by = By.CSS_SELECTOR
                value = '[name="%s"]' % value

        return self._execute(Command.FIND_CHILD_ELEMENTS,
                             {"using": by, "value": value})['value']
799614
def lookupFieldType( element )
      type = ""
      if element and element.is_a?( REXML::Element )
         if element.name == "f" and @fields
            fid = element.attributes[ "id" ]
            field = lookupField( fid ) if fid
            type = field.attributes[ "field_type" ] if field
         end
      end
      type
   end
1115704
def find_elements(self, by=By.ID, value=None):
        
        if self.w3c:
            if by == By.ID:
                by = By.CSS_SELECTOR
                value = '[id="%s"]' % value
            elif by == By.TAG_NAME:
                by = By.CSS_SELECTOR
            elif by == By.CLASS_NAME:
                by = By.CSS_SELECTOR
                value = ".%s" % value
            elif by == By.NAME:
                by = By.CSS_SELECTOR
                value = '[name="%s"]' % value

        # Return empty list if driver returns null
        # See https://github.com/SeleniumHQ/selenium/issues/4555
        return self.execute(Command.FIND_ELEMENTS, {
            'using': by,
            'value': value})['value'] or []
1072396
def field_value(field)
      element = find_field(field)
      value = (element.tag_name == 'textarea') ? element.text : element.value
      # If field value is an Array, take the first item
      if value.class == Array
        value = value.first
      end
      return value.to_s
    end
638303
def lookup_key(self):
        
        parts = set()
        for node in self.simple_selectors:
            for token in node.tokens:
                if token[0] not in ':[':
                    parts.add(token)

        if not parts:
            # Should always have at least ONE key; selectors with no elements,
            # no classes, and no ids can be indexed as None to avoid a scan of
            # every selector in the entire document
            parts.add(None)

        return frozenset(parts)
67303
def _get_match(self, key):
        

        return self._get_string_match(key=key) or \
            self._get_non_string_match(key=key)
816513
function() {
      var ids = [];
      // search localstorage for saved documents
      for ( var i = 0, max = localStorage.length; i < max; i++) {
        var key = localStorage.key(i);
        // value is a document if key confirms to prefix
        if (key.indexOf(prefix) == 0) {
          ids.push(key.substring(prefix.length));
        }
      }
      return ids;
    }
132921
def get_field_key(self, key, using_name=True):
        
        try:
            if using_name:
                return self.f_name[key].key
            else:
                return self.f[key].key
        except KeyError:
            raise ValueError("'%s' are not found!" % key)
467551
def get_key_value_dict_by_selectors(
        self, key_selector, value_selector, value_sub_selector=None
    ):
        """"""
        key_nodes = self.parsedpage.get_nodes_by_selector(key_selector)
        keys = [
            self.parsedpage.get_text_from_node(node)
            for node in key_nodes
        ]

        value_nodes = self.parsedpage.get_nodes_by_selector(value_selector)
        if value_sub_selector is not None:
            vals = [
                [
                    self.parsedpage.get_text_from_node(subnode)
                    for subnode in node.find(value_sub_selector)
                ]
                for node in value_nodes.items()
            ]
        else:
            vals = [
                self.parsedpage.get_text_from_node(node)
                for node in value_nodes
            ]

        return dict(zip(keys, vals))
559437
def _find_id(self, result, uid):
        
        # if the result is a list
        if isinstance(result, list):
            # if the list has a valid entry
            if any([self._find_id(value, uid) for value in result]):
                # then we're done
                return True

        # otherwise results could be dictionaries
        if isinstance(result, dict):
            # the children of the result that are lists
            list_children = [value for value in result.values() if isinstance(value, list)]

            # go to every value that is a list
            for value in list_children:
                # if the value is a match
                if self._find_id(value, uid):
                    # we're done
                    return True

            # the children of the result that are dicts
            dict_children = [value for value in result.values() if isinstance(value, dict)]

            # perform the check on every child that is a dict
            for value in dict_children:
                # if the child is a match
                if self._find_id(value, uid):
                    # we're done
                    return True

            # if there are no values that are lists and there is an id key
            if not list_children and not dict_children and 'id' in result:
                # the value of the remote id field
                result_id = result['id']
                # we've found a match if the id field matches (cast to match type)
                return result_id == type(result_id)(uid)

        # we didn't find the result
        return False
838019
def find(self, id, **kwargs):
        
        return self.find_by(values={self.primary_key: id}, **kwargs)
26384
def get(self, key):
        '''
        
        '''
        if key in self._data_fields:
            return self._data_fields[key]
        if key in self._sub_reports:
            return self._sub_reports[key]
        return None
760200
def _lookup_style(element, names):
    '''
    
    '''
    return _STYLES.get('_'+element, '') + \
        ''.join([_STYLES.get(name, '') for name in names])
913733
def find_field_by_value(browser, field_type, name):
    
    xpath = field_xpath(field_type, 'value') % string_literal(name)
    elems = ElementSelector(
        browser,
        xpath=str(xpath),
        filter_displayed=True,
        filter_enabled=True,
    )

    # sort by shortest first (most closely matching)
    if field_type in ('button-element', 'button-role'):
        elems = sorted(elems, key=lambda elem: len(elem.text))
    else:
        elems = sorted(elems,
                       key=lambda elem: len(elem.get_attribute('value')))

    if elems:
        elems = [elems[0]]

    return ElementSelector(browser, elements=elems)
46552
def selector(self, fieldname):
        """"""
        finder = self._finders[fieldname]
        return (finder._by, finder._selector)
121698
def lookup_field_class(self, field, obj=None, default=None):
        
        css = ""

        # is there a class specified for this field
        if field in self.field_config and 'class' in self.field_config[field]:
            css = self.field_config[field]['class']

        # if we were given a default, use that
        elif default:
            css = default

        return css