puppeteer/api.md at main – GitHub
Interactive Documentation: API Translations: 中文|Chinese
Troubleshooting:
Releases per Chromium version:
Chromium 93. 0. 4577. 0 – Puppeteer v10. 2. 0
Chromium 92. 4512. 0
Chromium 91. 4469. 0 – Puppeteer v9. 0
Chromium 90. 4427. 0 – Puppeteer v8. 4403. 0 – Puppeteer v7. 0
Chromium 89. 4389. 0 – Puppeteer v6. 0
Chromium 88. 4298. 0 – Puppeteer v5. 5. 0
Chromium 87. 4272. 4. 0
Chromium 86. 4240. 3. 0
Chromium 85. 4182. 1
Chromium 84. 4147. 1. 0
Chromium 83. 4103. 0 – Puppeteer v3. 0
Chromium 81. 4044. 0
Chromium 80. 3987. 0 – Puppeteer v2. 0
Chromium 79. 3942. 0
Chromium 78. 3882. 0 – Puppeteer v1. 20. 0
Chromium 77. 3803. 19. 0
Chromium 76. 17. 0
Chromium 75. 3765. 15. 0
Chromium 74. 3723. 13. 0
Chromium 73. 3679. 12. 2
All releases
Table of Contents
Overview
puppeteer vs puppeteer-core
Environment Variables
Working with Chrome Extensions
class: Puppeteer
earCustomQueryHandlers()
nnect(options)
eateBrowserFetcher([options])
stomQueryHandlerNames()
faultArgs([options])
vices
puppeteer. executablePath()
([options])
tworkConditions
oduct
gisterCustomQueryHandler(name, queryHandler)
puppeteer. unregisterCustomQueryHandler(name)
class: BrowserFetcher
nDownload(revision)
wnload(revision[, progressCallback])
()
browserFetcher. localRevisions()
atform()
oduct()
(revision)
visionInfo(revision)
class: Browser
event: ‘disconnected’
event: ‘targetchanged’
event: ‘targetcreated’
event: ‘targetdestroyed’
owserContexts()
eateIncognitoBrowserContext([options])
faultBrowserContext()
browser. disconnect()
Connected()
wPage()
ocess()
s()
erAgent()
rsion()
browser. waitForTarget(predicate[, options])
Endpoint()
class: BrowserContext
owser()
earPermissionOverrides()
Incognito()
browserContext. overridePermissions(origin, permissions)
browserContext. waitForTarget(predicate[, options])
class: Page
event: ‘close’
event: ‘console’
event: ‘dialog’
event: ‘domcontentloaded’
event: ‘error’
event: ‘frameattached’
event: ‘framedetached’
event: ‘framenavigated’
event: ‘load’
event: ‘metrics’
event: ‘pageerror’
event: ‘popup’
event: ‘request’
event: ‘requestfailed’
event: ‘requestfinished’
event: ‘response’
event: ‘workercreated’
event: ‘workerdestroyed’
page. $(selector)
page. $$(selector)
page. $$eval(selector, pageFunction[,.. ])
page. $eval(selector, pageFunction[,.. $x(expression)
cessibility
dScriptTag(options)
dStyleTag(options)
thenticate(credentials)
ingToFront()
owserContext()
(selector[, options])
ntent()
okies([.. ])
verage
eatePDFStream([options])
leteCookie(okies)
page. emulate(options)
page. emulateCPUThrottling(factor)
page. emulateIdleState(overrides)
page. emulateMediaFeatures(features)
page. emulateMediaType(type)
page. emulateNetworkConditions(networkConditions)
page. emulateTimezone(timezoneId)
page. emulateVisionDeficiency(type)
page. evaluate(pageFunction[,.. evaluateHandle(pageFunction[,.. evaluateOnNewDocument(pageFunction[,.. exposeFunction(name, puppeteerFunction)
(selector)
page. goForward([options])
(url[, options])
Closed()
DragInterceptionEnabled()
JavaScriptEnabled()
yboard
inFrame()
trics()
page. queryObjects(prototypeHandle)
reenshot([options])
(selector,.. )
tBypassCSP(enabled)
tCacheEnabled([enabled])
tContent(html[, options])
tCookie(okies)
tDefaultNavigationTimeout(timeout)
tDefaultTimeout(timeout)
tDragInterception(enabled)
tExtraHTTPHeaders(headers)
tGeolocation(options)
tJavaScriptEnabled(enabled)
tOfflineMode(enabled)
tRequestInterception(value)
Cooperative Intercept Mode and Legacy Intercept Mode
Upgrading to Cooperative Mode for package maintainers
tUserAgent(userAgent[, userAgentMetadata])
tViewport(viewport)
uchscreen
acing
(selector, text[, options])
ewport()
page. waitFor(selectorOrFunctionOrTimeout[, options[,.. ]])
page. waitForFileChooser([options])
page. waitForFunction(pageFunction[, options[,.. waitForNavigation([options])
page. waitForNetworkIdle([options])
page. waitForRequest(urlOrPredicate[, options])
page. waitForResponse(urlOrPredicate[, options])
page. waitForSelector(selector[, options])
page. waitForTimeout(milliseconds)
page. waitForXPath(xpath[, options])
ers()
GeolocationOptions
WaitTimeoutOptions
class: WebWorker
webWorker. ])
webWorker. executionContext()
class: Accessibility
apshot([options])
class: Keyboard
(key[, options])
ndCharacter(char)
(text[, options])
(key)
class: Mouse
(x, y[, options])
(start, target)
mouse. dragAndDrop(start, target[, options])
mouse. dragEnter(target, data)
mouse. dragOver(target, data)
(target, data)
class: Touchscreen
(x, y)
class: Tracing
class: FileChooser
(filePaths)
Multiple()
class: Dialog
([promptText])
faultValue()
dialog. dismiss()
ssage()
class: ConsoleMessage
consoleMessage. location()
ackTrace()
class: Frame
frame. $(selector)
frame. $$(selector)
frame. ])
frame. $x(expression)
ildFrames()
frame. executionContext()
Detached()
rentFrame()
frame. ]])
frame. waitForNavigation([options])
frame. waitForSelector(selector[, options])
frame. waitForTimeout(milliseconds)
frame. waitForXPath(xpath[, options])
class: ExecutionContext
executionContext. ])
executionContext. queryObjects(prototypeHandle)
class: JSHandle
Element()
jsHandle. dispose()
jsHandle. ])
jsHandle. executionContext()
tProperties()
tProperty(propertyName)
jsHandle. jsonValue()
class: ElementHandle
elementHandle. $(selector)
elementHandle. $$(selector)
elementHandle. ])
elementHandle. $x(expression)
undingBox()
xModel()
ickablePoint([offset])
ntentFrame()
elementHandle. dispose()
(target)
elementHandle. dragAndDrop(target[, options])
elementHandle. dragEnter([data])
elementHandle. dragOver([data])
([data])
elementHandle. executionContext()
IntersectingViewport([options])
elementHandle. jsonValue()
(.. )
String()
elementHandle. uploadFile(lePaths)
class: HTTPRequest
([errorCode], [priority])
Request. abortErrorReason()
ntinue([overrides], [priority])
ntinueRequestOverrides()
Request. enqueueInterceptAction(pendingHandler)
ure()
nalizeInterceptions()
Request. headers()
itiator()
NavigationRequest()
Data()
directChain()
sourceType()
spond(response, [priority])
sponse()
sponseForRequest()
class: HTTPResponse
omCache()
omServiceWorker()
Response. headers()
moteAddress()
quest()
curityDetails()
atusText()
class: SecurityDetails
otocol()
bjectAlternativeNames()
bjectName()
lidFrom()
lidTo()
class: Target
eateCDPSession()
class: CDPSession
nnection()
(method[, ramArgs])
class: Coverage
artCSSCoverage([options])
artJSCoverage([options])
opCSSCoverage()
opJSCoverage()
class: TimeoutError
class: EventEmitter
dListener(event, handler)
(event, [eventData])
stenerCount(event)
(event, handler)
moveAllListeners([event])
moveListener(event, handler)
interface: CustomQueryHandler
Puppeteer is a Node library which provides a high-level API to control Chromium or Chrome over the DevTools Protocol.
The Puppeteer API is hierarchical and mirrors the browser structure.
NOTE On the following diagram, faded entities are not currently represented in Puppeteer.
Puppeteer communicates with the browser using DevTools Protocol.
Browser instance can own multiple browser contexts.
BrowserContext instance defines a browsing session and can own multiple pages.
Page has at least one frame: main frame. There might be other frames created by iframe or frame tags.
Frame has at least one execution context – the default execution context – where the frame’s JavaScript is executed. A Frame might have additional execution contexts that are associated with extensions.
Worker has a single execution context and facilitates interacting with WebWorkers.
(Diagram source: link)
Every release since v1. 7. 0 we publish two packages:
puppeteer
puppeteer-core
puppeteer is a product for browser automation. When installed, it downloads a version of
Chromium, which it then drives using puppeteer-core. Being an end-user product, puppeteer supports a bunch of convenient PUPPETEER_* env variables to tweak its behavior.
puppeteer-core is a library to help drive anything that supports DevTools protocol. puppeteer-core doesn’t download Chromium when installed. Being a library, puppeteer-core is fully driven
through its programmatic interface and disregards all the PUPPETEER_* env variables.
To sum up, the only differences between puppeteer-core and puppeteer are:
puppeteer-core doesn’t automatically download Chromium when installed.
puppeteer-core ignores all PUPPETEER_* env variables.
In most cases, you’ll be fine using the puppeteer package.
However, you should use puppeteer-core if:
you’re building another end-user product or library atop of DevTools protocol. For example, one might build a PDF generator using puppeteer-core and write a custom script that downloads headless_shell instead of Chromium to save disk space.
you’re bundling Puppeteer to use in Chrome Extension / browser with the DevTools protocol where downloading an additional Chromium binary is unnecessary.
you’re building a set of tools where puppeteer-core is one of the ingredients and you want to postpone script execution until Chromium is about to be used.
When using puppeteer-core, remember to change the include line:
const puppeteer = require(‘puppeteer-core’);
You will then need to call nnect([options]) or ([options]) with an explicit executablePath or channel option.
Puppeteer looks for certain environment variables to aid its operations.
If Puppeteer doesn’t find them in the environment during the installation step, a lowercased variant of these variables will be used from the npm config.
HTTP_PROXY, HTTPS_PROXY, NO_PROXY – defines HTTP proxy settings that are used to download and run the browser.
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD – do not download bundled Chromium during installation step.
PUPPETEER_TMP_DIR – defines the directory to be used by Puppeteer for creating temporary files. Defaults to ().
PUPPETEER_DOWNLOAD_HOST – overwrite URL prefix that is used to download Chromium. Note: this includes protocol and might even include path prefix. Defaults to PUPPETEER_DOWNLOAD_PATH – overwrite the path for the downloads folder. Defaults to
PUPPETEER_CHROMIUM_REVISION – specify a certain version of Chromium you’d like Puppeteer to use. See ([options]) on how executable path is inferred. BEWARE: Puppeteer is only guaranteed to work with the bundled Chromium, use at your own risk.
PUPPETEER_EXECUTABLE_PATH – specify an executable path to be used in See ([options]) on how the executable path is inferred. BEWARE: Puppeteer is only guaranteed to work with the bundled Chromium, use at your own risk.
PUPPETEER_PRODUCT – specify which browser you’d like Puppeteer to use. Must be one of chrome or firefox. This can also be used during installation to fetch the recommended browser binary. Setting product programmatically in ([options]) supersedes this environment variable. The product is exposed in oduct
NOTE PUPPETEER_* env variables are not accounted for in the puppeteer-core package.
Puppeteer can be used for testing Chrome Extensions.
NOTE Extensions in Chrome / Chromium currently only work in non-headless mode.
The following is code for getting a handle to the background page of an extension whose source is located in. /my-extension:
const puppeteer = require(‘puppeteer’);
(async () => {
const pathToExtension = require(‘path’)(__dirname, ‘my-extension’);
const browser = await ({
headless: false,
args: [
`–disable-extensions-except=${pathToExtension}`,
`–load-extension=${pathToExtension}`, ], });
const targets = await s();
const backgroundPageTarget = (
(target) => () === ‘background_page’);
const backgroundPage = await ();
// Test the background page as you would any other page.
await ();})();
NOTE It is not yet possible to test extension popups or content scripts.
Puppeteer module provides a method to launch a Chromium instance.
The following is a typical example of using Puppeteer to drive automation:
const browser = await ();
const page = await wPage();
await (”);
// other actions…
Clears all registered handlers.
options
Quick start | Tools for Web Developers
Getting Started
Installation
To use Puppeteer in your project, run:
npm i puppeteer
# or “yarn add puppeteer”
puppeteer-core
Since version 1. 7. 0 we publish the puppeteer-core package,
a version of Puppeteer that doesn’t download any browser by default.
npm i puppeteer-core
# or “yarn add puppeteer-core”
puppeteer-core is intended to be a lightweight version of Puppeteer for launching an existing browser installation or for connecting to a remote one. Be sure that the version of puppeteer-core you install is compatible with the
browser you intend to connect to.
See puppeteer vs puppeteer-core.
Usage
Puppeteer follows the latest maintenance LTS version of Node.
Puppeteer will be familiar to people using other browser testing frameworks. You create an instance
of Browser, open pages, and then manipulate them with Puppeteer’s API.
Example – navigating to and saving a screenshot as
Save file as
const puppeteer = require(‘puppeteer’);
(async () => {
const browser = await ();
const page = await wPage();
await (”);
await reenshot({ path: ”});
await ();})();
Execute script on the command line
node
Puppeteer sets an initial page size to 800×600px, which defines the screenshot size. The page size can be customized with tViewport().
Example – create a PDF.
await (”, {
waitUntil: ‘networkidle2’, });
await ({ path: ”, format: ‘a4’});
See () for more information about creating pdfs.
Example – evaluate script in the context of the page
// Get the “viewport” of the page, as reported by the page.
const dimensions = await page. evaluate(() => {
return {
width: ientWidth,
height: ientHeight,
deviceScaleFactor: vicePixelRatio, };});
(‘Dimensions:’, dimensions);
See Page. evaluate() for more information on evaluate and related methods like evaluateOnNewDocument and exposeFunction.
Default runtime settings
1. Uses Headless mode
Puppeteer launches Chromium in headless mode. To launch a full version of Chromium, set the headless option when launching a browser:
const browser = await ({ headless: false}); // default is true
2. Runs a bundled version of Chromium
By default, Puppeteer downloads and uses a specific version of Chromium so its API
is guaranteed to work out of the box. To use Puppeteer with a different version of Chrome or Chromium,
pass in the executable’s path when creating a Browser instance:
const browser = await ({ executablePath: ‘/path/to/Chrome’});
You can also use Puppeteer with Firefox Nightly (experimental support). See () for more information.
See this article for a description of the differences between Chromium and Chrome. This article describes some differences for Linux users.
3. Creates a fresh user profile
Puppeteer creates its own browser user profile which it cleans up on every run.
Next steps
Learn more about headless Chrome
Look over the examples.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4. 0 License, and code samples are licensed under the Apache 2. 0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2021-09-22 UTC.
[{
“type”: “thumb-down”,
“id”: “missingTheInformationINeed”,
“label”:”Missing the information I need”}, {
“id”: “tooComplicatedTooManySteps”,
“label”:”Too complicated / too many steps”}, {
“id”: “outOfDate”,
“label”:”Out of date”}, {
“id”: “samplesCodeIssue”,
“label”:”Samples / code issue”}, {
“id”: “otherDown”,
“label”:”Other”}]
“type”: “thumb-up”,
“id”: “easyToUnderstand”,
“label”:”Easy to understand”}, {
“id”: “solvedMyProblem”,
“label”:”Solved my problem”}, {
“id”: “otherUp”,
“label”:”Other”}]
Puppeteer (video game) – Wikipedia
PuppeteerDeveloper(s)Japan StudioPublisher(s)Sony Computer EntertainmentDirector(s)Gavin MooreProducer(s)Takashi MizutaniDesigner(s)Kazunobu SatoComposer(s)Patrick DoylePlatform(s)PlayStation 3ReleaseJP: September 5, 2013[1]NA: September 10, 2013 EU: September 11, 2013Genre(s)PlatformerMode(s)Single-player
Puppeteer (パペッティア) is a platform video game developed by Japan Studio for the PlayStation 3. [2][3] It was directed by Gavin Moore. The game was released worldwide in September 2013.
It is playable in both traditional 2D and in 3D. Gavin Moore says Puppeteer plays better in 3D than other games because the camera does not move and his team used a method of 3D that has not resulted in a reduced framerate. [4]
Gameplay[edit]
Puppeteer is a side-scrolling platformer in which the player controls the character ‘Kutaro’: a boy changed into an animated puppet and immediately decapitated. Throughout the game, Kutaro obtains various heads to replace his own, each enabling access to certain animations, and referring to the adjacent scenery. If Kutaro is damaged by an enemy or obstacle, he loses his head. Should the player not retrieve the head within a few seconds, it will disappear. Kutaro can hold three heads at a time, and when they are all lost, he restarts from the last checkpoint. The player can earn an extra life by collecting 100 “Moonsparkles” in a given section of the game.
Throughout most of the story, Kutaro is armed with a pair of magical scissors, known as ‘Calibrus’, enabling him to cut through some portions of the scenery, and thus to reach otherwise inaccessible areas. He later acquires the abilities of the Four Champions of the Moon: the Knight’s shield to defend against damage and reflect attacks, the Ninja’s bombs to attack enemies and break obstacles, the Pirate’s hook to grapple and pull enemies and change the scenery, and the Wrestler’s mask and strength to body slam enemies and pull and push obstacles. His stated object is to acquire the shards of ‘Moonstone’ from the game’s villains (in the process removing their influence from the scenery) and to free the souls of children like himself, from the malevolent figures containing them, all the while saving a Goddess in distress.
The game is playable by one or two players. If two are playing, the second player controls Kutaro’s companion (initially a ghostly cat named ‘Ying-Yang’; later the fairylike ‘Pikarina’), who can examine the scenery for foreign objects and find interactables, moonsparkles, and new heads for Kutaro. In single-player mode, the two analog sticks on the joypad each control a character.
The game is presented as a puppet show in front of an audience, who can be heard cheering and laughing when impressive actions take place. It is divided into seven “acts”, each of which comprise three “curtains”. Each curtain has a set number of heads to collect, a set number of souls to rescue, and a hidden area to discover. For 100% completion, the player must revisit old curtains with new heads to complete it.
Plot[edit]
The story occurs in a concave world representing Earth’s Moon, inhabited by pseudo-folkloric characters: the first half on the dark side of the Moon, and the second half on the Earthward side. Its premise states that the world’s ruler, the Moon Goddess, was overthrown by her subordinate, Little Bear, when the latter seized her ‘Black Moonstone’ and the magic scissor-set ‘Calibrus’, and declared himself ‘Moon Bear King’. Throughout the game, each of his twelve generals (the animals of the Chinese zodiac) has set part of the moon-world in disorder: each holding a portion of the Goddess’ ‘White Moonstone. ’
The player-character ‘Kutaro’ is one of many children whose souls were spirited away from Earth in their sleep and changed into animated wooden puppets to be enslaved in the King’s mobile fortress, Castle Grizzlestein. After having his head pulled off and his soul devoured by the Moon Bear King, Kutaro is found in the dungeons by the Goddess’s cat, Ying Yang, who leads him to his current mistress, the Moon Witch Ezma Potts. Potts, who is secretly planning overthrow the Moon Bear King herself, orders Kutaro to sneak into the throne room and capture the magic pair of scissors Calibrus. This weapon allows Kutaro to dispel the King’s magic and defeat his puppets to release the souls within, allowing them to escape back to Earth. When the Witch demands the scissors, they adhere to Kutaro, and she allows him to use Calibrus to oppose the twelve generals. During the defeat of the first (General Tiger), Kutaro rescues Pikarina, Princess of the Sun, whom the Moon Bear King had captured. Under Potts’ guidance, Kutaro and Pikarina venture to the various realms of the moon, to vanquish each general in turn: the Moonwood Forest guarded by Rat and Snake, the Moonshine Sea patrolled by Pig and Sheep, the Wild Wastes trampled by Bull and Horse, Hallowee-Ville controlled by Dog and Monkey, and the Land of Time conquered by Rabbit and Rooster, ultimately facing off against Dragon.
When the White Moonstone is re-assembled, Potts revealed to be as the Moon Goddess as she transforms back; but is instantly trapped by the Moon Bear King, and must be rescued by Kutaro. Propelled thereto by a cannon, Kutaro and Pikarina disable Castle Grizzlestein and reduce the Moon Bear King to his former shape of Little Bear, who surrenders the Black Moonstone in exchange for Kutaro’s friendship, and restores Kutaro’s head. All the twelve Generals are resurrected and converted from evil to good; and Kutaro, accompanied by Calibrus and Ying Yang, returns to Earth.
Development[edit]
On July 21, 2010, Sony filed a trademark titled Puppeteer. It has been speculated that it would be a game that would make use of the PlayStation Move technology in order to control the main character. Two years later, the trademark was later revealed to be indeed for a game with its official announcement at Gamescom 2012.
In December 2012, Gavin Moore, the director of the video game, posted an entry on the European PlayStation Blog, stating that the video game is “Shaping up nicely, playing great and looking awesome. From January we will be polishing, refining and adding extra little details, to make the whole experience something fantastical and wonderful that PlayStation fans deserve. I will be in London for two weeks doing the Voice recordings in January, popping across to Budapest for the music recordings, then back to Japan with all my wonderful assets to shove them lovingly into the game. This is one of my favourite parts of game creation. Getting the final assets into the game really brings everything together. “[5]
Reception[edit]
Puppeteer received “generally favorable” reviews, according to review aggregator Metacritic.
References[edit]
^ 『パペッティア』の発売日が2013年9月5日に決定! 価格は5980円[税込] (in Japanese). Famitsu. 2013-06-27. Retrieved 2013-07-27.
^ “Puppeteer – IGN”.
^ “Archived copy”. Archived from the original on 2012-08-18. Retrieved 2012-08-15. CS1 maint: archived copy as title (link)
^ Rutledge, Daniel (26 October 2012). “Puppeteer – a weird, wild PS3 adventure”. 3 News NZ. Archived from the original on 4 October 2013. Retrieved 28 October 2012.
^ “Happy holidays from the Puppeteer team! “. 18 December 2012.
^ “Puppeteer for PlayStation 3 Reviews”. Metacritic. Retrieved 2021-09-05.
^ Moriarty, Colin (5 September 2021). “Puppeteer Review”. IGN. Retrieved 5 September 2021.
^ Walton, Mark (5 September 2021). GameSpot. Retrieved 5 September 2021.
^ Whitehead, Dan (5 September 2021). “Puppeteer review”. Eurogamer. Retrieved 5 September 2021.
^ “Puppeteer Review (PS3) | Aces high”. Push Square. 5 September 2021. Retrieved 5 September 2021.
^ Sterling, Jim (5 September 2021). “Review: Puppeteer”. Destructoid. Retrieved 5 September 2021.
^ Moutinho, Eduardo (5 September 2021). “Puppeteer’s endearing whimsy makes it worth the price of admission (review)”. VentureBeat. Retrieved 5 September 2021.
^ Marchiafava, Jeff (5 September 2021). “Puppeteer – Japan Studio Delivers A Rousing Stage Performance”. Game Informer. Retrieved 5 September 2021.
^ “Puppeteer review | Aces high”. Electronic Gaming Monthly. GamesRadar. Retrieved 5 September 2021.
^ Gies, Arthur (5 September 2021). “Puppeteer review: strings attached”. Polygon. Retrieved 5 September 2021.
External links[edit]
Official UK website
Official US website
Official Japanese website
Frequently Asked Questions about puppeteer launch
What is puppeteer launch?
Overview. Puppeteer is a Node library which provides a high-level API to control Chromium or Chrome over the DevTools Protocol. … Puppeteer communicates with the browser using DevTools Protocol.
When was puppeteer released?
Puppeteer (video game)PuppeteerPlatform(s)PlayStation 3ReleaseJP: September 5, 2013 NA: September 10, 2013 EU: September 11, 2013Genre(s)PlatformerMode(s)Single-player7 more rows
How do I launch a puppeteer browser?
To use Puppeteer with a different version of Chrome or Chromium, pass in the executable’s path when creating a Browser instance: const browser = await puppeteer. launch({ executablePath: ‘/path/to/Chrome’ }); You can also use Puppeteer with Firefox Nightly (experimental support).Sep 22, 2021