@staticmethod
def enable_download_in_headless_chrome(driver, download_dir):
    """
        there is currently a "feature" in chrome where
        headless does not allow file download: https://bugs.chromium.org/p/chromium/issues/detail?id=696481
        This method is a hacky work-around until the official chromedriver support for this.
        Requires chrome version 62.0.3196.0 or above.
        """
    driver.command_executor._commands['send_command'
        ] = 'POST', '/session/$sessionId/chromium/send_command'
    params = {'cmd': 'Page.setDownloadBehavior', 'params': {'behavior':
        'allow', 'downloadPath': download_dir}}
    command_result = driver.execute('send_command', params)
    print('response from browser:')
    for key in command_result:
        print('result:' + key + ':' + str(command_result[key]))
