Bug 1914685 - [wpt-sync] Update web-platform-tests to 26c88095d89792c886494e30c85aca3...
[gecko.git] / remote / test / puppeteer / README.md
blob9f7c06e198aba7691265487c4a211db1fc2f6264
1 # Puppeteer
3 [![build](https://github.com/puppeteer/puppeteer/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/puppeteer/puppeteer/actions/workflows/ci.yml)
4 [![npm puppeteer package](https://img.shields.io/npm/v/puppeteer.svg)](https://npmjs.org/package/puppeteer)
6 <img src="https://user-images.githubusercontent.com/10379601/29446482-04f7036a-841f-11e7-9872-91d1fc2ea683.png" height="200" align="right"/>
8 > Puppeteer is a JavaScript library which provides a high-level API to control
9 > Chrome or Firefox over the
10 > [DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/) or [WebDriver BiDi](https://pptr.dev/webdriver-bidi).
11 > Puppeteer runs in the headless (no visible UI) by default
13 ## [Get started](https://pptr.dev/docs) | [API](https://pptr.dev/api) | [FAQ](https://pptr.dev/faq) | [Contributing](https://pptr.dev/contributing) | [Troubleshooting](https://pptr.dev/troubleshooting)
15 ## Installation
17 ```bash npm2yarn
18 npm i puppeteer # Downloads compatible Chrome during installation.
19 npm i puppeteer-core # Alternatively, install as a library, without downloading Chrome.
20 ```
22 ## Example
24 ```ts
25 import puppeteer from 'puppeteer';
26 // Or import puppeteer from 'puppeteer-core';
28 // Launch the browser and open a new blank page
29 const browser = await puppeteer.launch();
30 const page = await browser.newPage();
32 // Navigate the page to a URL.
33 await page.goto('https://developer.chrome.com/');
35 // Set screen size.
36 await page.setViewport({width: 1080, height: 1024});
38 // Type into search box.
39 await page.locator('.devsite-search-field').fill('automate beyond recorder');
41 // Wait and click on first result.
42 await page.locator('.devsite-result-item-link').click();
44 // Locate the full title with a unique string.
45 const textSelector = await page
46   .locator('text/Customize and automate')
47   .waitHandle();
48 const fullTitle = await textSelector?.evaluate(el => el.textContent);
50 // Print the full title.
51 console.log('The title of this blog post is "%s".', fullTitle);
53 await browser.close();
54 ```