playwright-video icon indicating copy to clipboard operation
playwright-video copied to clipboard

support webkit browser

Open roughsoft opened this issue 5 years ago • 2 comments

https://github.com/microsoft/playwright/pull/2107

roughsoft avatar May 09 '20 13:05 roughsoft

@mxschmitt Did an investigation of this. It's not quite ready yet. We will definitely add it when it is though.

jperl avatar May 09 '20 14:05 jperl

Once its "officially" added (documentation too), we'll take care and add it to the project. Currently to use it it's quite hacky since we have to access internal properties etc. My current test was the following:

const fs = require("fs")
// @ts-check
const playwright = require(".");
(async () => {
  const browser = await playwright.webkit.launch({
    headless: true
  })
  const context = await browser.newContext()
  const page = await context.newPage()
  // @ts-ignore
  const wkPage = browser._wkPages.values().next().value
  let i = 0;
  // @ts-ignore
  wkPage._pageProxySession.on("Screencast.frame", async (payload) => {
    console.log(Object.keys(payload))
    try {
      await wkPage._pageProxySession.send('Screencast.frameAck');
    } catch (error) {
        console.log(`Could not ack screencast frame: ${error}`)
    }
    fs.writeFileSync(`screenshot-${i}.png`, payload.data, "base64")
    i++
  })
  await wkPage._pageProxySession.send("Screencast.start", {
    format: "png"
  })
  await page.goto("https://amazon.com");
  await page.type('#twotabsearchtextbox', "Toilet Paper");
  await page.press('#twotabsearchtextbox', "Enter");
  await page.waitForNavigation()
  await wkPage._pageProxySession.send("Screencast.stop")
  await browser.close()
})()

Type/press does not work.

mxschmitt avatar May 09 '20 14:05 mxschmitt