Repository: plotly/dash
File: dash/testing/wait.py (Python)

Code before:
        self.text = text

    def __call__(self, driver):
        try:
            elem = driver.find_element(By.CSS_SELECTOR, self.selector)
            logger.debug("contains text {%s} => expected %s", elem.text, self.text)
            return self.text in str(elem.text) or self.text in str(
                elem.get_attribute("value")
            )
        except WebDriverException:
            return False


class contains_class:
    def __init__(self, selector, classname):
        self.selector = selector
        self.classname = classname

    def __call__(self, driver):
        try:
            elem = driver.find_element(By.CSS_SELECTOR, self.selector)
            classname = elem.get_attribute("class")
            logger.debug(
                "contains class {%s} => expected %s", classname, self.classname
            )
            return self.classname in str(classname)
        except WebDriverException:
            return False


class text_to_equal:
    def __init__(self, selector, text):
        self.selector = selector
        self.text = text

    def __call__(self, driver):
        try:
            elem = driver.find_element(By.CSS_SELECTOR, self.selector)
            logger.debug("text to equal {%s} => expected %s", elem.text, self.text)
            return (
                str(elem.text) == self.text
                or str(elem.get_attribute("value")) == self.text
            )
        except WebDriverException:
            return False


class style_to_equal:
    def __init__(self, selector, style, val):
        self.selector = selector
        self.style = style

Review comment (suggestion):
```suggestion
            return self.classname in str(classname).split(" ")
```
So we don't match part of a longer class, only an exact match of one of the classes.

Code after:
        self.text = text

    def __call__(self, driver):
        try:
            elem = driver.find_element(By.CSS_SELECTOR, self.selector)
            logger.debug("contains text {%s} => expected %s", elem.text, self.text)
            return self.text in str(elem.text) or self.text in str(
                elem.get_attribute("value")
            )
        except WebDriverException:
            return False


class contains_class:
    def __init__(self, selector, classname):
        self.selector = selector
        self.classname = classname

    def __call__(self, driver):
        try:
            elem = driver.find_element(By.CSS_SELECTOR, self.selector)
            classname = elem.get_attribute("class")
            logger.debug(
                "contains class {%s} => expected %s", classname, self.classname
            )
            return self.classname in str(classname).split(" ")
        except WebDriverException:
            return False


class text_to_equal:
    def __init__(self, selector, text):
        self.selector = selector
        self.text = text

    def __call__(self, driver):
        try:
            elem = driver.find_element(By.CSS_SELECTOR, self.selector)
            logger.debug("text to equal {%s} => expected %s", elem.text, self.text)
            return (
                str(elem.text) == self.text
                or str(elem.get_attribute("value")) == self.text
            )
        except WebDriverException:
            return False


class style_to_equal:
    def __init__(self, selector, style, val):
        self.selector = selector
        self.style = style