def save_source(driver, name):
    """
    Save the rendered HTML of the browser.

    The location of the source can be configured
    by the environment variable `SAVED_SOURCE_DIR`.  If not set,
    this defaults to the current working directory.

    Args:
        driver (selenium.webdriver): The Selenium-controlled browser.
        name (str): A name to use in the output file name.
            Note that ".html" is appended automatically

    Returns:
        None
    """
    source = driver.page_source
    file_name = os.path.join(os.environ.get('SAVED_SOURCE_DIR'),
                             '{name}.html'.format(name=name))

    try:
        with open(file_name, 'wb') as output_file:
            output_file.write(source.encode('utf-8'))
    except Exception:  # pylint: disable=broad-except
        msg = u"Could not save the browser page source to {}.".format(file_name)
        LOGGER.warning(msg)
def save_source ( driver , name ) : source = driver . page_source file_name = os . path . join ( os . environ . get ( 'SAVED_SOURCE_DIR' ) , '{name}.html' . format ( name = name ) ) try : with open ( file_name , 'wb' ) as output_file : output_file . write ( source . encode ( 'utf-8' ) ) except Exception : msg = u"Could not save the browser page source to {}." . format ( file_name ) LOGGER . warning ( msg )
Save the rendered HTML of the browser.

    The location of the source can be configured
    by the environment variable `SAVED_SOURCE_DIR`.  If not set,
    this defaults to the current working directory.

    Args:
        driver (selenium.webdriver): The Selenium-controlled browser.
        name (str): A name to use in the output file name.
            Note that ".html" is appended automatically

    Returns:
        None