Giter VIP home page Giter VIP logo

Comments (6)

sindresorhus avatar sindresorhus commented on August 11, 2024

The element must be loaded when the page is loaded. If it's loaded dynamically/lazily, you must use the waitForElement option.

I cannot really help more than that without code that reproduces the issue.

from capture-website.

gaminfish avatar gaminfish commented on August 11, 2024

I don't believe that the elements are loaded lazily but I am using waitForElement here's the code:
image
(it appeared strangely when I copied and pasted it so here's an image instead)

from capture-website.

sgtrusty avatar sgtrusty commented on August 11, 2024

Try using

image
E.G.:

 // code here 

syntax in order to let us test your code. Or add it to a pen/jsfiddle.

from capture-website.

mre avatar mre commented on August 11, 2024

I have the same problem.

const captureWebsite = require('capture-website');

(async () => {
  await captureWebsite.file('https://github.com/sindresorhus/capture-website', 'screenshot.png', { scrollToElement: "#readme" });
})()

This takes a screenshot from the top of the page.

image

Node version 12.18.3, capture-website 1.2.1.
What am I doing wrong?

(Edit: attached screenshot)

from capture-website.

 avatar commented on August 11, 2024

I believe this is the issue: https://github.com/sindresorhus/capture-website/blob/master/index.js#L71-L75

Before we try to scroll the parentElement we should also scroll the body so that the parent element is visible. Currently we try to scroll elements that are not scrollable and/or outside of the viewport.

parentElement.scrollIntoView(true) something like this is missing

from capture-website.

mre avatar mre commented on August 11, 2024

Thanks for the research. It worked for me so I created a PR.

from capture-website.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.