capybara/queries/selector_query.py
def matches_filters(self, node):
        """
        Returns whether the given node matches all filters.

        Args:
            node (Element): The node to evaluate.

        Returns:
            bool: Whether the given node matches.
        """

        visible = self.visible

        if self.options["text"]:
            if isregex(self.options["text"]):
                regex = self.options["text"]
            elif self.exact_text is True:
                regex = re.compile(r"\A{}\Z".format(re.escape(self.options["text"])))
            else:
                regex = toregex(self.options["text"])

            text = normalize_text(
                node.all_text if visible == "all" else node.visible_text)

            if not regex.search(text):
                return False

        if isinstance(self.exact_text, (bytes_, str_)):
            regex = re.compile(r"\A{}\Z".format(re.escape(self.exact_text)))

            text = normalize_text(
                node.all_text if visible == "all" else node.visible_text)

            if not regex.search(text):
                return False

        if visible == "visible":
            if not node.visible:
                return False
        elif visible == "hidden":
            if node.visible:
                return False

        for name, node_filter in iter(self._node_filters.items()):
            if name in self.filter_options:
                if not node_filter.matches(node, self.filter_options[name]):
                    return False
            elif node_filter.has_default:
                if not node_filter.matches(node, node_filter.default):
                    return False

        if self.options["filter"] and not self.options["filter"](node):
            return False

        return True
def matches_filters(self, node):
        visible = self.visible

        if self.options["text"]:
            if isregex(self.options["text"]):
                regex = self.options["text"]
            elif self.exact_text is True:
                regex = re.compile(r"\A{}\Z".format(re.escape(self.options["text"])))
            else:
                regex = toregex(self.options["text"])

            text = normalize_text(
                node.all_text if visible == "all" else node.visible_text)

            if not regex.search(text):
                return False

        if isinstance(self.exact_text, (bytes_, str_)):
            regex = re.compile(r"\A{}\Z".format(re.escape(self.exact_text)))

            text = normalize_text(
                node.all_text if visible == "all" else node.visible_text)

            if not regex.search(text):
                return False

        if visible == "visible":
            if not node.visible:
                return False
        elif visible == "hidden":
            if node.visible:
                return False

        for name, node_filter in iter(self._node_filters.items()):
            if name in self.filter_options:
                if not node_filter.matches(node, self.filter_options[name]):
                    return False
            elif node_filter.has_default:
                if not node_filter.matches(node, node_filter.default):
                    return False

        if self.options["filter"] and not self.options["filter"](node):
            return False

        return True
def matches_filters ( self , node ) : visible = self . visible if self . options [ "text" ] : if isregex ( self . options [ "text" ] ) : regex = self . options [ "text" ] elif self . exact_text is True : regex = re . compile ( r"\A{}\Z" . format ( re . escape ( self . options [ "text" ] ) ) ) else : regex = toregex ( self . options [ "text" ] ) text = normalize_text ( node . all_text if visible == "all" else node . visible_text ) if not regex . search ( text ) : return False if isinstance ( self . exact_text , ( bytes_ , str_ ) ) : regex = re . compile ( r"\A{}\Z" . format ( re . escape ( self . exact_text ) ) ) text = normalize_text ( node . all_text if visible == "all" else node . visible_text ) if not regex . search ( text ) : return False if visible == "visible" : if not node . visible : return False elif visible == "hidden" : if node . visible : return False for name , node_filter in iter ( self . _node_filters . items ( ) ) : if name in self . filter_options : if not node_filter . matches ( node , self . filter_options [ name ] ) : return False elif node_filter . has_default : if not node_filter . matches ( node , node_filter . default ) : return False if self . options [ "filter" ] and not self . options [ "filter" ] ( node ) : return False return True
Returns whether the given node matches all filters.

        Args:
            node (Element): The node to evaluate.

        Returns:
            bool: Whether the given node matches.
Returns whether the given node matches all filters .