def validate_node(self, node, matcher, image):
"""Helper method that matches nodes by given conditions.
Args:
node: Node that is matched
matcher: If it is an instance of regular expression, that one is used, otherwise
equality comparison is used. Against item name.
image: If not None, then after the matcher matches, this will do an additional check for
the image name
Returns:
A :py:class:`bool` if the node is correct or not.
"""
text = self.browser.text(node)
if isinstance(matcher, re._pattern_type):
match = matcher.match(text) is not None
else:
match = matcher == text
if not match:
return False
if image is not None and self.image_getter(node) != image:
return False
return True
评论列表
文章目录