#NEWLINE# def wait_for_text_visible( driver , text , selector , by = By . CSS_SELECTOR , timeout = settings . LARGE_TIMEOUT ) : #NEWLINE# #INDENT# '\n    Searches for the specified element by the given selector. Returns the\n    element object if the text is present in the element and visible\n    on the page. Raises an exception if the text or element do not appear\n    in the specified timeout.\n    @Params\n    driver - the webdriver object (required)\n    text - the text that is being searched for in the element (required)\n    selector - the locator that is used (required)\n    by - the method to search for the locator (Default: By.CSS_SELECTOR)\n    timeout - the time to wait for elements in seconds\n    @Returns\n    A web element object that contains the text searched for\n    ' #NEWLINE# element = None #NEWLINE# for x in range ( int ( ( timeout * 10 ) ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# element = driver . find_element ( by = by , value = selector ) #NEWLINE# if element . is_displayed ( ) : #NEWLINE# #INDENT# if ( text in element . text ) : #NEWLINE# #INDENT# return element #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# element = None #NEWLINE# raise Exception ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except Exception : #NEWLINE# #INDENT# time . sleep ( 0.1 ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not element ) : #NEWLINE# #INDENT# raise ElementNotVisibleException ( ( 'Expected text [%s] for [%s] was not visible after %s seconds!' % ( text , selector , timeout ) ) )