Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Screenshots are only getting inline styles, no css #280

Open
JoeVanGundy opened this issue Jul 22, 2022 · 1 comment
Open

[BUG] Screenshots are only getting inline styles, no css #280

JoeVanGundy opened this issue Jul 22, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@JoeVanGundy
Copy link

Environment

  • chrome-aws-lambda Version: 10.1.0
  • puppeteer / puppeteer-core Version: 10.1.0
  • OS: Mac
  • Node.js Version: 16.15.1
  • Lambda / GCF Runtime: nodejs12.x

Expected Behavior

When I take a screenshot, the results include all styles that the component included.

Current Behavior

I'm testing my lambda locally.
When I take a screenshot of any site, no css is included.
The only thing that works are inline styles.

Could this be because I'm testing locally?
Or could there be some css configuration that I need to include to puppeteer?
Any help is super appreciated!

Steps to Reproduce

let result = null;
  let browser = null;

  try {
    browser = await chromium.puppeteer.launch({
      args: chromium.args,
      defaultViewport: chromium.defaultViewport,
      executablePath: await chromium.executablePath,
      headless: chromium.headless,
      ignoreHTTPSErrors: true,
    });

    const page = await browser.newPage();

    await page.setViewport({
      width: 1002,
      height: 402,
      deviceScaleFactor: 2,
    });

    const node = (
      <html>
        <body
          style={{
            width: "1000px",
            minWidth: "1000px",
            height: "400px",
            padding: "0 !important",
            margin: "0 !important",
            overflow: "hidden !important",
          }}
        >
          <PlotRenderer plotData={plotData} />
        </body>
      </html>
    );
    const svgString = ReactDOMServer.renderToString(node);

    await page.setContent(svgString);
    const image = await page.screenshot();
@JoeVanGundy JoeVanGundy added the bug Something isn't working label Jul 22, 2022
@pavelloz
Copy link

Have you tried experimenting with waitUntil?
https://blog.cloudlayer.io/puppeteer-waituntil-options/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants