JavaScript Quality of the DOM element screenshot using “captureSelector” in CasperJS

I'm using casperJS to try to get a screenshot of a DOM element using captureSelector, but the quality of the screenshot is really poor, but when capturing full screenshot using capture it works correctly, the quality is correct.

Can anyone help me with this issue? Thanks in advanced.

CasperJS script

var casper = require("casper").create({
  verbose: true,
  logLevel: 'debug',
  pageSettings: {
    loadImages: true,
    loadPlugins: false,
  }
});
// ***************************************************
var viewport_width = 1524;
var viewport_height = 768;
var ua = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36"; 
var filename = "./screenshot_"+new Date().getTime() + "_" + viewport_width + "x" + viewport_height + "_desktop.jpg";
var url = "http://url-here.com";
var lang_header = "fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3";
// ***************************************************
casper.on('remote.message', function(msg) {
  this.log('Remote message caught: ' + msg, "error");
});
casper.on("page.error", function(msg, trace) {
  this.log("Page Error: " + msg, "error");
});
casper.on('load.finished', function (status) {
  if (status !== 'success') {
    this.log("Failed to load page", "error");
  }
  else {
    this.log("The page has been loaded", "info");
  }
});
casper.start();
casper.thenOpen(url, function() {
  this.userAgent(ua);
  this.viewport(viewport_width, viewport_height).then(function() {
    this.wait(5000, function() {
      this.waitForSelector('#dom-element-id', function() {
        this.captureSelector(filename, '#dom-element-id', { quality: 100 });
      });
    });
  });
});
casper.run();

Even using the quality imgOptions parameter I get really poor quality screenshots.

this.captureSelector(filename, '#dom-element-id', { quality: 100 });

PhantomJS: version 1.9.7

CasperJS: version 1.0.2

PD: I didn't put the real urls because is an internal project. Sorry for the inconvenience.

Answer:1

I am developing a windows desktop application using node.js and backbone.js. I want to perform an action when the user closes the app by clicking on the close button on the title bar or right clicking ...

I am developing a windows desktop application using node.js and backbone.js. I want to perform an action when the user closes the app by clicking on the close button on the title bar or right clicking ...

For some reaon, I cannot use nested div, and I m trying to toggle a tree of divs Div id contains any string except - <div class="tree"> <div id="a">id=a click to toggle child</div&...

For some reaon, I cannot use nested div, and I m trying to toggle a tree of divs Div id contains any string except - <div class="tree"> <div id="a">id=a click to toggle child</div&...

I don't want to use the default, + icon, to expand the row. Clicking anywhere on the row should expand it. I tried this: HTML <div ui-grid="gridOptions" ui-grid-expandable class="grid"> ...

I don't want to use the default, + icon, to expand the row. Clicking anywhere on the row should expand it. I tried this: HTML <div ui-grid="gridOptions" ui-grid-expandable class="grid"> ...

  1. ui grid expandable grid example
  2. expandable grid ui-grid

I know it seems like a duplicate but it isn't. Nothing worked, whatever I tried. I have a list in my angular module: this.checkedInterviews = [] and then a function that does: var interviewModel = ...

I know it seems like a duplicate but it isn't. Nothing worked, whatever I tried. I have a list in my angular module: this.checkedInterviews = [] and then a function that does: var interviewModel = ...