def save_driver_logs(driver, prefix):
    log_types = ['browser', 'driver', 'client', 'server']
    for log_type in log_types:
        try:
            log = driver.get_log(log_type)
            file_name = os.path.join(
                os.environ.get('SELENIUM_DRIVER_LOG_DIR', ''), '{}_{}.log'.format(
                    prefix, log_type)
            )
            with open(file_name, 'w') as output_file:
                for line in log:
                    output_file.write("{}{}".format(dumps(line), '\n'))
        except:  # pylint: disable=bare-except
            msg = (
                "Could not save browser log of type '{log_type}'. "
                "It may be that the browser does not support it."
            ).format(log_type=log_type)

            LOGGER.warning(msg, exec_info=True)
Save the selenium driver logs.
dataset/ETHPy150Open edx/bok-choy/bok_choy/browser.py/save_driver_logs