def waitfor(css_selector, text=None, classes=None):
    """
    Decorator for specifying elements (selected by a CSS-style selector) to
    explicitly wait for before taking a screenshot. If text is set, wait for the
    element to contain that text before taking the screenshot. If classes is
    present, wait until the element has all classes.
    """
    def decorator(method):
        if not isinstance(getattr(method, '__waitfors', None), list):
            setattr(method, '__waitfors', [])
        method.__waitfors.append({
            'css_selector': css_selector,
            'text': text,
            'classes': classes
        })
        return method
    return decorator