selectors by class name
352183
function selectorClassNameSpyBefore(className) {
                    /*jshint validthis: true */

                    var context = phantomas.getDOMPath(this);

                    phantomas.incrMetric('DOMqueriesByClassName');
                    phantomas.addOffender('DOMqueriesByClassName', '.%s (in %s)', className, context);

                    phantomas.enterContext({
                        type: 'getElementsByClassName',
                        callDetails: {
                            context: {
                                length: 1,
                                elements: [context]
                            },
                            arguments: ['.' + className]
                        },
                        backtrace: phantomas.getBacktrace()
                    });
                }
272775
def getElementsByClassName(self, className):
        '''
            
        '''
        elements = []
        for child in self.children:
            if child.hasClass(className) is True:
                elements.append(child)
            elements += child.getElementsByClassName(className)
        return TagCollection(elements)
1067601
function getSelector(node) {
  var selector = arguments.length <= 1 || arguments[1] === undefined ? [node.name] : arguments[1];

  var parent = node.parent;
  if (parent) {
    var children = parent.children;
    var matches = children.filter(function (child) {
      return child.name === node.name;
    });
    if (matches.length > 1) {
      for (var i = 0, l = matches.length; i < l; i++) {
        if (matches[i] === node) {
          selector[0] = selector[0] + ':nth-of-type(' + (i + 1) + ')';
          break;
        }
      }
    }
    selector.unshift(parent.name);
  }
  return parent && parent.parent ? getSelector(parent, selector) : selector.join(' > ');
}
368079
def has_class(self, classname):
        
        def element_has_class():
            """Wrapper to test if element has a class"""
            pattern = re.compile('(\s|^){classname}(\s|$)'.format(classname=classname))
            classes = self.element.get_attribute('class')
            matches = re.search(pattern, classes)

            if matches is not None:
                return True
            return False

        return self.execute_and_handle_webelement_exceptions(
            element_has_class,
            'check for element class "{}"'.format(classname)
        )
1056725
function getCssSelectorClasses(selector) {
  var list = []
  var ast = cssSelector.parse(selector)
  visitRules(ast, function(ruleSet) {
    if (ruleSet.classNames) {
      list = list.concat(ruleSet.classNames)
    }
  })
  return uniq(list)
}
767756
def select_by_selector(self, selector):
    """"""
    option = find_element_by_jquery(world.browser, selector)
    selectors = find_parents_by_jquery(world.browser, selector)
    if not selectors:
        raise AssertionError("No parent element found for the option.")
    selector = selectors[0]
    selector.click()
    sleep(0.3)
    option.click()
    if not option.is_selected():
        raise AssertionError(
            "Option should have become selected after clicking it.")
46552
def selector(self, fieldname):
        """"""
        finder = self._finders[fieldname]
        return (finder._by, finder._selector)
1226013
function selectorClassNameSpy(results, className) {
        var context = phantomas.getDOMPath(this);

        phantomas.incrMetric('DOMqueriesByClassName');
        phantomas.addOffender('DOMqueriesByClassName', {class: className, node: context});
        querySpy('class', '.' + className, 'getElementsByClassName', context, (results.length === 0));
    }
976309
function(element, name) {
        var names = element.className;
        return (!!names && new RegExp("(^|\\s)" + name + "(\\s|$)").test(names));
    }
1296689
def selector_node_name(node)
      if node.class.class_variable_defined?(:@@snake_case_name)
        return node.class.class_variable_get(:@@snake_case_name)
      end

      rindex = node.class.name.rindex('::')
      name = node.class.name[(rindex + 2)..-1]
      name.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
      name.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
      name.downcase!
      node.class.class_variable_set(:@@snake_case_name, name)
    end
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']
1215134
function selectorBlockHandler(element) {
    if (element.type === 'Selector') {
        const name = []
        let discard = false
        element.children.forEach(e => {
            switch (e.type) {
                case "ClassSelector":
                    name.push("." + e.name);
                    break;
                    //not support for now
                case "Combinator":
                    name.push(e.name);
                    discard = true
                    return null
                case "TypeSelector":
                    name.push(e.name);
                    break;
                case "IdSelector":
                    //not support for now
                    name.push("#" + e.name);
                    discard = true
                    return null
                case "WhiteSpace":
                    name.push(" ");
                    break
                default: {
                    // console.warn('unknown selector type:', e)
                    discard = true
                    return null
                }
            }
        })
        if (!discard)
            return name.join("")
        else return null
    }
}
125000
function querySelectorAlls(str) {
        return (document.querySelectorAll || window.jQuery || window.Zepto || selector).call(document, str);
    }
153234
function hasClass ( el, className ) {
        return el.classList ? el.classList.contains(className) : new RegExp('\\b' + className + '\\b').test(el.className);
    }
577587
function _match(elm, selector)
    {
        if (!selector) {
            return true;
        }

        var tag = selector.uTag,
            id = selector.id,
            classes = selector.classes;

        return (elm.nodeType === 1) &&
        !(tag && tag !== elm.tagName) &&
        !(id && id !== elm.id) &&
        !(classes && !_hasClasses(elm, classes));
    }
850
def extract_selector_info(sel):
    """"""
    #  walk the parsed_tree, looking for pseudoClass selectors, check names
    # add in steps and/or deferred extras
    steps, extras = _extract_sel_info(sel.parsed_tree)
    steps = sorted(set(steps))
    extras = sorted(set(extras))
    if len(steps) == 0:
        steps = ['default']
    return (steps, extras)
926877
function find(el, selector) {
  if (!selector) {
    selector = el;
    el = document;
  }
  return el.querySelector(selector);
}