timesnap icon indicating copy to clipboard operation
timesnap copied to clipboard

[FEATURE REQUEST] Playwright Support with timesnap-core

Open tungs opened this issue 3 years ago • 1 comments

Playwright is a Puppeteer alternative that offers out-of-the-box support for additional browsers, including Firefox and WebKit. The API is similar with Puppeteer's, though there are some differences that make it not completely interchangeable (in particular, Playwright's page.addInitScript, instead of page.evaluateOnNewDocument). It would be nice to add support for Playwright, so it could be used with timesnap/timesnap-core.

Is your feature request related to a problem? Please describe. No

Describe the solution you'd like It would be nice to make timesnap (and therefore timesnap-core) compatible with Playwright by checking for alternative playwright API calls and and using those if available.

Describe alternatives you've considered An alternative could be to use timeweb and Playwright, though that might replicate some of the work in timesnap and timecut.

tungs avatar Apr 24 '21 07:04 tungs

In implementing this now, there are some differences in the functions used by timesnap:

  • page.evaluateOnNewDocument becomes page.addInitScript
  • page.viewport becomes page.viewportSize
  • page.setViewport becomes page.setViewportSize, and does not support deviceScaleFactor
  • page.evaluate can take at most two arguments, the first being the function to evaluate, the second is the argument to pass to that function. Playwright does not support passing multiple arguments to the passed function. Instead, it recommends combining multiple ones into a single object.
  • page.goto(url, { waitUntil: 'networkidle0' }) does not seem to wait for the page to finish all network connections

tungs avatar Aug 14 '21 05:08 tungs