microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
66.22k stars 3.62k forks source link

[Feature]: configure `page.pause` behavior on remote servers #32397

Open chris9979 opened 1 month ago

chris9979 commented 1 month ago

🚀 Feature Request

AFAICT as of version 1.41.0, the Playwright server always ignores pauses. Would it be possible to add an option to not ignore pauses on the server? Or, perhaps, could the Playwright server only ignore pauses when running headlessly?

Example

With the hypothetical parameter name allowPause:

const {chromium} = require('playwright');
const browserServer = await chromium.launchServer({
  allowPause: true
});

Motivation

At work, we run Playwright servers on our laptops via Docker, so all our developers can work in a consistent environment. We also like using page.pause while writing our tests, so to make that work, we're currently patching the Playwright source code in our Docker images (which is admittedly gross). This feature would mean we don't have to resort to such a hack.

(On the bright side, this hack has made me familiar enough with the Playwright codebase that I'm comfortable submitting a PR for this issue, if you want to move forward with it).

dgozman commented 1 month ago

@chris9979 Could you please tell me more about your setup? Do you run tests in headed mode in Docker? Do you expect to see Playwright Inspector upon page.pause() call? If so, why don't you host everything in the docker, and just run in local mode? What's the advantage of client/server for you usecase?

chris9979 commented 1 month ago

@dgozman Yes, we do run tests in headed mode inside Docker, albeit only while developing or debugging tests. The rest of the time, we run the tests headlessly. When running headed though, we are hoping to see the Playwright Inspector after calling page.pause().

As for why we're using the client/server setup, it lets us keep our client container (which contains the website we're testing) mostly untouched and "truer" to our production website, and offload the Playwright server to its own container. That's really the only reason why we don't put everything in one container, although I'm certainly willing to reevaluate our setup if this feature request isn't practical.