diff --git a/detect/synthetic-monitoring/playwright-checks/configuration.mdx b/detect/synthetic-monitoring/playwright-checks/configuration.mdx
index ba61703d..c5f360ed 100644
--- a/detect/synthetic-monitoring/playwright-checks/configuration.mdx
+++ b/detect/synthetic-monitoring/playwright-checks/configuration.mdx
@@ -7,7 +7,7 @@ sidebarTitle: 'Configuration'
Use the `checkly.config.ts/js` file to define your Playwright Check Suite. Each Playwright Check Suite can be connected to references in your `playwright.config.ts/js` file.
-**A Playwright Check Suite can run up to 15 minutes**. [Please contact us in the Checkly Web App](https://app.checklyhq.com/?support=true) or get in touch with your account executive if you're interested in longer runs.
+**A Playwright Check Suite can run up to 30 minutes**. [Please contact us in the Checkly Web App](https://app.checklyhq.com/?support=true) or get in touch with your account executive if you're interested in longer runs.
## Playwright Check Suite definition
@@ -216,9 +216,9 @@ Verify that `playwrightConfigPath` points to the correct relative path from your
### Test execution issues
-**Tests exceed 20-minute limit**
+**Tests exceed 30-minute limit**
-If your Playwright Check Suite times out after 20 minutes:
+If your Playwright Check Suite times out after 30 minutes:
- Split large test suites into multiple Playwright Check Suites using `pwTags` or `pwProjects`
- Use `.only` or `.skip` in your tests during development, then create separate check suites for different test priorities
@@ -238,4 +238,4 @@ If dependencies fail to install:
If tests fail due to authentication issues:
- Verify environment variables are set correctly in Checkly. You can verify your environment variables using `npx checkly env ls`, or looking at your Global or Check's environment variables in the Checkly Webapp to ensure any `process.env.VARIABLE_NAME` call from your test is defined.
-- For persistent authentication, use Playwright's [`storageState`](https://playwright.dev/docs/auth#reuse-authentication-state) feature.
\ No newline at end of file
+- For persistent authentication, use Playwright's [`storageState`](https://playwright.dev/docs/auth#reuse-authentication-state) feature.
diff --git a/detect/synthetic-monitoring/playwright-checks/overview.mdx b/detect/synthetic-monitoring/playwright-checks/overview.mdx
index 3620aef3..7589bec5 100644
--- a/detect/synthetic-monitoring/playwright-checks/overview.mdx
+++ b/detect/synthetic-monitoring/playwright-checks/overview.mdx
@@ -7,7 +7,7 @@ tags: ['synthetic-monitoring', 'playwright-checks']
## What are Playwright Check Suites?
-Playwright Check Suites turn your Playwright end-to-end tests into production monitors. Run entire test suites, specific projects, or tagged tests globally without modifying your existing code or configuration.
+**Playwright Check Suites turn your Playwright end-to-end tests into production monitors.** Run entire test suites, specific projects, or tagged tests globally without modifying your existing code or configuration.
**Known limitations**: Playwright Check Suites do not currently support monorepo workspaces for dependency installation.
diff --git a/images/icons/playwright.svg b/images/icons/playwright.svg
new file mode 100644
index 00000000..bf7f696a
--- /dev/null
+++ b/images/icons/playwright.svg
@@ -0,0 +1,21 @@
+
diff --git a/images/playwright.png b/images/playwright.png
deleted file mode 100644
index 8a6e83e3..00000000
Binary files a/images/playwright.png and /dev/null differ
diff --git a/images/samples/images/pdf-generation-hd.png b/images/samples/images/pdf-generation-hd.png
index 44cb56bb..68735772 100644
Binary files a/images/samples/images/pdf-generation-hd.png and b/images/samples/images/pdf-generation-hd.png differ
diff --git a/learn/playwright/assertions.mdx b/learn/playwright/assertions.mdx
index 0c1112dc..244c0896 100644
--- a/learn/playwright/assertions.mdx
+++ b/learn/playwright/assertions.mdx
@@ -12,12 +12,13 @@ sidebarTitle: Assertions
---
import PlaywrightCheckSuiteTryOut from "/snippets/playwright-check-suite-tryout.mdx"
+import SignUpCta from "/snippets/sign-up-cta.mdx"
### What are Playwright Assertions?
-Playwright is more than a testing framework. With its generalized tool at simulating user behavior in a browser (or via an API), playwright is better defined as a web automation framework. You can use Playwright to scrape websites, automate form submissions, or any other time it would be helpful to replace a human web user with a robot. For most users, Playwright is intimately associated with end-to-end tests, and for these we must stop our automated actions and check to see if everything is working right.
+Playwright is more than a testing framework. With its generalized tool at simulating user behavior in a browser (or via an API), Playwright is better defined as a web automation framework. You can use Playwright to scrape websites, automate form submissions, or any other time it would be helpful to replace a human web user with a robot. For most users, Playwright is intimately associated with end-to-end tests, and for these we must stop our automated actions and check to see if everything is working right.
To make an automation into a test, we have assertions. When a hard assertion fails, the execution of a Playwright test stops, and following steps are not run.
@@ -27,7 +28,7 @@ Playwright offers a variety of assertion types to accommodate different testing
### Auto-retrying, Web-first Assertions
-Auto-retrying assertions automatically recheck conditions until they pass or a timeout is reached. They both make a test more stable, and can make tests execute more quickly, and in the language of game theory should be ‘strictly better’ than non-retrying assertions.
+Auto-retrying assertions automatically recheck conditions until they pass or a timeout is reached. They both make a test more stable, and can make tests execute more quickly, and in the language of game theory should be 'strictly better' than non-retrying assertions.
| **Assertion** | **Description** |
| --- | --- |
@@ -88,21 +89,27 @@ Non-retrying assertions evaluate conditions only once. They are used when you ex
| `expect(value).toBeDefined()` | value is defined (not `undefined`). |
| `expect(value).toBeNaN()` | value is `NaN`. |
-This makes the most sense when using Playwright to run single end-to-end tests in a controlled environment. If you’re using Playwright to run on a cadence and monitor a production system, for example, with [Checkly](https://www.checklyhq.com/docs/browser-checks/playwright-test/), you generally want to stick with the auto-retrying assertions.
+This makes the most sense when using Playwright to run single end-to-end tests in a controlled environment. If you're using Playwright to run on a cadence and monitor a production system, for example, with [Checkly](https://www.checklyhq.com/docs/browser-checks/playwright-test/), you generally want to stick with the auto-retrying assertions to avoid unnecessary alerts.
### Negating Assertions
-Negating matchers allow you to assert that a condition does not hold. For example, you can use `toBeFalsy` or `not.toContain` to make negative assertions (as will be explained later, if you’re checking an element directly, probably the latter of these two options will work better as it implements Playwright’s auto-retries).
+Negating matchers allow you to assert that a condition does not hold. For example, you can use `toBeFalsy` or `not.toContain` to make negative assertions (as will be explained later, if you're checking an element directly, probably the latter of these two options will work better as it implements Playwright's auto-retries).
### Soft Assertions
-Soft assertions collect all failures within a block before failing the test, rather than stopping at the first failure. This approach is useful for gathering more complete information during test runs. Soft assertions are a critical component of production monitoring, as when measuring things like load times, a failing response time may not mean that we want to stop the check entirely. Any Playwright test with failing soft assertions will be listed as failed, but the test will still run to completion (or the next hard assertion that fails).
+Soft assertions won't fail your test immediately, but rather allow the test to continue running after a failure. Using soft assertions is useful for gathering more complete information during test runs. Soft assertions are a critical component of production monitoring, as when measuring things like load times, a failing response time may not mean that we want to stop the check entirely. Any Playwright test with failing soft assertions will still be listed as failed, but the test will still run to completion (or the next hard assertion that fails).
+
+```typescript login.spec.ts
+// if this assertion fails the following actions and
+// assertions will still run but the test will be marked as failed
+await expect.soft(page.getByTestId('cookieBanner')).toBeVisible();
+```
### Checkly, soft assertions, and degraded check states
-Checkly can use soft assertions as part of a ‘degraded’ state for checks. If a check fails soft assertions and there is a call to `markCheckAsDegraded`, the check will be placed in a ‘yellow light’ category of degraded rather than failing. Instead of categorizing the check as a total failure the 'degraded' state signals that the check encountered issues but still completed execution. Degraded checks have different notification policies. For example: you might have degraded checks report to Slack rather than sending a notification that wakes people up.
+Checkly can use soft assertions as part of [a `degraded` state for Multistep checks](/detect/synthetic-monitoring/multistep-checks/degraded-states). If a check fails soft assertions and there is a call to `markCheckAsDegraded`, the check will be placed in a 'yellow light' category of degraded rather than failing. Instead of categorizing the check as a total failure the 'degraded' state signals that the check encountered issues but still completed execution. Degraded checks have different notification policies. For example: you might have degraded checks report to Slack rather than sending a notification that wakes people up.
-This is useful for distinguishing between partial service disruptions and complete outages, offering teams a more precise understanding of performance and reliability. If your Playwright test is running on Checkly, the check will enter a ‘degraded’ state when some soft assertions fail, or if you call `markCheckAsDegraded` in its execution.
+This is useful for distinguishing between partial service disruptions and complete outages, offering teams a more precise understanding of performance and reliability. If your Playwright test is running on Checkly, the check will enter a 'degraded' state when some soft assertions fail, or if you call `markCheckAsDegraded` in its execution.
```ts soft-assertions.spec.ts
import { test, expect } from '@playwright/test'
@@ -132,7 +139,9 @@ test("SpaceX-API Dragon Capsules & Next Launch", async ({ request }) => {
})
```
-In this case if the response has a 200 status code but the API response time is more than 200 seconds, the status of this check will be degraded and the slow api response time will be included as a failed step. If the response came back as a non-200 status (indicating an error) then the check would be ‘failed,’ whether or not `markCheckAsDegraded` was called. You can [configure alert channels](https://www.checklyhq.com/docs/communicate/alerts/channels#managing-alert-channels) to notify you when a check has degraded.
+`degraded` using `@checkly/playwright-helpers` states are currently only available for [Multistep Checks](/detect/synthetic-monitoring/multistep-checks/overview) and [Browser Checks](/detect/synthetic-monitoring/browser-checks/overview).
+
+In this case if the response has a `200` status code but the API response time is more than 200 milliseconds, the status of this check will be degraded and the slow API response time will be included as a failed step. If the response came back as a non-200 status (indicating an error) then the check would be 'failed,' whether or not `markCheckAsDegraded` was called. You can [configure alert channels](https://www.checklyhq.com/docs/communicate/alerts/channels#managing-alert-channels) to notify you when a check has degraded.
### Custom Assertions
@@ -155,9 +164,9 @@ Soft assertions are helpful for tests where understanding multiple failures is b
| **Asserting non-deterministic or flaky conditions (for example images loading in X seconds)** | Yes. Can handle variations more gracefully, allowing the test to proceed for better overall coverage. | No. Would stop execution unnecessarily and increase the risk of flaky tests. |
| **Pre-check for test prerequisites** | No. If a condition must be true for the rest of the test to proceed, use a hard assertion. | Yes. If a pre-requisite check kicks off further steps, all further steps should stop if the rerequisite fails. |
| **Validating UI elements during navigation** | Yes. When testing multiple UI states, soft assertions can log failures without interrupting the flow. | Only if the missing UI element would block further navigation. |
-| **Critical database operation validations** | No. If a data inconsistency occurs, it’s usually vital to stop further operations. | Yes. Data integrity should be enforced strictly with hard assertions. |
+| **Critical database operation validations** | No. If a data inconsistency occurs, it's usually vital to stop further operations. | Yes. Data integrity should be enforced strictly with hard assertions. |
| **Form field validations** | Yes. Allows collecting errors on multiple fields at once, providing more detailed feedback. | No. Stopping at the first validation failure can hinder broader test coverage. |
-| **Verifying the presence of essential elements before action** | No. If the element must exist for the test to continue, a hard assertion ensures reliability. | Yes, if the element’s presence is not critical and you want the test to proceed. |
+| **Verifying the presence of essential elements before action** | No. If the element must exist for the test to continue, a hard assertion ensures reliability. | Yes, if the element's presence is not critical and you want the test to proceed. |
### How to Get Started with Playwright Assertions in Simple Steps
@@ -196,7 +205,7 @@ expect.extend({
expect(100).toBeWithinRange(90, 110)
```
-This can be especially useful if we’re doing complex assertions, or specialized parsing of responses.
+This can be especially useful if we're doing complex assertions, or specialized parsing of responses.
## Common Assertion Errors and How to Debug Them
@@ -204,19 +213,19 @@ Understanding how to diagnose assertion failures can save significant debugging
### Hard waits
-*Hard waits should be avoided.* A ‘hard wait’ refers to giving an exact period of time before going on to the next step of a test. Generally using code like:
+*Hard waits should be avoided.* A 'hard wait' refers to giving an exact period of time before going on to the next step of a test. Generally using code like:
```ts bad-practice.spec.ts
await page.waitForTimeout(3000);
```
-When you have page components you want to ensure are loading quickly, or you have page components that you know take some time to load, it’s tempting to reach for a hard wait, however, there are better ways to accomplish this functionality, like the soft assertions and auto-retry assertions listed above.
+When you have page components you want to ensure are loading quickly, or you have page components that you know take some time to load, it's tempting to reach for a hard wait, however, there are better ways to accomplish this functionality, like the soft assertions and auto-retry assertions listed above.
-After that fixed period, if the next step doesn’t work, the test will fail. Hard waits are the most common cause of unreliable or ‘flaky’ tests with Playwright. They’re also inefficient, if the element we’re checking for becomes available *before* the hard wait time has elapsed, the test runner still has to wait to the end of the wait time. Read more about this in our page on [waiting in Playwright](https://www.checklyhq.com/learn/playwright/waits-and-timeouts/).
+After that fixed period, if the next step doesn't work, the test will fail. Hard waits are the most common cause of unreliable or 'flaky' tests with Playwright. They're also inefficient, if the element we're checking for becomes available *before* the hard wait time has elapsed, the test runner still has to wait to the end of the wait time. Read more about this in our page on [waiting in Playwright](https://www.checklyhq.com/learn/playwright/waits-and-timeouts/).
### Manual Assertions
-While a hard wait is problematic since it doesn’t benefit from Playwright’s auto-waiting, an improperly structured assertion doesn’t include waiting at all. By wrapping the `await` inside the `expect()` instead of vice versa, and by using a non-web-first assertion, we get no waiting. In this case we’re checking that there is some text inside an element.
+While a hard wait is problematic since it doesn't benefit from Playwright's auto-waiting, an improperly structured assertion doesn't include waiting at all. By wrapping the `await` inside the `expect()` instead of vice versa, and by using a non-web-first assertion, we get no waiting. In this case we're checking that there is some text inside an element.
```ts manual-assertion-bad.spec.ts
// expects the text to be visible instantly
@@ -242,26 +251,28 @@ Flaky tests are those that fail intermittently, often due to timing issues or un
Implementing best practices can make your tests more reliable and easier to maintain.
-- **Test Granularity**: Structure tests to cover distinct, isolated behaviors, making debugging easier. The choice between one ‘super test’ and 5 or 10 smaller tests should always go with the more granular option. Since [tests can be run in parallel](https://www.checklyhq.com/learn/playwright/testing-in-parallel/), it’s likely that better test granularity will also improve test execution time.
-- **Create Concise Statements**: Keep assertions simple and focused. Asserting that five different page components is an indicator that you’re testing multiple ideas with one test, and want to consider either breaking up your test or should at least have multiple steps.
-- **Use Descriptive Messages**: Adding clear messages to assertions helps identify failures quickly. It’s also good to use [test steps](https://www.checklyhq.com/blog/improve-your-playwright-documentation-with-steps/) to add more description to the exact phase where the test failed. Read further to see how to [add test steps programmatically with Typescript decorators](https://www.checklyhq.com/blog/playwright-test-steps-with-typescript-decorators/).
+- **Test Granularity**: Structure tests to cover distinct, isolated behaviors, making debugging easier. The choice between one 'super test' and 5 or 10 smaller tests should always go with the more granular option. Since [tests can be run in parallel](https://www.checklyhq.com/learn/playwright/testing-in-parallel/), it's likely that better test granularity will also improve test execution time.
+- **Create Concise Statements**: Keep assertions simple and focused. Asserting that five different page components is an indicator that you're testing multiple ideas with one test, and want to consider either breaking up your test or should at least have multiple steps.
+- **Use Descriptive Messages**: Adding clear messages to assertions helps identify failures quickly. It's also good to use [test steps](https://www.checklyhq.com/blog/improve-your-playwright-documentation-with-steps/) to add more description to the exact phase where the test failed. Read further to see how to [add test steps programmatically with Typescript decorators](https://www.checklyhq.com/blog/playwright-test-steps-with-typescript-decorators/).
- **Parameterize Assertions**: Use variables for assertion parameters to improve test readability and maintainability.
-- **Leverage Libraries**: Utilize existing libraries for common assertions where possible. Note that if you’re running tests on a cadence, a full set of libraries may not be available in your execution environment.
+- **Leverage Libraries**: Utilize existing libraries for common assertions where possible. Note that if you're running tests on a cadence, a full set of libraries may not be available in your execution environment.
- **Be Specific**: Make sure your assertions are as targeted as possible to avoid false positives. Bet on auto-waiting and web-first assertions. Even a change from checking if a text label has the needed text with [`.toContain()`](https://playwright.dev/docs/api/class-genericassertions#generic-assertions-to-contain-1) rather than `toBe()` can improve the reliability of a page monitor.
-- **Leverage Built-in Timeout**: Use Playwright’s built-in timeout features to handle flaky conditions gracefully. Avoid hard waits whenever possible.
+- **Leverage Built-in Timeout**: Use Playwright's built-in timeout features to handle flaky conditions gracefully. Avoid hard waits whenever possible.
+
+### How Checkly can help with Playwright
-### How can Checkly Help with Playwright Assertions
+Checkly enables you to take your existing Playwright code base to run it as global synthetic monitoring. Use the power of Playwright to effectively simulate a real user's behavior with your site or service, and get alerts of problems before your users have noticed.
-Checkly offers tools for continuous monitoring using Playwright scripts. With Checkly, you use the power of Playwright to effectively simulate a real user’s behavior with your site or service, and a can get alerts of problems before your users have noticed.
+
### Conclusion
-By using the right types of assertions, debugging tools, and best practices, you can ensure your tests are robust and efficient. In general, my direct experience has served to emphasize the wisdom of the Playwright project’s recommendations: web first assertions, dependent on web-first selectors.
+By using the right types of assertions, debugging tools, and best practices, you can ensure your tests are robust and efficient. In general, my direct experience has served to emphasize the wisdom of the Playwright project's recommendations: web first assertions, dependent on web-first selectors.
-For assertions, web-first, auto-retrying assertions are the preferred choice for most scenarios, as they leverage Playwright’s built-in waiting mechanisms, making tests more resilient and less prone to flakiness. These assertions continuously check conditions until they pass or reach a timeout, which can help streamline test execution. Examples like `toBeVisible` or `toContainText` illustrate how these assertions can improve test stability. On the other hand, non-retrying assertions evaluate conditions just once and should be reserved for scenarios where retries are unnecessary or could introduce ambiguity. Anything other than web-first assertions will lead to brittle tests with more false positives.
+For assertions, web-first, auto-retrying assertions are the preferred choice for most scenarios, as they leverage Playwright's built-in waiting mechanisms, making tests more resilient and less prone to flakiness. These assertions continuously check conditions until they pass or reach a timeout, which can help streamline test execution. Examples like `toBeVisible` or `toContainText` illustrate how these assertions can improve test stability. On the other hand, non-retrying assertions evaluate conditions just once and should be reserved for scenarios where retries are unnecessary or could introduce ambiguity. Anything other than web-first assertions will lead to brittle tests with more false positives.
Soft assertions also add value by collecting all failures within a block before stopping the test, offering a complete picture of what went wrong. They are especially useful in production monitoring scenarios where partial failures should not disrupt the entire check, as seen in the Checkly example using `markCheckAsDegraded`. The ability to use soft assertions alongside the concept of a degraded state provides a nuanced way to monitor service health without causing false alarms.
-I’ll again recommend avoiding some common pitfalls, such as relying on hard waits, which can introduce flakiness and inefficiency into your tests. Using auto-waiting mechanisms and structuring assertions properly can make a significant difference. Debugging tools like `page.pause()` and verbose logging, combined with visual debugging options, can be valuable in diagnosing test failures.
+I'll again recommend avoiding some common pitfalls, such as relying on hard waits, which can introduce flakiness and inefficiency into your tests. Using auto-waiting mechanisms and structuring assertions properly can make a significant difference. Debugging tools like `page.pause()` and verbose logging, combined with visual debugging options, can be valuable in diagnosing test failures.
Follow best practices now for a better testing and monitoring experience later. These include using concise, focused assertions, adding descriptive messages for better debugging, and leveraging built-in timeouts and parameterization for clarity and maintainability. Granular test design also matters as a way to improve both parallel execution efficiency and debugging ease. Avoiding complex, monolithic tests in favor of smaller, well-defined ones can make your testing framework more manageable and robust.
diff --git a/learn/playwright/authentication.mdx b/learn/playwright/authentication.mdx
index e4fbfe42..4285769f 100644
--- a/learn/playwright/authentication.mdx
+++ b/learn/playwright/authentication.mdx
@@ -20,6 +20,7 @@ aliases:
- managing-cookies
---
+import SignUpCta from "/snippets/sign-up-cta.mdx"
import PlaywrightCheckSuiteTryOut from "/snippets/playwright-check-suite-tryout.mdx"
@@ -197,14 +198,14 @@ test('API token auth', async ({ request }) => {
'Authorization': `Bearer ${process.env.API_TOKEN}`
}
})
- expect(response).toBeOK()
+ expect(response).toBeOK()
})
```
Just like with username and password authentication, make sure to store your API tokens securely using environment
variables.
-# Reusing authentication state with storageState
+# Reusing authentication state with `storageState`
All of the above examples work fine if you are running just one test that requires authentication. However, the
moment you will run more tests — either in parallel or in sequence — you will exercise your authentication
@@ -215,7 +216,7 @@ Ideally, you can authenticate once and reuse the authenticated state across mult
[Playwright has this feature baked in](https://playwright.dev/docs/auth) and leverages something called `storageState`.
It requires a little setup 👇
-## Setting up the playwright.config.ts file
+## Setting up the `playwright.config.ts` file
The recommended way to reuse auth state is by setting up **projects** in your `playwright.config.ts` file and defining a `setup` step that references file — `auth.setup.ts` for example — that takes care of the necessary authentication flow.
@@ -303,3 +304,5 @@ When writing automation scripts that deal with authentication, there are some ge
- [How to automate Google login with Playwright.](https://www.checklyhq.com/learn/playwright/google-login-automation/)
- [How to bypass Time-Based 2FA login flows with Playwright.](https://www.checklyhq.com/learn/playwright/bypass-totp/)
+
+
diff --git a/learn/playwright/bypass-totp.mdx b/learn/playwright/bypass-totp.mdx
index b28ff6b5..252c03ff 100644
--- a/learn/playwright/bypass-totp.mdx
+++ b/learn/playwright/bypass-totp.mdx
@@ -14,6 +14,7 @@ learn_playwright:
---
import PlaywrightCheckSuiteTryOut from "/snippets/playwright-check-suite-tryout.mdx"
+import SignUpCta from "/snippets/sign-up-cta.mdx"
@@ -188,3 +189,5 @@ I’m still amazed at how far we’ve come with the recent tooling. Playwright c
But keep in mind end-to-end testing is only a tiny fraction of guaranteeing that your product is working. Third-party providers can go rogue, or your database can struggle days after you tested your deployment. That’s why I’m excited to announce that [the recently released Checkly runtime (2022.10)](https://www.checklyhq.com/docs/runtimes/specs/#2022.10) includes the “otpauth” package and allows you to test your products at all times — even the ones that are behind a 2FA secured login!
Do you want to be the first one to know when something’s off with your application? Give Checkly a try 😉.
+
+
diff --git a/learn/playwright/challenging-flows.mdx b/learn/playwright/challenging-flows.mdx
index 23c85f3a..8759d43a 100644
--- a/learn/playwright/challenging-flows.mdx
+++ b/learn/playwright/challenging-flows.mdx
@@ -13,6 +13,7 @@ learn_playwright:
---
import PlaywrightCheckSuiteTryOut from "/snippets/playwright-check-suite-tryout.mdx"
+import SignUpCta from "/snippets/sign-up-cta.mdx"
@@ -67,3 +68,5 @@ In these cases, UI automation is specifically made more difficult by utilising c
## Further reading
1. [OWASP's Automated Threat list](https://wiki.owasp.org/index.php/Category:Automated_Threat)
+
+
diff --git a/learn/playwright/checkout-testing-guide.mdx b/learn/playwright/checkout-testing-guide.mdx
index f73badd5..98626dfa 100644
--- a/learn/playwright/checkout-testing-guide.mdx
+++ b/learn/playwright/checkout-testing-guide.mdx
@@ -13,6 +13,7 @@ learn_playwright:
---
import PlaywrightCheckSuiteTryOut from "/snippets/playwright-check-suite-tryout.mdx"
+import SignUpCta from "/snippets/sign-up-cta.mdx"
@@ -82,3 +83,5 @@ Checkout is a peculiar flow: unlike Login and others, it almost always involves
1. Checkout flows will vary depending on what is being purchased.
2. Remember to check different flows (e.g. with and without login) if needed.
3. Additional care is needed on production systems as real transactions will take place.
+
+
diff --git a/learn/playwright/clicking-typing-hovering.mdx b/learn/playwright/clicking-typing-hovering.mdx
index e399448f..1da2a952 100644
--- a/learn/playwright/clicking-typing-hovering.mdx
+++ b/learn/playwright/clicking-typing-hovering.mdx
@@ -17,6 +17,7 @@ learn_playwright:
parent: "Interaction"
---
+import SignUpCta from "/snippets/sign-up-cta.mdx"
import PlaywrightCheckSuiteTryOut from "/snippets/playwright-check-suite-tryout.mdx"
@@ -38,12 +39,6 @@ test('can click log in', async ({ page }) => {
})
```
-
-For the times when even the humble click fails, you can try the following alternatives:
-1. `await page.click('#login', { force: true })` to force the click even if the selected element appears not to be accessible
-2. `await page.$eval('#login', elem => elem.click())` to run the click inside the webpage
-3. `await page.dispatchEvent('#login', 'click')` to directly dispatch the click event on the element
-
## Hovering
A popular pattern among web pages is exposing additional information or functionality when the user hovers the mouse cursor over a specific item. Examples include, menus, previews and dialogs containing extra information on the item.
@@ -108,6 +103,8 @@ You can run (from the terminal) the above examples as follows:
npx playwright test basic-click-type.ts
```
+
+
## Further reading
1. The related official documentation of [Playwright](https://playwright.dev/docs/input#mouse-click)
2. [Finding effective selectors](/learn/playwright/selectors/)
diff --git a/learn/playwright/codegen.mdx b/learn/playwright/codegen.mdx
index 17d04f41..16c2be0c 100644
--- a/learn/playwright/codegen.mdx
+++ b/learn/playwright/codegen.mdx
@@ -14,6 +14,7 @@ learn_playwright:
---
import PlaywrightCheckSuiteTryOut from "/snippets/playwright-check-suite-tryout.mdx"
+import SignUpCta from "/snippets/sign-up-cta.mdx"
import { YoutubeEmbed } from "/snippets/youtube-embed.jsx"
@@ -60,7 +61,7 @@ test('test', async ({ page }) => {
Note that codegen will make a ‘best effort’ at emulating your actions and writing ‘best practice’ code, so you should always review it before deploying.
-### Step 5: Add Assertions to your tests
+### Step 3: Add Assertions to your tests
Every action in the script above has implicit assertions about the elements we interact with. Playwright will expect these elements are stable, visible, and enabled; and if one isn’t then the test will fail we could call this done, but we generally want our tests to contain assertions beyond just navigating. There are a few reasons why you should have assertions in your test: It makes it clearer to future coders what your test was checking for, and the error message is more useful from a failed assertion rather than just failing to find an element. Right now all we’ll get if the test above fails is a timeout and a line which failed.
@@ -89,11 +90,13 @@ For this example, let's pick JavaScript. You can copy the generated script from
### Step 5: Save and Run Your Script
-With your script copied, you can drop the test into your Playwright spec file, and run it to see the results. Note that the script as generated contains no comments, and isn’t in steps. If you want to be considerate of your next coder, who let’s be honest is probably you in 6 months having forgotten everything about this test, add some comments, give the test a more helpful name than `'test'` and [divide the test into steps for readability](https://www.checklyhq.com/blog/improve-your-playwright-documentation-with-steps/).
+With your script copied, you can drop the test into a Playwright `spec` file, and run it with `npx playwright test` to see the results. Note that the script as generated contains no comments or further explanations. If you want to be considerate of your next coder, who let’s be honest is probably you in 6 months having forgotten everything about this test, add some comments, give the test a more helpful name than `'test'` and [divide the test into steps for readability](https://www.checklyhq.com/blog/improve-your-playwright-documentation-with-steps/).
-### Step 5: Run Your Script in the Cloud
+### Step 6: Run Your Script in the Cloud
-The script you generated works perfectly in your local environment. But if you want to take it a step further, you can copy and [paste the script into a Checkly browser check](https://www.checklyhq.com/docs/browser-checks/) to run it in the cloud on their infrastructure. This is especially useful for continuous monitoring and testing in different environments and from different geographies. If you’re not partial to a web interface, deploy your locally saved Playwright tests directly to Checkly with the [Checkly CLI](https://www.checklyhq.com/cli/overview). With our CLI, you can work on tests locally and then run them through the Checkly system right from your command line.
+If you want to take it a step further, use [Playwright Check Suites](/detect/synthetic-monitoring/playwright-checks/overview) to run your Playwright tests in the Checkly infrastructure as synthetic monitoring.
+
+
### Bonus Step 1: Add Playwright to Visual Studio Code
@@ -131,3 +134,5 @@ To see the highly visual codegen tool in action, check out Stefan’s video belo
You’ve just taken your first steps with creating Playwright tests. Playwright's `codegen` is a powerful tool that simplifies the process of creating automation scripts. As it produces assertions and locators that are industry standard, you should use anytime you need to make a clean, readable test or automation for your site.
If you’d like to dive deeper into Playwright and Checkly’s monitoring tools, join our [upcoming Kick-Start webinar](https://us02web.zoom.us/webinar/register/WN_gKYeJcMqQ_Kh31ziKM7uYw) to see how your end-to-end testing can grow into bullet-proof site monitoring to defend your SLA.
+
+
diff --git a/learn/playwright/debugging-errors.mdx b/learn/playwright/debugging-errors.mdx
index 89ba953c..d3f8f280 100644
--- a/learn/playwright/debugging-errors.mdx
+++ b/learn/playwright/debugging-errors.mdx
@@ -15,6 +15,7 @@ learn_playwright:
---
import PlaywrightCheckSuiteTryOut from "/snippets/playwright-check-suite-tryout.mdx"
+import SignUpCta from "/snippets/sign-up-cta.mdx"
@@ -40,3 +41,5 @@ To help avoid stressful and unsuccessful debugging sessions, it might help to co
2. [Error: element not visible](/learn/playwright/error-element-not-visible/)
3. [Error: target closed](/learn/playwright/error-target-closed/)
4. [Error: wait not respected](/learn/playwright/error-wait-not-respected/)
+
+
diff --git a/learn/playwright/debugging.mdx b/learn/playwright/debugging.mdx
index d7b51dfa..df69625f 100644
--- a/learn/playwright/debugging.mdx
+++ b/learn/playwright/debugging.mdx
@@ -15,6 +15,7 @@ learn_playwright:
---
import PlaywrightCheckSuiteTryOut from "/snippets/playwright-check-suite-tryout.mdx"
+import SignUpCta from "/snippets/sign-up-cta.mdx"
@@ -117,3 +118,5 @@ The Inspector allows us to easily step through each instruction of our script, w
1. [Debugging challenges](/learn/playwright/debugging-errors/)
2. [Working with selectors](/learn/playwright/selectors/)
+
+
diff --git a/learn/playwright/emulating-mobile-devices.mdx b/learn/playwright/emulating-mobile-devices.mdx
index fd200abc..3e21785c 100644
--- a/learn/playwright/emulating-mobile-devices.mdx
+++ b/learn/playwright/emulating-mobile-devices.mdx
@@ -17,6 +17,7 @@ learn_playwright:
parent: "Basics"
---
+import SignUpCta from "/snippets/sign-up-cta.mdx"
import PlaywrightCheckSuiteTryOut from "/snippets/playwright-check-suite-tryout.mdx"
@@ -95,3 +96,5 @@ test('emulate iPhone SE', async ({ page }) => {
1. [Measuring page performance](/learn/playwright/performance/)
2. [Playwright's emulation documentation](https://playwright.dev/docs/emulation)
+
+
diff --git a/learn/playwright/error-click-not-executed.mdx b/learn/playwright/error-click-not-executed.mdx
index 40ceb41a..4af9d7c2 100644
--- a/learn/playwright/error-click-not-executed.mdx
+++ b/learn/playwright/error-click-not-executed.mdx
@@ -12,6 +12,7 @@ learn_playwright:
---
import PlaywrightCheckSuiteTryOut from "/snippets/playwright-check-suite-tryout.mdx"
+import SignUpCta from "/snippets/sign-up-cta.mdx"
@@ -34,3 +35,5 @@ Unless you know for certain, do not assume that the page you are automating foll
If you are running Playwright 1.14 or newer, you can also enable [strict mode](https://playwright.dev/docs/release-notes#version-114) to have it throw an error in case your selector matches more than one element on the page: `await page.click('mySelector', { strict: true });`
> Note that this list neither is nor aims to be complete: additional possible causes most likely exist for this error.
+
+
diff --git a/learn/playwright/error-element-not-found.mdx b/learn/playwright/error-element-not-found.mdx
index 4ba19a5c..41f4a1d0 100644
--- a/learn/playwright/error-element-not-found.mdx
+++ b/learn/playwright/error-element-not-found.mdx
@@ -12,6 +12,7 @@ learn_playwright:
---
import PlaywrightCheckSuiteTryOut from "/snippets/playwright-check-suite-tryout.mdx"
+import SignUpCta from "/snippets/sign-up-cta.mdx"
@@ -33,3 +34,5 @@ UnhandledPromiseRejectionWarning: Error: No node found for selector: ...
Either walk through the execution in headful mode or take screenshots before and after the instruction that has raised the error - this will help you verify whether the application state actually is the one you expect.
> Note that this list neither is nor aims to be complete: additional possible causes most likely exist for this error.
+
+
diff --git a/learn/playwright/error-element-not-visible.mdx b/learn/playwright/error-element-not-visible.mdx
index 88d43a18..d11b80c3 100644
--- a/learn/playwright/error-element-not-visible.mdx
+++ b/learn/playwright/error-element-not-visible.mdx
@@ -12,6 +12,7 @@ learn_playwright:
---
import PlaywrightCheckSuiteTryOut from "/snippets/playwright-check-suite-tryout.mdx"
+import SignUpCta from "/snippets/sign-up-cta.mdx"
@@ -35,3 +36,5 @@ waiting for selector ".contact-form > .form-control" to be visible
Either walk through the execution in headful mode or take screenshots before and after the instruction that has raised the error - this will help you verify whether the application state actually is the one you expect.
> Note that this list neither is nor aims to be complete: additional possible causes most likely exist for this error.
+
+
diff --git a/learn/playwright/error-target-closed.mdx b/learn/playwright/error-target-closed.mdx
index d51b8cac..7d3406d0 100644
--- a/learn/playwright/error-target-closed.mdx
+++ b/learn/playwright/error-target-closed.mdx
@@ -12,6 +12,7 @@ learn_playwright:
---
import PlaywrightCheckSuiteTryOut from "/snippets/playwright-check-suite-tryout.mdx"
+import SignUpCta from "/snippets/sign-up-cta.mdx"
@@ -30,3 +31,5 @@ UnhandledPromiseRejectionWarning: Error: Protocol error: Target closed
2. [Wrong foreach usage](https://github.com/babel/babel/issues/909): [forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) expects a synchronous function, so use a [for-of loop](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of) if you are using `await`.
> Note that this list neither is nor aims to be complete: additional possible causes most likely exist for this error.
+
+
diff --git a/learn/playwright/error-wait-not-respected.mdx b/learn/playwright/error-wait-not-respected.mdx
index 27114e0c..2eda7739 100644
--- a/learn/playwright/error-wait-not-respected.mdx
+++ b/learn/playwright/error-wait-not-respected.mdx
@@ -12,6 +12,7 @@ learn_playwright:
---
import PlaywrightCheckSuiteTryOut from "/snippets/playwright-check-suite-tryout.mdx"
+import SignUpCta from "/snippets/sign-up-cta.mdx"
@@ -28,3 +29,5 @@ For example: we are waiting for an element, e.g. with `page.waitForSelector`, bu
Try querying for the element in the browser console during inspection. If the element is found, inspect its attributes (e.g. `visibility`) and ensure they match your expectations.
> Note that this list neither is nor aims to be complete: additional possible causes most likely exist for this error.
+
+
diff --git a/learn/playwright/file-download.mdx b/learn/playwright/file-download.mdx
index d9e047dd..ebdadedc 100644
--- a/learn/playwright/file-download.mdx
+++ b/learn/playwright/file-download.mdx
@@ -14,6 +14,7 @@ learn_playwright:
---
import PlaywrightCheckSuiteTryOut from "/snippets/playwright-check-suite-tryout.mdx"
+import SignUpCta from "/snippets/sign-up-cta.mdx"
@@ -126,3 +127,5 @@ npx playwright test file-download.spec.ts
## Further reading
1. [Playwright's](https://playwright.dev/#version=v1.3.0&path=docs%2Fapi.md&q=class-download) documentation on downloading files.
+
+
diff --git a/learn/playwright/generating-pdfs.mdx b/learn/playwright/generating-pdfs.mdx
index 002e69ee..e3896200 100644
--- a/learn/playwright/generating-pdfs.mdx
+++ b/learn/playwright/generating-pdfs.mdx
@@ -12,6 +12,7 @@ learn_playwright:
parent: "Basics"
---
+import SignUpCta from "/snippets/sign-up-cta.mdx"
import PlaywrightCheckSuiteTryOut from "/snippets/playwright-check-suite-tryout.mdx"
@@ -61,7 +62,7 @@ We can also have custom headers and footers added to our pages, displaying value
import { test, expect } from '@playwright/test';
test('generate PDF with header and footer', async ({ page }) => {
- await page.goto('https://www.checklyhq.com/');
+ await page.goto('https://www.checklyhq.com/docs/');
await page.pdf({
path: 'checkly-with-header-footer.pdf',
format: 'A4',
@@ -78,7 +79,7 @@ test('generate PDF with header and footer', async ({ page }) => {
});
```
-We are including the following template files for our header and footer.
+Change `headerTemplate` and `footerTemplate` to include more complex templates like these ones below.
**template-header.html**
```html
@@ -147,7 +148,7 @@ We are including the following template files for our header and footer.