Git Product home page Git Product logo

Comments (1)

TillerBurr avatar TillerBurr commented on May 27, 2024

I was just coming to look into this further, but looks like I was beaten to it.

Looking at the function, I think there's a another solution. My thought would be to change

dash/dash/testing/wait.py

Lines 106 to 113 in f7f8fb4

def __call__(self, driver):
try:
elem = self._get_element(driver)
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
)

to

def __call__(self, driver): 
    try:  
        elem = self._get_element(driver) 
        logger.debug("text to equal {%s} => expected %s", elem.text, self.text) 
        value = elem.get_attribute("value")
        value = str(value) if value is not None else None
        return ( 
            str(elem.text) == self.text 
            or value == self.text 
        ) 

That way, the overall functionality of wait_for_text_to_equal doesn't change (except for the "None" case). The only downside is that it would pass if you use dash_duo.wait_for_text_to_equal("#my-div", None, timeout=4), but I don't know how often that would come up.

There is also an issue with wait_for_contains_text. The test

from dash import html
import dash


def test_wait_for_contains_text_none(dash_duo):

    app = dash.Dash(__name__)
    app.layout = html.Div(id="my-div", children="Hello world")
    dash_duo.start_server(app)
    dash_duo.wait_for_contains_text("#my-div", "No", timeout=4)

also passes, but similarly, there is no value and "No" is not in "Hello world".

There are potential issues with wait_for_contains_class and wait_for_class_to_equal, but I imagine those would be far less common.

from dash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.