<commit_before># -*- coding: utf-8 -*-
#!/usr/bin/python
def load_page(page_url, save_screenshot_filepath = ''):
    import time
    from selenium import webdriver
    seconds_to_load = 0

    driver_path = "/Users/mac/Downloads/chromedriver"
    load_timeout = 300 # seconds
    driver = webdriver.Chrome(driver_path)

    # cleanup cache
    driver.delete_all_cookies()

    # Clean cache
    driver.set_page_load_timeout(load_timeout)

    print "Open page: %s" % (page_url)
    start_clock = time.clock()
    p = driver.get(page_url)
    end_clock = time.clock()
    elapsed_seconds = ((end_clock - start_clock) * 1000)
    print "Page load took: %f seconds." % (elapsed_seconds)

    all_warnings = driver.get_log('browser')
    network_warnings = []
    javascript_warnings = []

    for warning in all_warnings:
        if warning['source'] == 'javascript':
            javascript_warnings.append(warning)
        if warning['source'] == 'network':
            network_warnings.append(warning)

    if len(network_warnings) != 0:
        print "ERROR: network issues are detected when loading the page. Details: %s" \
            % (network_warnings)

    if len(network_warnings) != 0:
        print "ERROR: javascript issues are detected when loading the page. Details: %s" \
            % (javascript_warnings)

    if save_screenshot_filepath != '':
        print "Save screenshot to %s" % (save_screenshot_filepath)
        driver.get_screenshot_as_file(save_screenshot_filepath)
    return elapsed_seconds, all_warnings

if __name__ == '__main__':
    elapsed_seconds, all_warnings = load_page('http://doc.carol.ai', '/tmp/test.png')
    # elapsed_seconds, all_warnings = load_page('http://www.dennyzhang.com', '/tmp/test.png')<commit_msg>bug fixing<commit_after># -*- coding: utf-8 -*-
#!/usr/bin/python
def load_page(page_url, save_screenshot_filepath = ''):
    import time
    from selenium import webdriver
    seconds_to_load = 0
    load_timeout = 300 # seconds

    # driver_path = "/Users/mac/Downloads/chromedriver"
    # driver = webdriver.Chrome(driver_path)
    driver = webdriver.Chrome()

    # cleanup cache
    driver.delete_all_cookies()

    # Clean cache
    driver.set_page_load_timeout(load_timeout)

    print "Open page: %s" % (page_url)
    start_clock = time.clock()
    p = driver.get(page_url)
    end_clock = time.clock()
    elapsed_seconds = ((end_clock - start_clock) * 1000)
    print "Page load took: %f seconds." % (elapsed_seconds)

    all_warnings = driver.get_log('browser')
    network_warnings = []
    javascript_warnings = []

    for warning in all_warnings:
        if warning['source'] == 'javascript':
            javascript_warnings.append(warning)
        if warning['source'] == 'network':
            network_warnings.append(warning)

    if len(network_warnings) != 0:
        print "ERROR: network issues are detected when loading the page. Details: %s" \
            % (network_warnings)

    if len(javascript_warnings) != 0:
        print "ERROR: javascript issues are detected when loading the page. Details: %s" \
            % (javascript_warnings)

    if save_screenshot_filepath != '':
        print "Save screenshot to %s" % (save_screenshot_filepath)
        driver.get_screenshot_as_file(save_screenshot_filepath)
    return elapsed_seconds, all_warnings

if __name__ == '__main__':
    # elapsed_seconds, all_warnings = load_page('http://doc.carol.ai', '/tmp/test.png')
    elapsed_seconds, all_warnings = load_page('http://www.dennyzhang.com', '/tmp/test.png')
{'fraction_non_alphanumeric': 0.11581920903954802, 'fraction_numerical': 0.0062146892655367235, 'mean_word_length': 3.2458033573141485, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5621059', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1107, 'n_words': 244}