def save_screenshot(driver, name):
    if hasattr(driver, 'save_screenshot'):
        image_name = os.path.join(
            os.environ.get('SCREENSHOT_DIR', ''), name + '.png'
        )
        driver.save_screenshot(image_name)

    else:
        msg = (
            "Browser does not support screenshots. "
            "Could not save screenshot '{name}'"
        ).format(name=name)

        LOGGER.warning(msg)
Save a screenshot of the browser.
dataset/ETHPy150Open edx/bok-choy/bok_choy/browser.py/save_screenshot