Comments (6)
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.
I don't believe that the elements are loaded lazily but I am using waitForElement here's the code:
(it appeared strangely when I copied and pasted it so here's an image instead)
from capture-website.
Try using
// code here
syntax in order to let us test your code. Or add it to a pen/jsfiddle.
from capture-website.
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.
Node version 12.18.3
, capture-website 1.2.1
.
What am I doing wrong?
(Edit: attached screenshot)
from capture-website.
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.
Thanks for the research. It worked for me so I created a PR.
from capture-website.
Related Issues (20)
- Capturing elements inside `#shadow-root` HOT 2
- Can it be changed using networkidle0 or open options HOT 1
- Error: Could not find expected browser (chrome) locally on version 1.4.0 CJS HOT 3
- Feature Request: use puppeteer-core when Chrome is available in system HOT 3
- Error: createRequire only supports 'file://' URLs for the 'filename' parameter. HOT 1
- Support PDF as output type HOT 4
- Feature: Option for allowing CORS
- TLS certificate HOT 1
- Consider replacing Puppeteer with Playwright HOT 2
- Could be useful to support a commonjs version HOT 2
- Consider add some code or event handler before goto page
- engine.bin size keeps on increasing untill no space left on device
- How to pass proxy configuration ? HOT 1
- Recommendation for multiple URL performance? HOT 1
- Class extends value undefined is not a constructor or null (NuxtJS) HOT 1
- [Feature Request] - Allow redirection of page console output to host console.log without forcing headless = false HOT 2
- Akamai error with TLS
- Video thumbnails not displaying
- Does not work on Vercel Serverless functions — "Could not find browser (chrome) locally" HOT 1
- Reading from "node:fs" is not handled by plugins (Unhandled scheme) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from capture-website.