To run the code, open a terminal window and navigate to project directory and type following command node screenshot.jsĪfter the script is finished you should see screenshot in current working directory named google. To install puppeteer package as project dependency type following command and press enter npm install installation, the package.json should look similar to following ) We will be using puppeteer version 5.0.0 as a dependency. Puppeteer comes pre-installed with a recent version of Chromium. Navigate to the desired directory and run below command to create a fresh project npm init -y Prerequisite Node 10.18.1+ Create a new project In this tutorial, we are going to see how we can take a screenshot of a page using puppeteer. I believe that this is because the file's extension is being used to auto-detect the desired mime type, and I had not set the extension initially. Puppeteer can be used to interact with the webpage as a normal user would over the DevTools Protocol. This was previously reported as 3629, but the original reporter closed the report following self diagnosis. By default, puppeteer runs in headless mode. Puppeteer not only provides the capability to take a screenshot but also provides options on how the screenshot should be. const puppeteer require ( 'puppeteer' ) // were using async/await - so we need an async function, that we can run const run async. Lets create a screenshot of the codesnacks homepage. Automatically creating a screenshot of a webpage used to be hard. Puppeteer can be configured to run in headless and GUI mode. We can capture a screenshot of the webpage using screenshot () function present in Puppeteer. Create a screenshot of a webpage with Javascript. Puppeteer is the NodeJs library that provides API to automate Chrome or Chromium browsers.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |