Playwright

  • automation & notes
  • in current work

Playwright is what I moved to after years of wrestling with Selenium. Same idea (automated browser control) but everything about it feels more modern. No more fiddling with driver binaries, no more Chrome version mismatches. It just works, and it works fast.

I first picked it up when a company needed their JavaScript scraping library translated into Python, and Playwright was the natural choice since it runs natively in both. Part of the spec required loading browser add-ons to block ads and cookies, something Playwright handled cleanly. From there it became my default. I used it heavily in the Companies Summary Generator to scrape hundreds of company websites, and again in Funding News Automation for pulling structured data from news sources.

The API is intuitive, the auto-wait logic saves you from writing brittle sleep statements, and the built-in codegen tool, where it records your browser actions and spits out code, is genuinely useful for prototyping. If you're starting fresh with browser automation today, skip Selenium and start here.

los/frontend/src/sw/offline.e2e.tslines 50–75 · private repo
test('offline: the app opens with what it last saw, and a timer started offline lands once the connection is back, from the moment it was tapped', async ({
	page,
	context,
	request,
}) => {
	await openWithWorker(page);

	await goOffline(context);
	await page.reload();
	await expect(page.getByText("Can't reach the server: showing saved data")).toBeVisible();
	await expect(page.getByRole('button', { name: 'Walk' })).toBeVisible();

	const tapped = Date.now();
	await page.getByRole('button', { name: 'Walk' }).click();
	// Running at once, stoppable, and the app says the start is waiting.
	await expect(page.getByRole('button', { name: 'Stop' })).toBeEnabled();
	await expect(page.getByText("Can't reach the server: 1 change waiting…")).toBeVisible();
	expect(await walks(request)).toEqual([]);

	await goOnline(context);
	await expect.poll(async () => (await walks(request)).length, { timeout: 20_000 }).toBe(1);
	const [walk] = await walks(request);
	expect(Math.abs(new Date(walk.startTime).getTime() - tapped)).toBeLessThan(3_000);
	expect(walk.endTime).toBeNull();
	await expect(page.getByText(/change waiting/)).toHaveCount(0);
});