Getting Started with Playwright Testing
This article will walk you through the process of leveraging BrowserCat and Playwright for browser automation at scale.
Prerequisites
Before you get started, you’ll need to:
- Sign up for a free BrowserCat account.
- Create an API key.
- Install Playwright in your project…
Test using BrowserCat
Connecting your tests to BrowserCat takes just a few lines of code. Below is a minimal playwight.config.ts
to get you started:
Configure the browsers
You can tweak the browsers launched for your tests, including setting up a third-party proxy, customizing launch args, and connecting to a specific region. You can bake these settings right into the headers of your playwright.config.ts
file.
See out browser config docs for more info.
Maximize concurrency
Playwright typically limits concurrency. On a normal machine, it defaults to parallelizing to half the number of CPU cores. And in CI/CD pipelines, it disables parallelization altogether.
These are logical constrains when you consider the weight of running headless browsers locally. But when you’re running against BrowserCat’s fleet, you can safely increase concurrency… a lot.
Here’s how:
When parallelizing your tests in CI/CD, start slow and build up. Even if you aren’t launching local browsers anymore, you can still run out of memory or CPU.
Nevertheless, we’ve seen dev teams save up to 75 minutes per deploy simply by parallelizing their tests using BrowserCat’s fleet.
Next steps
Now that you’re testing against BrowserCat, explore the app dashboard. It provides realtime data about your usage. And by leveraging different API keys for different functionality, you can even use it to track costs of different features, or different environments.