Skip to content

Commit

Permalink
remove Puppeteer many many times. There's an issue where loading in s…
Browse files Browse the repository at this point in the history
…cripts still requires the tabs wrapper, idk, TODO: figure out why
  • Loading branch information
serverless-mom committed Sep 19, 2024
1 parent 79589b2 commit c8771ed
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 164 deletions.
2 changes: 1 addition & 1 deletion site/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ disqusShortname = "checkly"

[[menu.learn]]
name = "Getting started"
pre = "/learn/icons/getting-started.svg"
pre = "/learn/icons/playwright-logo.svg"
weight = 300

[[menu.learn]]
Expand Down
5 changes: 1 addition & 4 deletions site/content/docs/CICD/vercel.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,7 @@ For more info on the **Virtual Experience Score** [check the documentation on th
## Skipping Performance checks

In some cases, Checkly will completely skip performance checks. You will see the "skipped" status in your Vercel deployment overview.
Checkly skips performance checks when...

1. A check doesn't report any Web Vitals. They are all `null`. For example, this happens when using Puppeteer based checks.
2. Or, the domain of the visited URL in the script does not match the domain of the **deployment URL**. In 9 out of 10 cases this should be the URL for your Preview and Production deployments.
Checkly skips performance checks when the domain of the visited URL in the script does not match the domain of the **deployment URL**. In 9 out of 10 cases this should be the URL for your Preview and Production deployments.


## Vercel-linked check results
Expand Down
9 changes: 1 addition & 8 deletions site/content/docs/browser-checks/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ To power your Browser checks, Checkly uses **[Playwright Test](https://playwrigh
While you can use plain Playwright to run your checks on Checkly, **we highly recommend using Playwright Test**. The test-runner gives you powerful additional features such as built-in awaiting for `expect()`, many web-first assertions, high-level locators, and traces and videos of your failed tests to easily debug your issues, [learn more about Playwright Test features](/docs/browser-checks/playwright-test/).


{{< warning >}}
We have stopped support for Puppeteer with runtime 2022.10. [Read more about our reasons](/docs/browser-checks/#what-about-puppeteer).
{{< /warning >}}

The following code is a valid Browser check using Playwright Test.

Expand Down Expand Up @@ -215,10 +212,6 @@ alerting channels will be triggered, notifying your team that something is up.

<video alt="Viewing a failed check" autoplay loop muted src="/docs/images/browser-checks/getting-started_pwt.mp4"></video>

## What about Puppeteer?
While Playwright and Puppeteer share many similarities, they have evolved at different speeds over time. Playwright's rapid release cycle and new features such as [auto-waiting](https://playwright.dev/docs/actionability) and [the built-in inspector](https://playwright.dev/docs/debug#playwright-inspector) made it gain momentum in the developer community. Playwright and Playwright Test Runner have become superior solutions and we have stopped support for Puppeteer in newer [runtimes](/docs/runtimes/). The latest runtime that supports Puppeteer is [2022.02](/docs/runtimes/specs/).

We recommend using Playwright Test if you are just starting out or [migrating from Puppeteer to Playwright using `puppeteer-to-playwright`](https://github.com/checkly/puppeteer-to-playwright).

## Using other browsers
{{< info >}}
Expand Down Expand Up @@ -277,7 +270,7 @@ Chrome is being used.

## More Playwright resources

- [Headless Automation guides](/learn/headless/), a free & open source knowledge base for Playwright and Puppeteer
- [Headless Automation guides](/learn/playwright/), a free & open source knowledge base for Playwright
(maintained by Checkly).
- [Checkly's YouTube channel](https://www.youtube.com/@ChecklyHQ) where we regularly publish tutorials and tips.
- [playwright.dev](https://playwright.dev/) is the official API documentation site for the Playwright framework.
Expand Down
4 changes: 0 additions & 4 deletions site/content/docs/monitoring/ip-info.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ test('Set host resolver to IPv4', async () => {
});
```

### Known limitations

Puppeteer-based browser checks do not support IPv6 and will not in the future as we are deprecating Puppeteer support.

## Static IP ranges

All monitoring traffic from Checkly for all customers on all plans comes from a fixed set of source IPs. An up-to-date list can be requested unauthenticated through the API. See our [API spec](https://api.checklyhq.com/#/Static%20IPs) for more info.
Expand Down
2 changes: 1 addition & 1 deletion site/content/docs/runtimes/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ We ship new runtimes with a regular cadence. This is what you can expect from us

**1. Major & minor version upgrades of core packages and Node.js versions**

We aim to release a new runtime that holds the major and minor upgrades of Playwright, Puppeteer and Node.js **every quarter**.
We aim to release a new runtime that holds the major and minor upgrades of Playwright and Node.js **every quarter**.
This will result in a new, named runtime e.g. `2023.03` available in the Checkly webapp and in our API.

**2. Patch releases and security patches**
Expand Down
2 changes: 1 addition & 1 deletion site/content/docs/runtimes/specs.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ See the built-in module documentation on the official Node.js site:

These are the currently available runtimes and the included external NPM dependencies.

> The packages below are included for **setup and teardown scripts** as well, with the exclusion of Puppeteer, Playwright and Mocha.
> The packages below are included for **setup and teardown scripts** as well, with the exclusion of Playwright and Mocha.
> We are planning to deprecate `mocha` in the future. Please use `@playwright/test` as a test framework instead.
Expand Down
16 changes: 7 additions & 9 deletions site/content/learn/playwright/_index.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
---
title: Learn Playwright Testing & Automation Framework
displayTitle: Learn Playwright
description: Learn more about Playwright & Puppeteer with Checkly. Explore how to automate your web with a reliable, programmable monitoring workflow.
description: Learn more about Playwright & monitoring with Checkly. Explore how to automate your web with a reliable, programmable monitoring workflow.
displayDescription:
Learn more about Playwright & Puppeteer with Checkly. Explore how to automate your web with a reliable, programmable monitoring workflow.
Learn more about Playwright & Monitoring with Checkly. Explore how to automate your web with a reliable, programmable monitoring workflow.
metatags:
title: Learn Playwright & Puppeteer - Browser Automation Frameworks
title: Learn Playwright & Checkly - Browser Automation

---

Tips, tricks, and in-depth guides from the trenches. Learn how to use the popular open-source browser automation frameworks, Playwright and Puppeteer.
Tips, tricks, and in-depth guides from the trenches. Learn how to use the popular open-source browser automation framework, Playwright .
This guide provides detailed information and examples how you can write high-quality scripts for testing and synthetic monitoring.

## Getting Started

Have a look at how Playwright & Puppeteer work, what similarities they share, as well as the noticeable differences.

<div class="cards-list">
{{< doc-card
class="two-column-card"
headerTag="h3"
title="What is Playwright?"
img="/learn/icons/playwright.png"
description="Built on the experience of Puppeteer, Microsoft's Playwright offers unique features."
description="Microsoft's Playwright offers unique features for automation and user simulation."
link="/learn/playwright/getting-started/intro"
>}}
{{< doc-card
Expand All @@ -38,7 +36,7 @@ Have a look at how Playwright & Puppeteer work, what similarities they share, as

## Diving Deeper

Playwright and Puppeteer are extremely powerful and serve a wide range of use cases. We have collected in-depth articles for important scenarios and challenging automation flows.
Playwright and is extremely powerful and serves a wide range of use cases. We have collected in-depth articles for important scenarios and challenging automation flows.

<div class="cards-list">
{{< doc-card
Expand Down Expand Up @@ -70,7 +68,7 @@ Playwright and Puppeteer are extremely powerful and serve a wide range of use ca
headerTag="h3"
title="Performance"
img="/learn/icons/performance.svg"
description="Learn how you can use Playwright & Puppeteer to measure page performances."
description="Learn how you can use Playwright to measure page performance."
link="/learn/headless/basics-performance/"
>}}
</div>
Expand Down
75 changes: 5 additions & 70 deletions site/content/learn/playwright/basics/emulating-mobile-devices.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ menu:
parent: "Basics"
---

Puppeteer and Playwright control headless desktop browsers that can also emulate mobile devices. And while device emulation can't replace testing on mobile devices entirely, it's a practical and quick-to-setup approach to testing mobile scenarios.
Playwright controls headless desktop browsers that can also emulate mobile devices. And while device emulation can't replace testing on mobile devices entirely, it's a practical and quick-to-setup approach to testing mobile scenarios.

Device emulation is well suited to test if your site behaves correctly across multiple viewport sizes and correctly handles `user-agent` strings. But if your site relies on device-specific browser features, an iPhone emulation running in a Chromium browser might lead to false positives.

This guide explains how to define viewport sizes, device pixel ratio and `user-agent` strings using Playwright and Puppeteer.
This guide explains how to define viewport sizes, device pixel ratio and `user-agent` strings using Playwright.

## Defining the user agent string

If your site parses the user agent string to serve a different experience to mobile users, define the `userAgent` in your automation scripts.

{{< tabs "1" >}}
{{< tab "Playwright" >}}


```js
const { chromium } = require("playwright")

Expand All @@ -47,34 +47,13 @@ const { chromium } = require("playwright")
await browser.close()
})()
```
{{< /tab >}}
{{< tab "Puppeteer" >}}
```js
const puppeteer = require("puppeteer")

;(async () => {
const browser = await puppeteer.launch()
const page = await browser.newPage()
// define the iPhone SE user agent
await page.setUserAgent(
"Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/16.0 Mobile/14E304 Safari/602.1"
)
await page.goto("https://danube-web.shop/")

// perform your tests

await browser.close()
})()
```
{{< /tab >}}
{{< /tabs >}}

## Defining viewport size and pixel density

If your site follows responsive web design practices and renders elements depending on device viewport size, define a mobile viewport and pixel density.

{{< tabs "2" >}}
{{< tab "Playwright" >}}

```js
const { chromium } = require("playwright")

Expand All @@ -95,29 +74,6 @@ const { chromium } = require("playwright")
await browser.close()
})()
```
{{< /tab >}}
{{< tab "Puppeteer" >}}
```js
const puppeteer = require("puppeteer")

;(async () => {
const browser = await puppeteer.launch()
const page = await browser.newPage()
// define the iPhone SE viewport size and pixel density
await page.setViewport({
width: 320,
height: 568,
deviceScaleFactor: 2,
})
await page.goto("https://danube-web.shop/")

// perform your tests

await browser.close()
})()
```
{{< /tab >}}
{{< /tabs >}}

### Use built-in device registries

Expand All @@ -128,8 +84,6 @@ Playwright and Puppeteer include a built-in device registry to access mobile dev

Leverage the pre-defined devices to emulate mobile devices.

{{< tabs "3" >}}
{{< tab "Playwright" >}}
```js
const { chromium, devices } = require("playwright")
const iPhone = devices['iPhone SE'];
Expand All @@ -147,26 +101,7 @@ const iPhone = devices['iPhone SE'];
await browser.close()
})()
```
{{< /tab >}}
{{< tab "Puppeteer" >}}
```js
const puppeteer = require("puppeteer")
const iPhone = puppeteer.devices['iPhone SE'];

;(async () => {
const browser = await puppeteer.launch()
const page = await browser.newPage()
// emulate the iPhone SE
await page.emulate(iPhone);
await page.goto("https://danube-web.shop/")

// perform your tests

await browser.close()
})()
```
{{< /tab >}}
{{< /tabs >}}

## Further reading

Expand Down
28 changes: 6 additions & 22 deletions site/content/learn/playwright/basics/generating-pdfs.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ menu:
parent: "Basics"
---

Playwright and Puppeteer can be used to create PDFs from webpages. This opens up interesting automation scenarios for tasks such as archiving, generating invoices, writing manuals, books and more.
Playwright can be used to create PDFs from webpages. This opens up interesting automation scenarios for tasks such as archiving, generating invoices, writing manuals, books and more.

This article introduces this functionality and shows how we can customise the PDF to fit our needs.

Expand All @@ -27,22 +27,18 @@ After loading a page, we use the `page.pdf()` command to convert it to a PDF.
{{< tab "Playwright" >}}
```js {hl_lines=[7]}
{{< readfile filename="samples/playwright/pdf-minimal.js" >}}
```
{{< /tab >}}
{{< tab "Puppeteer" >}}
```js {hl_lines=[7]}
{{< readfile filename="samples/puppeteer/pdf-minimal.js" >}}
```
```
{{< /tab >}}
{{< /tabs >}}


Note that we need to pass the `path` option to have the PDF file actually saved to disk.

> ⚠️ This feature is currently only supported in Chromium headless in both Playwright and Puppeteer.
> ⚠️ This feature is currently only supported in Chromium headless in Playwright.
## Tweaking the result

It is important to take a quick look at the official docs for `page.pdf()` ([Puppeteer](https://pptr.dev/#?product=Puppeteer&version=v10.2.0&show=api-pagepdfoptions) or [Playwright](https://playwright.dev/docs/api/class-page#page-pdf)), as it is almost certain that we will want to tweak the appearance of our page in the resulting PDF.
It is important to take a quick look at the official docs for `page.pdf()` from [Playwright](https://playwright.dev/docs/api/class-page#page-pdf), as it is almost certain that we will want to tweak the appearance of our page in the resulting PDF.

In certain cases, our webpage might look significantly different in our PDF compared to our browser. Depending on the case, it can pay off to experiment with the following:

Expand All @@ -55,17 +51,13 @@ In certain cases, our webpage might look significantly different in our PDF comp

We can also have custom headers and footers added to our pages, displaying values such as title, page number and more. Let's see how this looks on your [favourite website](https://www.checklyhq.com/):


{{< tabs "2" >}}
{{< tab "Playwright" >}}
```js {hl_lines=["11-12","18-31"]}
{{< readfile filename="samples/playwright/pdf-hd.js" >}}
```
{{< /tab >}}
{{< tab "Puppeteer" >}}
```js {hl_lines=["11-12","20-33"]}
{{< readfile filename="samples/puppeteer/pdf-hd.js" >}}
```
{{< /tab >}}
{{< /tabs >}}

We are including the following template files for our header and footer.
Expand Down Expand Up @@ -144,7 +136,6 @@ The first page of the generated PDF looks as follows:

![generated pdf example](/samples/images/pdf-generation-hd.png)

> Chromium sets a default padding for header and footer. You will need to [override it](https://github.com/puppeteer/puppeteer/issues/4132#issuecomment-475110167) in your CSS.</style>

Run the above examples as follows:
```sh
Expand All @@ -155,10 +146,3 @@ node generate-pdf.js

We can easily transform existing web pages into PDF format, just as we have shown in our example. An even more interesting use case is about generating a brand new document: now we can use our existing HTML and CSS skills to produce high-quality PDFs, often eliminating the need for LaTeX or similar tools.

See points 2 and 3 of the following section for practical examples of this approach.

## Further reading

1. Pocket Admin's article on [generating PDF from HTML](https://pocketadmin.tech/en/puppeteer-generate-pdf/).
2. Florian Mößle's guide to [generating invoices with Puppeteer](https://medium.com/@fmoessle/use-html-and-puppeteer-to-create-pdfs-in-node-js-566dbaf9d9ca)
3. A great example of Puppeteer's PDF generation feature: [Li Haoyi](https://twitter.com/li_haoyi)'s [Hands On Scala](https://www.handsonscala.com/index.html) book. See the [build pipeline](https://github.com/handsonscala/build) behind it.
Loading

0 comments on commit c8771ed

Please sign in to comment.