{"id":13415469,"url":"https://github.com/checkly/puppeteer-examples","last_synced_at":"2025-10-01T00:31:50.847Z","repository":{"id":45157044,"uuid":"105864784","full_name":"checkly/puppeteer-examples","owner":"checkly","description":"Puppeteer example scripts for running Headless Chrome from Node.","archived":true,"fork":false,"pushed_at":"2020-10-01T07:27:17.000Z","size":527,"stargazers_count":3051,"open_issues_count":14,"forks_count":501,"subscribers_count":95,"default_branch":"master","last_synced_at":"2025-09-29T12:40:14.184Z","etag":null,"topics":["developer-tools","headless-chrome","jest","monitoring","node","nodejs","puppeteer","testing"],"latest_commit_sha":null,"homepage":"https://checklyhq.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/checkly.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-05T08:12:01.000Z","updated_at":"2025-09-24T04:55:57.000Z","dependencies_parsed_at":"2022-07-13T16:47:59.509Z","dependency_job_id":null,"html_url":"https://github.com/checkly/puppeteer-examples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/checkly/puppeteer-examples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/checkly%2Fpuppeteer-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/checkly%2Fpuppeteer-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/checkly%2Fpuppeteer-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/checkly%2Fpuppeteer-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/checkly","download_url":"https://codeload.github.com/checkly/puppeteer-examples/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/checkly%2Fpuppeteer-examples/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277777968,"owners_count":25875397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-30T02:00:09.208Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["developer-tools","headless-chrome","jest","monitoring","node","nodejs","puppeteer","testing"],"created_at":"2024-07-30T21:00:49.427Z","updated_at":"2025-10-01T00:31:50.502Z","avatar_url":"https://github.com/checkly.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","例子","testing","Examples"],"sub_categories":["贡献"],"readme":"# Puppeteer examples\n\n\n\u003e Deprecation notice: We are moving our efforts to [theheadless.dev](https://github.com/checkly/theheadless.dev), a new free \u0026 open source knowledge base for Puppeteer AND Playwright. Idea is the same: practical examples and guides, by the community. We — the team at Checkly — are going to pour a lot of love \u0026 care into this new project. Feel free to [contribute!](https://github.com/checkly/theheadless.dev/blob/master/CONTRIBUTING.md)\n\nPuppeteer Headless Chrome examples for real life use cases. Clone this repo and run them directy with a simple `node` command.\n\n```bash\ngit clone https://github.com/checkly/puppeteer-examples\ncd puppeteer-examples\nnpm i\nnode 2.\\ search/amazon.js\n```\nYou can run these scripts in the [puppeteer sandbox](https://puppeteersandbox.com).\n\n- [1. basics](#1-basics)\n  * [alerts](#alerts)\n  * [Download file / upload file](#download-file-upload-file)\n  * [emulate devices](#emulate-devices)\n  * [get the value of common form elements](#get-the-value-of-common-form-elements)\n  * [get list of links](#get-list-of-links)\n  * [get text value of an element](#get-text-value-of-an-element)\n  * [get title](#get-title)\n  * [hover](#hover)\n  * [keyboard](#keyboard)\n  * [location_faker](#location-faker)\n  * [mouse](#mouse)\n  * [pdf](#pdf)\n  * [request interception](#request-interception)\n  * [screenshots](#screenshots)\n  * [screenshots clipped](#screenshots-clipped)\n  * [set cookie](#set-cookie)\n- [2. search](#2-search)\n  * [Amazon search](#amazon-search)\n  * [Booking.com search](#booking-com-search)\n  * [Duck Duck Go search](#duck-duck-go-search)\n  * [Youtube search](#youtube-search)\n- [3. login](#3-login)\n  * [Github](#github)\n  * [Google Social Login](#google-social-login)\n  * [Instagram](#instagram)\n  * [Microsoft Live Login](#microsoft-live-login)\n- [4. shopping-carts](#4-shopping-carts)\n  * [Staples shopping cart](#staples-shopping-cart)\n  * [Walmart shopping cart](#walmart-shopping-cart)\n- [5. parallel-pages](#5-parallel-pages)\n  * [Screenshots parallel pages](#screenshots-parallel-pages)\n  * [Screenshots parallel pages in batches](#screenshots-parallel-pages-in-batches)\n- [a. mocha-tests](#a-mocha-tests)\n  * [Alibaba product search](#alibaba-product-search)\n  * [Amazon product search](#amazon-product-search)\n  * [codesandbox.io](#codesandbox-io)\n  * [Duck Duck Go search](#duck-duck-go-search)\n  * [Etsy shopping cart](#etsy-shopping-cart)\n  * [Gmail signup](#gmail-signup)\n  * [Google search](#google-search)\n  * [Staples shopping cart](#staples-shopping-cart)\n  * [Walmart shopping cart](#walmart-shopping-cart)\n- [b. jest-tests](#b-jest-tests)\n  * [Alibaba product search](#alibaba-product-search)\n  * [Amazon product search](#amazon-product-search)\n  * [codesandbox.io](#codesandbox-io)\n  * [Etsy shopping cart](#etsy-shopping-cart)\n  * [Google search](#google-search)\n  * [Walmart shopping cart](#walmart-shopping-cart)\n\n\n## 1. basics\nThe very basic on getting useful info from web page. Highlights the basic Puppeteer functions.  \n### alerts\nCreate an alert dialog and close it again.\n\n\n[1. basics/alerts.js](https://github.com/checkly/puppeteer-examples/blob/master/1.%20basics/alerts.js)\n### Download file / upload file\nFind an image by class selector, downloads the image, saves it to disk and read it again. Use this together with a .fileUpload() method.\n\n\n[1. basics/download_upload.js](https://github.com/checkly/puppeteer-examples/blob/master/1.%20basics/download_upload.js)\n### emulate devices\nUse the built in devices descriptors to emulate an Iphone 6. These are actually shortcuts for calling page.setUserAgent() and page.setViewPort().\n\n\n[1. basics/emulate_devices.js](https://github.com/checkly/puppeteer-examples/blob/master/1.%20basics/emulate_devices.js)\n### get the value of common form elements\nGets the value of commonly used HTML form elements using page.$eval()\n\n\n[1. basics/forms.js](https://github.com/checkly/puppeteer-examples/blob/master/1.%20basics/forms.js)\n### get list of links\nScrapes Hacker News for links on the home page and returns the top 10\n\n\n[1. basics/get_list_of_links.js](https://github.com/checkly/puppeteer-examples/blob/master/1.%20basics/get_list_of_links.js)\n### get text value of an element\nGets the text value of an element by using the page.$eval method\n\n\n[1. basics/get_text_value.js](https://github.com/checkly/puppeteer-examples/blob/master/1.%20basics/get_text_value.js)\n### get title\nGet the title of a page and print it to the console.\n\n\n[1. basics/get_title.js](https://github.com/checkly/puppeteer-examples/blob/master/1.%20basics/get_title.js)\n### hover\nThe hover function is a combination of scrolling and putting the mouse into a hover state over the requested element. This example hovers the first track we find on the soundcloud.com homepage, which should trigger the play and like buttons to be visible\n\n\n[1. basics/hover.js](https://github.com/checkly/puppeteer-examples/blob/master/1.%20basics/hover.js)\n### keyboard\ntypes into a text editor\n\n\n[1. basics/keyboard.js](https://github.com/checkly/puppeteer-examples/blob/master/1.%20basics/keyboard.js)\n### location_faker\nFake the location for the geolocation API used by the browsers\n\n\n[1. basics/location_faker.js](https://github.com/checkly/puppeteer-examples/blob/master/1.%20basics/location_faker.js)\n### mouse\nMost of the things you can click using straight .click() handlers, but for some situation directly instructing the mouse might be convenient. This example load a page that plays back what mouse actions are used on the page.\n\n\n[1. basics/mouse.js](https://github.com/checkly/puppeteer-examples/blob/master/1.%20basics/mouse.js)\n### pdf\nRenders a PDF of the Puppeteer API spec. This is a pretty long page and will generate a nice, A4 size multi-page PDF.\n\n\n[1. basics/pdf.js](https://github.com/checkly/puppeteer-examples/blob/master/1.%20basics/pdf.js)\n### request interception\nUses Puppeteer request interception, blocks images from loading, then snaps a basic screenshot of the full New York Time homepage and saves it a .png file.\n\n\n[1. basics/request_interception.js](https://github.com/checkly/puppeteer-examples/blob/master/1.%20basics/request_interception.js)\n### screenshots\nSnaps a basic screenshot of the full New York Time homepage and saves it a .png file.\n\n\n[1. basics/screenshots.js](https://github.com/checkly/puppeteer-examples/blob/master/1.%20basics/screenshots.js)\n### screenshots clipped\nGrabs and clips out just the stock tickers on the Yahoo finance page\n\n\n[1. basics/screenshots_clipped.js](https://github.com/checkly/puppeteer-examples/blob/master/1.%20basics/screenshots_clipped.js)\n### set cookie\nSets the \"login_email\" property in a Paypal cookie so the login screen is pre-filled with an email address.\n\n\n[1. basics/set_cookie.js](https://github.com/checkly/puppeteer-examples/blob/master/1.%20basics/set_cookie.js)\n## 2. search\nCommon search input and select methods on search results.  \n### Amazon search\nLooks for a \"nyan cat pullover\" on amazon.com, goes two page two clicks the third one.\n\n\n[2. search/amazon.js](https://github.com/checkly/puppeteer-examples/blob/master/2.%20search/amazon.js)\n### Booking.com search\nFinds accommodations in Berlin on Booking.com, takes a screenshot and logs the top 10.\n\n\n[2. search/booking.js](https://github.com/checkly/puppeteer-examples/blob/master/2.%20search/booking.js)\n### Duck Duck Go search\nundefined\n\n\n[2. search/duck_duck_go.js](https://github.com/checkly/puppeteer-examples/blob/master/2.%20search/duck_duck_go.js)\n### Youtube search\nLooks for Fleetwood Mac's \"Dreams\" video on youtube.com and clicks on the third video. Waits for 5 seconds for the video to load.\n\n\n[2. search/youtube.js](https://github.com/checkly/puppeteer-examples/blob/master/2.%20search/youtube.js)\n## 3. login\nCommon login scenarios on popular website. Credentials mostly supplied with setting `ENV` variables.  \n### Github\nLogs into Github. Provide your username and password as environment variables when running the script, i.e: `GITHUB_USER=myuser GITHUB_PWD=mypassword node github.js`\n\n\n[3. login/github.js](https://github.com/checkly/puppeteer-examples/blob/master/3.%20login/github.js)\n### Google Social Login\nLogs into Checkly using Google social Login. Provide your username and password as environment variables when running the script, i.e: `GOOGLE_USER=myuser GOOGLE_PWD=mypassword node google_social.js`\n\n\n[3. login/google_social.js](https://github.com/checkly/puppeteer-examples/blob/master/3.%20login/google_social.js)\n### Instagram\nLogs into Instagram with credentials. Provide your username and password as environment variables when running the script, i.e: `INSTAGRAM_USER=myuser INSTAGRAM_PWD=mypassword node instagram.js`\n\n\n[3. login/instagram.js](https://github.com/checkly/puppeteer-examples/blob/master/3.%20login/instagram.js)\n### Microsoft Live Login\nLogs into MS Live. Provide your username and password as environment variables when running the script, i.e: linux: MSLIVE_USER=myuser MSLIVE_PWD=mypassword node mslive.js Windows users: SET MSLIVE_USER=myuser SET MSLIVE_PWD=mypassword node mslive.js for more info see here: https://stackoverflow.com/questions/9249830/how-can-i-set-node-env-production-on-windows\n\n\n[3. login/mslive.js](https://github.com/checkly/puppeteer-examples/blob/master/3.%20login/mslive.js)\n## 4. shopping-carts\nHow to handle shopping cart functions like adding and removing items.  \n### Staples shopping cart\nGoes to the face paint category and adds to the shopping cart.\n\n\n[4. shopping-carts/staples.js](https://github.com/checkly/puppeteer-examples/blob/master/4.%20shopping-carts/staples.js)\n### Walmart shopping cart\nLooks for a Nintendo's Mario Odyssey and adds it to the shopping cart.\n\n\n[4. shopping-carts/walmart.js](https://github.com/checkly/puppeteer-examples/blob/master/4.%20shopping-carts/walmart.js)\n## 5. parallel-pages\nHow to handle Allow parallel processing pages.  \n### Screenshots parallel pages\nAllow parallel processing screenshot\n\n\n[5. parallel-pages/screenshots_parallel.js](https://github.com/checkly/puppeteer-examples/blob/master/5.%20parallel-pages/screenshots_parallel.js)\n### Screenshots parallel pages in batches\nparallel screenshotting of an array of Websites with small example\n\n\n[5. parallel-pages/screenshots_parallel_cologne_colleges.js](https://github.com/checkly/puppeteer-examples/blob/master/5.%20parallel-pages/screenshots_parallel_cologne_colleges.js)\n## A. mocha-tests\nMocha test runner scripts that use Puppeteer and the standard `assert` library to check specific properties and actions on a page. They can be executed like: \n\n```bash\ncd \"a. mocha-tests\"\nnpx mocha alibaba.js\n```  \n### Alibaba product search\nSearches Alibaba.com for a product and checks if the results show up\n\n\n[a. mocha-tests/alibaba.js](https://github.com/checkly/puppeteer-examples/blob/master/a.%20mocha-tests/alibaba.js)\n### Amazon product search\nSearches Amazon.com for a product and checks if the results show up\n\n\n[a. mocha-tests/amazon.js](https://github.com/checkly/puppeteer-examples/blob/master/a.%20mocha-tests/amazon.js)\n### codesandbox.io\nGoes to codesandbox.io, creates a new sandbox and selects the Vue.js template\n\n\n[a. mocha-tests/codesandbox.js](https://github.com/checkly/puppeteer-examples/blob/master/a.%20mocha-tests/codesandbox.js)\n### Duck Duck Go search\nGoes to duckduckgo.com, searches for \"chrome puppeteer\", asserts the result and snaps a screenshots\n\n\n[a. mocha-tests/duck_duck_go.js](https://github.com/checkly/puppeteer-examples/blob/master/a.%20mocha-tests/duck_duck_go.js)\n### Etsy shopping cart\nGoes to etsy.com, select the first knick knack and adds it to the shopping cart.\n\n\n[a. mocha-tests/etsy.js](https://github.com/checkly/puppeteer-examples/blob/master/a.%20mocha-tests/etsy.js)\n### Gmail signup\nChecks the signup flow from the landing page. Clicks the\n\n\n[a. mocha-tests/gmail.js](https://github.com/checkly/puppeteer-examples/blob/master/a.%20mocha-tests/gmail.js)\n### Google search\nSearches Google.com for a term and checks if the first link matches. This check should fail.\n\n\n[a. mocha-tests/google.js](https://github.com/checkly/puppeteer-examples/blob/master/a.%20mocha-tests/google.js)\n### Staples shopping cart\nGoes to staples.com and adds a some facepaint to an empty shopping cart. Validates the correct amount.\n\n\n[a. mocha-tests/staples.js](https://github.com/checkly/puppeteer-examples/blob/master/a.%20mocha-tests/staples.js)\n### Walmart shopping cart\nGoes to walmart.com and adds a Nintendo game to an empty shopping cart. Validates the correct amount.\n\n\n[a. mocha-tests/walmart.js](https://github.com/checkly/puppeteer-examples/blob/master/a.%20mocha-tests/walmart.js)\n## B. jest-tests\nJest test runner scripts that use Puppeteer to check specific properties and actions on a page. Very similar to the Mocha tests, but using the Jest `expect` assertions. Install Jest as a global dependency and run them as any other script\n\n```bash\nnpm i -g jest\njest jest-tests/alibaba.js\n```  \n### Alibaba product search\nSearches Alibaba.com for a product and checks if the results show up\n\n\n[b. jest-tests/alibaba.spec.js](https://github.com/checkly/puppeteer-examples/blob/master/b.%20jest-tests/alibaba.spec.js)\n### Amazon product search\nSearches Amazon.com for a product and checks if the results show up\n\n\n[b. jest-tests/amazon.spec.js](https://github.com/checkly/puppeteer-examples/blob/master/b.%20jest-tests/amazon.spec.js)\n### codesandbox.io\nGoes to codesandbox.io, creates a new sandbox and selects the Vue.js template\n\n\n[b. jest-tests/codesandbox.spec.js](https://github.com/checkly/puppeteer-examples/blob/master/b.%20jest-tests/codesandbox.spec.js)\n### Etsy shopping cart\nGoes to etsy.com, select the first knick knack and adds it to the shopping cart.\n\n\n[b. jest-tests/etsy.spec.js](https://github.com/checkly/puppeteer-examples/blob/master/b.%20jest-tests/etsy.spec.js)\n### Google search\nSearches Google.com for a term and checks if the first link matches. This check should fail.\n\n\n[b. jest-tests/google.spec.js](https://github.com/checkly/puppeteer-examples/blob/master/b.%20jest-tests/google.spec.js)\n### Walmart shopping cart\nGoes to walmart.com and adds a Nintendo game to an empty shopping cart. Validates the correct amount.\n\n\n[b. jest-tests/walmart.spec.js](https://github.com/checkly/puppeteer-examples/blob/master/b.%20jest-tests/walmart.spec.js)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheckly%2Fpuppeteer-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcheckly%2Fpuppeteer-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheckly%2Fpuppeteer-examples/lists"}