If there is a screenshot, save it as screenshot.jpg in the same folder as the results
192087
function saveScreenshotIfExists(testResults) {
        var deferred = Q.defer();

        if (testResults.screenshotBuffer) {

            var screenshotFilePath = path.join(resultsDir, testResults.runId, resultScreenshotName);
            fs.writeFile(screenshotFilePath, testResults.screenshotBuffer);

            delete testResults.screenshotBuffer;

        } else {
            deferred.resolve();
        }

        return deferred;
    }
135679
def create_screenshot(self, app_id, filename, position=1):
        
        # prepare file for upload
        with open(filename, 'rb') as s_file:
            s_content = s_file.read()
        s_encoded = b64encode(s_content)
        url = self.url('create_screenshot') % app_id

        mtype, encoding = mimetypes.guess_type(filename)
        if mtype is None:
            mtype = 'image/jpeg'

        data = {'position': position,
                'file': {'type': mtype,
                         'data': s_encoded}}
        return self.conn.fetch('POST', url, data)
51679
def record_result(self, res, prg=''):
        
        self._log(self.logFileResult , force_to_string(res), prg)
740021
def saveScreenCapture(self, path=None, name=None):
        
        bitmap = self.getBitmap()
        target_file = None
        if path is None and name is None:
            _, target_file = tempfile.mkstemp(".png")
        elif name is None:
            _, tpath = tempfile.mkstemp(".png")
            target_file = os.path.join(path, tfile)
        else:
            target_file = os.path.join(path, name+".png")
        cv2.imwrite(target_file, bitmap)
        return target_file
491306
def screenshot(filename, width=None, height=None):
    '''
    
    '''
    width = width or viewer.widget.width()
    height = height or viewer.widget.height()
    
    img = viewer.widget.toimage(width, height)
    img.save(filename)
754757
def take_screenshot(self):
    """"""

    if not self.failed:
        return

    browser = getattr(world, 'browser', None)
    if not browser:
        return

    try:
        scenario_name = self.scenario.name
        scenario_index = \
            self.scenario.feature.scenarios.index(self.scenario) + 1
    except AttributeError:
        scenario_name = self.background.keyword
        scenario_index = 0

    if self.outline is None:
        outline_index_str = ''
    else:
        outline_index = self.scenario.outlines.index(self.outline) + 1
        outline_index_str = '_{}'.format(outline_index)

    base_name = FORMAT.format(
        feature_file=os.path.relpath(self.feature.filename),
        scenario_index=scenario_index,
        scenario_name=scenario_name,
        outline_index=outline_index_str,
    )
    base_name = re.sub(r'\W', '_', base_name, flags=re.UNICODE)
    base_name = os.path.join(DIRECTORY, base_name)

    world.browser.save_screenshot('{}.png'.format(base_name))

    with open('{}.html'.format(base_name), 'w') as page_source_file:
        page_source_file.write(world.browser.page_source)
1343494
def saveViewSnapshot(self, view):
        '''
        
        '''

        if not view:
            raise ValueError("view must be provided to take snapshot")
        filename = self.snapshotDir + os.sep + '${serialno}-' + view.variableNameFromId() + '-${timestamp}' + '.' + self.snapshotFormat.lower()
        d = FileDialog(self, self.device.substituteDeviceTemplate(filename))
        saveAsFilename = d.askSaveAsFilename()
        if saveAsFilename:
            _format = os.path.splitext(saveAsFilename)[1][1:].upper()
            self.printOperation(view, Operation.VIEW_SNAPSHOT, filename, _format)
            view.writeImageToFile(saveAsFilename, _format)
434440
def generate_screenshots(self):
        
        headers = {'content-type': 'application/json', 'Accept': 'application/json'}
        resp = requests.post(self.api_url, data=json.dumps(self.config), \
                             headers=headers, auth=self.auth)
        resp = self._process_response(resp)
        return resp.json()
605705
def save_image(self, cat, img, data):
        """"""
        filename = self.path(cat, img)
        mkdir(filename)
        if type(data) == np.ndarray:
            data = Image.fromarray(data).convert('RGB')
        data.save(filename)
426107
def work(path)
      out = "#{path}/#{@name}.png"
      @fetcher.fetch(output: out, width: @size[0], height: @size[1], dpi: @dpi)
    rescue Screencap::Error
      puts "Fail to capture screenshot #{@url}"
    end
174494
function captureScreenshot (chromy, filePath_, selector, selectorMap, config, selectors) {
  return new Promise(function (resolve, reject) {
    // VIEWPORT screenshot
    if (selector === VIEWPORT_SELECTOR || selector === BODY_SELECTOR) {
      chromy
        .screenshot()
        .result(buffer => {
          return saveViewport(buffer, selector);
        });
    // DOCUMENT screenshot
    } else if (selector === NOCLIP_SELECTOR || selector === DOCUMENT_SELECTOR) {
      chromy.screenshotMultipleSelectors(['body'], saveSelector);
    // OTHER-SELECTOR screenshot
    } else {
      chromy.screenshotMultipleSelectors(selectors, saveSelector);
    }

    chromy
      .end()
      .then(_ => {
        resolve();
      })
      .catch(e => {
        reject(e);
      });

    // result helpers

    // saveViewport: selectors will be `body` or `viewport` ONLY
    function saveViewport (buffer, selector) {
      const filePath = selectorMap[selector].filePath;

      ensureDirectoryPath(filePath);
      return fs.writeFile(filePath, buffer);
    }

    // saveSelector: selectorArr will contain any valid selector (not body or viewport).
    // If body *is* found in selector arr then it was originally DOCUMENT_SELECTOR -- and it will be reset back to DOCUMENT_SELECTOR -- this is because chromy takes a Document shot when BODY is used.
    function saveSelector (err, buffer, index, selectorArr) {
      let selector = selectorArr[index];
      if (selector === BODY_SELECTOR) {
        selector = DOCUMENT_SELECTOR;
      }
      const selectorProps = selectorMap[selector];
      const filePath = selectorProps.filePath;
      if (!selectorProps.exists) {
        return fs.copy(config.env.backstop + SELECTOR_NOT_FOUND_PATH, filePath);
      } else if (!selectorProps.isVisible) {
        return fs.copy(config.env.backstop + HIDDEN_SELECTOR_PATH, filePath);
      } else {
        if (err) {
          console.log('ChromyJS returned an unexpected error while attempting to capture a selector.', err);
          return new Error(err);
        }
        ensureDirectoryPath(filePath);
        return fs.writeFile(filePath, buffer);
      }
    }
  });
}
1230911
def snapshot(self, filename="tmp.png"):
        
        if not filename:
            filename = "tmp.png"
        if self.handle:
            try:
                screenshot(filename, self.handle)
            except win32gui.error:
                self.handle = None
                screenshot(filename)
        else:
            screenshot(filename)

        img = aircv.imread(filename)
        os.remove(filename)

        return img
1144427
def store_shot(self):
        """"""
        def to_str(cregs):
            return ''.join(str(b) for b in cregs)
        key = to_str(self.cregs)
        self.shots_result[key] = self.shots_result.get(key, 0) + 1
1100089
def save_as_png(self, filename, width=300, height=250, render_time=1):
        """"""
        self.driver.set_window_size(width, height)
        self.driver.get('file://{path}/{filename}'.format(
            path=os.getcwd(), filename=filename + ".html"))
        time.sleep(render_time)
        self.driver.save_screenshot(filename + ".png")
813645
def __capture_screenshot(webdriver, folder_location, file_name):
        ""
        # Check folder location exists.
        if not os.path.exists(folder_location):
            os.makedirs(folder_location)

        file_location = os.path.join(folder_location, file_name)

        if isinstance(webdriver, remote.webdriver.WebDriver):
            # If this is a remote webdriver.  We need to transmit the image data
            # back across system boundries as a base 64 encoded string so it can
            # be decoded back on the local system and written to disk.
            base64_data = webdriver.get_screenshot_as_base64()
            screenshot_data = base64.decodestring(base64_data)
            screenshot_file = open(file_location, "wb")
            screenshot_file.write(screenshot_data)
            screenshot_file.close()
        else:
            webdriver.save_screenshot(file_location)
493386
def _save_image(image, filename, return_img=None):
        """"""
        if not image.size:
            raise Exception('Empty image.  Have you run plot() first?')

        # write screenshot to file
        if isinstance(filename, str):
            if isinstance(vtki.FIGURE_PATH, str) and not os.path.isabs(filename):
                filename = os.path.join(vtki.FIGURE_PATH, filename)
            if not return_img:
                return imageio.imwrite(filename, image)
            imageio.imwrite(filename, image)

        return image
967453
protected void writeScreenshot(ScreenshotEntry screenshotEntry) throws IOException {

        int heigth = screenshotEntry.getHeight() * Integer.parseInt(this.configuration.getImageHeight()) / 100;
        int width = screenshotEntry.getWidth() * Integer.parseInt(this.configuration.getImageWidth()) / 100;

        boolean large = width > Integer.parseInt(this.configuration.getMaxImageWidth());

        if (large) {

            writer.append(".").append(screenshotEntry.getPhase().name()).append(NEW_LINE);
            writer.append(screenshotEntry.getLink()).append(" -> file://").append(screenshotEntry.getPath()).append("[")
            .append(this.resourceBundle.getString("asciidoc.reporter.screenshot"))
            .append("]").append(NEW_LINE).append(NEW_LINE);

        } else {

            writer.append(".").append(screenshotEntry.getPhase().name()).append(NEW_LINE);
            writer.append("image::").append(screenshotEntry.getLink())
                .append("[screenshot," + width + "," + heigth + "]")
                .append(NEW_LINE).append(NEW_LINE);
        }

    }