#NEWLINE# def wait_for_ready_state_complete( driver , timeout = settings . EXTREME_TIMEOUT ) : #NEWLINE# #INDENT# '\n    The DOM (Document Object Model) has a property called "readyState".\n    When the value of this becomes "complete", page resources are considered\n    fully loaded (although AJAX and other loads might still be happening).\n    This method will wait until document.readyState == "complete".\n    ' #NEWLINE# for x in range ( int ( ( timeout * 10 ) ) ) : #NEWLINE# #INDENT# ready_state = driver . execute_script ( 'return document.readyState' ) #NEWLINE# if ( ready_state == 'complete' ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# time . sleep ( 0.1 ) #NEWLINE# #UNINDENT# #UNINDENT# raise Exception ( ( 'Page elements never fully loaded after %s seconds!' % timeout ) )