Skip to content

Commit

Permalink
9.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacasonato authored Sep 29, 2021
1 parent b0ebcf5 commit 4d74440
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 25 deletions.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ RUN apt-get -qq update \
wget \
xdg-utils \
# ↑ https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#chrome-headless-doesnt-launch-on-unix
# ↓ Added based on the information obtained from by console.log(line) at https://deno.land/x/puppeteer@9.0.1/src/deno/BrowserRunner.ts#L168.
# ↓ Added based on the information obtained from by console.log(line) at https://deno.land/x/puppeteer@9.0.2/src/deno/BrowserRunner.ts#L168.
libdrm2 \
libxkbcommon0 \
libxshmfence1 \
# ↑ Added based on the information obtained from by console.log(line) at https://deno.land/x/puppeteer@9.0.1/src/deno/BrowserRunner.ts#L168.
# ↑ Added based on the information obtained from by console.log(line) at https://deno.land/x/puppeteer@9.0.2/src/deno/BrowserRunner.ts#L168.
&& curl -fsSL https://github.com/denoland/deno/releases/download/v${DENO_VERSION}/deno-x86_64-unknown-linux-gnu.zip \
--output deno.zip \
&& unzip deno.zip \
Expand All @@ -79,8 +79,8 @@ ENV DENO_DIR /deno-dir/
WORKDIR /root
COPY . .

# https://deno.land/x/puppeteer@9.0.1#installation
# In your real script, replace the installation script with https://deno.land/x/puppeteer@9.0.1/install.ts
# https://deno.land/x/puppeteer@9.0.2#installation
# In your real script, replace the installation script with https://deno.land/x/puppeteer@9.0.2/install.ts
RUN PUPPETEER_PRODUCT=chrome deno run -A --unstable ./install.ts

ENTRYPOINT ["deno"]
Expand Down
63 changes: 42 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,25 @@

<img src="./logo.png" height="200" align="right">

###### [API](https://github.com/puppeteer/puppeteer/blob/v9.0.1/docs/api.md)
###### [API](https://github.com/puppeteer/puppeteer/blob/v9.0.2/docs/api.md)

A fork of [Puppeteer](https://pptr.dev/) running on Deno.

> Puppeteer is a library which provides a high-level API to control Chrome, Chromium, or Firefox Nightly over the DevTools Protocol. Puppeteer runs headless by default, but can be configured to run full (non-headless) Chrome or Chromium.
> Puppeteer is a library which provides a high-level API to control Chrome,
> Chromium, or Firefox Nightly over the DevTools Protocol. Puppeteer runs
> headless by default, but can be configured to run full (non-headless) Chrome
> or Chromium.
Most things that you can do manually in the browser can be done using Puppeteer! Here are a few examples to get you started:
Most things that you can do manually in the browser can be done using Puppeteer!
Here are a few examples to get you started:

- Generate screenshots and PDFs of pages.
- Crawl a SPA (Single-Page Application) and generate pre-rendered content (i.e. "SSR" (Server-Side Rendering)).
- Crawl a SPA (Single-Page Application) and generate pre-rendered content (i.e.
"SSR" (Server-Side Rendering)).
- Automate form submission, UI testing, keyboard input, etc.
- Create an up-to-date, automated testing environment. Run your tests directly in the latest version of Chrome using the latest JavaScript and browser features.
- Create an up-to-date, automated testing environment. Run your tests directly
in the latest version of Chrome using the latest JavaScript and browser
features.
- Capture a timeline trace of your site to help diagnose performance issues.
- Test Chrome Extensions.

Expand All @@ -24,28 +31,35 @@ Most things that you can do manually in the browser can be done using Puppeteer!
To use Puppeteer, import it like so:

```ts
import puppeteer from "https://deno.land/x/puppeteer@9.0.1/mod.ts";
import puppeteer from "https://deno.land/x/puppeteer@9.0.2/mod.ts";
```

Puppeteer can use any recent version of Chromium or Firefox Nightly, but this version of Puppeteer is only validated against a specific version. To cache these versions in the Puppeteer cache, run the commands below.
Puppeteer can use any recent version of Chromium or Firefox Nightly, but this
version of Puppeteer is only validated against a specific version. To cache
these versions in the Puppeteer cache, run the commands below.

```shell
PUPPETEER_PRODUCT=chrome deno run -A --unstable https://deno.land/x/puppeteer@9.0.1/install.ts
PUPPETEER_PRODUCT=firefox deno run -A --unstable https://deno.land/x/puppeteer@9.0.1/install.ts
PUPPETEER_PRODUCT=chrome deno run -A --unstable https://deno.land/x/puppeteer@9.0.2/install.ts
PUPPETEER_PRODUCT=firefox deno run -A --unstable https://deno.land/x/puppeteer@9.0.2/install.ts
```

You can find all of the supported environment variables to customize installation [in the Puppeteer docs](https://pptr.dev/#?product=Puppeteer&version=v5.5.0&show=api-environment-variables).
You can find all of the supported environment variables to customize
installation
[in the Puppeteer docs](https://pptr.dev/#?product=Puppeteer&version=v5.5.0&show=api-environment-variables).

### Usage

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.
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 https://example.com and saving a screenshot as _example.png_:
**Example** - navigating to https://example.com and saving a screenshot as
_example.png_:

Save file as **example.js**

```js
import puppeteer from "https://deno.land/x/puppeteer@9.0.1/mod.ts";
import puppeteer from "https://deno.land/x/puppeteer@9.0.2/mod.ts";

const browser = await puppeteer.launch();
const page = await browser.newPage();
Expand All @@ -61,14 +75,16 @@ Execute script on the command line
deno run -A --unstable example.js
```

Puppeteer sets an initial page size to 800×600px, which defines the screenshot size. The page size can be customized with [`Page.setViewport()`](https://github.com/puppeteer/puppeteer/blob/v5.5.0/docs/api.md#pagesetviewportviewport).
Puppeteer sets an initial page size to 800×600px, which defines the screenshot
size. The page size can be customized with
[`Page.setViewport()`](https://github.com/puppeteer/puppeteer/blob/v5.5.0/docs/api.md#pagesetviewportviewport).

**Example** - create a PDF.

Save file as **hn.js**

```js
import puppeteer from "https://deno.land/x/puppeteer@9.0.1/mod.ts";
import puppeteer from "https://deno.land/x/puppeteer@9.0.2/mod.ts";

const browser = await puppeteer.launch();
const page = await browser.newPage();
Expand All @@ -86,14 +102,16 @@ Execute script on the command line
deno run -A --unstable hn.js
```

See [`Page.pdf()`](https://github.com/puppeteer/puppeteer/blob/v5.5.0/docs/api.md#pagepdfoptions) for more information about creating pdfs.
See
[`Page.pdf()`](https://github.com/puppeteer/puppeteer/blob/v5.5.0/docs/api.md#pagepdfoptions)
for more information about creating pdfs.

**Example** - evaluate script in the context of the page

Save file as **get-dimensions.js**

```js
import puppeteer from "https://deno.land/x/puppeteer@9.0.1/mod.ts";
import puppeteer from "https://deno.land/x/puppeteer@9.0.2/mod.ts";

const browser = await puppeteer.launch();
const page = await browser.newPage();
Expand Down Expand Up @@ -123,14 +141,17 @@ deno run -A --unstable get-dimensions.js

### How does deno-puppeteer compare to the Node version?

`deno-puppeteer` effectively runs a regular version of Puppeteer, except for some minor changes to make it compatible with Deno.
`deno-puppeteer` effectively runs a regular version of Puppeteer, except for
some minor changes to make it compatible with Deno.

The most noticable difference is likely that instead of some methods taking / returning Node `Buffer`, they take / return `Uint8Array`.
The most noticable difference is likely that instead of some methods taking /
returning Node `Buffer`, they take / return `Uint8Array`.

Other than this, the documentation on https://pptr.dev generally applies.

### How to run in Docker?

An example Dockerfile can be found in this repository. It will install all necessary dependencies, and shows how to run the ./examples/docker.js.
An example Dockerfile can be found in this repository. It will install all
necessary dependencies, and shows how to run the ./examples/docker.js.

It is just meant as a jumping off point - customize it as you wish.
It is just meant as a jumping off point - customize it as you wish.

0 comments on commit 4d74440

Please sign in to comment.