Another way to check (assert) if text exists using Selenium Python

When using Selenium IDE to check if text exists in an element, regex is usually auto coded by the tool, something like this, when looking for the existence of the word Weather:

self.assertRegexpMatches(self.driver.find_element_by_xpath("html/body/div[1]/div[2]/div/div[1]/label").text, r"^[\s\S]*Weather[\s\S]*$")

Sometimes it is easier just to use “assert in” like this:

assert "Weather" in 

change elements according to your situation