If "jQuery is not defined", use this method to activate it for use.
        This happens because jQuery is not always defined on web sites.

def activate_jquery(driver):
    """ If "jQuery is not defined", use this method to activate it for use.
        This happens because jQuery is not always defined on web sites. """
    try:
        # Let's first find out if jQuery is already defined.
        driver.execute_script("jQuery('html')")
        # Since that command worked, jQuery is defined. Let's return.
        return
    except Exception:
        # jQuery is not currently defined. Let's proceed by defining it.
        pass
    jquery_js = constants.JQuery.MIN_JS
    activate_jquery_script = (
        '''var script = document.createElement('script');'''
        '''script.src = "%s";document.getElementsByTagName('head')[0]'''
        '''.appendChild(script);''' % jquery_js)
    driver.execute_script(activate_jquery_script)
    for x in range(int(settings.MINI_TIMEOUT * 10.0)):
        # jQuery needs a small amount of time to activate.
        try:
            driver.execute_script("jQuery('html')")
            return
        except Exception:
            time.sleep(0.1)
    # Since jQuery still isn't activating, give up and raise an exception
    raise Exception(
        '''Unable to load jQuery on "%s" due to a possible violation '''
        '''of the website's Content Security Policy directive. '''
        '''To override this policy, add "--disable_csp" on the '''
        '''command-line when running your tests.''' % driver.current_url)