pythonunit-testingselenium-webdriverwebdriverseleniumbase

How to check if text is visible with seleniumbase?


Using seleniumbase I just want to check if some text is available. I just want to get a boolean flag, indicating text is available (True) or not (False).

The methods provided by seleniumbase seem to throw an exception if the text is not available. Is there another method that just returns a boolean flag, or do I have to use a try/except construct?


Solution

  • Just use self.is_text_visible():

    self.is_text_visible(text, selector="html")
    

    Eg:

    self.is_text_visible("Welcome")
    self.is_text_visible("Welcome", "h1")