def wait_for_text_visible(driver, text, selector, by=By.CSS_SELECTOR,<EOL>timeout=settings.LARGE_TIMEOUT):
element = None<EOL>start_ms = time.time() * <NUM_LIT><EOL>stop_ms = start_ms + (timeout * <NUM_LIT>)<EOL>for x in range(int(timeout * <NUM_LIT:10>)):<EOL><INDENT>try:<EOL><INDENT>element = driver.find_element(by=by, value=selector)<EOL>if element.is_displayed() and text in element.text:<EOL><INDENT>return element<EOL><DEDENT>else:<EOL><INDENT>element = None<EOL>raise Exception()<EOL><DEDENT><DEDENT>except Exception:<EOL><INDENT>now_ms = time.time() * <NUM_LIT><EOL>if now_ms >= stop_ms:<EOL><INDENT>break<EOL><DEDENT>time.sleep(<NUM_LIT:0.1>)<EOL><DEDENT><DEDENT>plural = "<STR_LIT:s>"<EOL>if timeout == <NUM_LIT:1>:<EOL><INDENT>plural = "<STR_LIT>"<EOL><DEDENT>if not element:<EOL><INDENT>raise ElementNotVisibleException(<EOL>"<STR_LIT>" %<EOL>(text, selector, timeout, plural))<EOL><DEDENT>
Searches for the specified element by the given selector. Returns the
element object if the text is present in the element and visible
on the page. Raises an exception if the text or element do not appear
in the specified timeout.
@Params
driver - the webdriver object (required)
text - the text that is being searched for in the element (required)
selector - the locator that is used (required)
by - the method to search for the locator (Default: By.CSS_SELECTOR)
timeout - the time to wait for elements in seconds
@Returns
A web element object that contains the text searched for