def _make_screenshot(driver, path, clean=False): """ Saves screenshot of the current window in ``path`` folder with file name combined of current test name and date. :type driver: WebDriver or WebElement or ContestoDriver """ if clean: # todo clean screenshots directory pass if driver.capabilities['takesScreenshot']: date_time = datetime.now().strftime('%Y_%m_%d_%H_%M_%S') fname = '%s%s.png' % (str(current_test), date_time) scr_file = os.path.sep.join([path, fname]) if driver.save_screenshot(scr_file): current_test._meta_info['attachments'].append( { 'path': scr_file, 'mime_type': 'image/png', 'name': 'screenshot' } ) else: log.warn("Could not save screenshot for %s" % str(current_test)) else: raise EnvironmentError( 'Option "takesScreenshot" in Capabilities is disabled.\n' 'Please enable option to save screenshot.')
def _make_screenshot(driver, path, clean=False): """ Saves screenshot of the current window in ``path`` folder with file name combined of current test name and date. :type driver: WebDriver or WebElement or ContestoDriver """ if clean: # todo clean screenshots directory pass if driver.capabilities['takesScreenshot']: date_time = datetime.now().strftime('%Y_%m_%d_%H_%M_%S') fname = '%s%s.png' % (str(current_test), date_time) scr_file = os.path.sep.join([path, fname]) if driver.save_screenshot(scr_file): current_test._meta_info['attachments'].append({ 'path': scr_file, 'mime_type': 'image/png', 'name': 'screenshot' }) else: log.warn("Could not save screenshot for %s" % str(current_test)) else: raise EnvironmentError( 'Option "takesScreenshot" in Capabilities is disabled.\n' 'Please enable option to save screenshot.')
def _collect(): _collect_error_details() path = get_path_for_metadata() file = os.path.join(path, '%s.json' % get_filename_base()) try: report_to_file(file) except Exception as e: log.warn('Error reporting test metadata to file: %s', e)
def add_handler(self, handler_name, handler_func): try: self._handlers[handler_name].append(handler_func) except KeyError as e: log.warn(e)