schickling/chromeless

Set deviceScaleFactor doesn't work

Open

#367 opened on Dec 22, 2017

View on GitHub
 (2 comments) (0 reactions) (0 assignees)TypeScript (13,240 stars) (606 forks)batch import
enhancementgood first issuehelp wanted

Description

I'm trying to get retina display screenshots using deviceScaleFactorwithout luck so far.

I have an AWS lambda as describing it here, basically using the remote functionality, something like this:

async function run() {
  let chromeless;
  try {
    chromeless = new Chromeless({
      remote: {
        endpointUrl: 'https://xxxxxxx.execute-api.us-west-2.amazonaws.com/dev/',
        apiKey: 'xxxxxxxxxxxxxxxxxxxx'
      },
      viewport: {
        width: 1280,
        height: 5000,
        scale: 2,
        deviceScaleFactor: 2,
      }
    })

    const screenshot = chromeless
      .setViewport({ deviceScaleFactor: 2 })
      .goto(options.url)
      .wait(5000)

    let fullPage = await screenshot.screenshot()

    const response = [{ id: 'Full page', url: fullPage }]
    for (let selector of options.selectors) {
      let url = await screenshot.wait(selector.selector).screenshot(selector.selector)
      selector.url = url
      response.push(selector);
    }

    console.log(JSON.stringify(response))
  } catch(err) {
    console.error(err)
  } finally {
    await chromeless.end()
  }
}

run().catch(console.error.bind(console))

On the above script, I tried to set the option for the remote server and set it in the viewport, none of them have any change in the output, so, going further I looked into the source code for the right option but I found it is hardcoded to 1 here.

so I'm wondering if is it possible to get screenshots with high DPI from chromeless?

Thank you

Contributor guide