Playwright Recording to k6 Script: Is Manual Translation Necessary?

I’m looking into browser-based performance testing and used Playwright to record a user flow. My goal is to use this flow for load testing with k6.
However, I’ve found that the Playwright script doesn’t work directly in k6. When I try to adapt it, I constantly have to change browser interaction methods (await page.getByRole to await page.locator) and element selectors (‘link’, { name: ‘EST-6’ } to #Catalog > table > tbody > tr:nth-child(2) > td:nth-child(1) > a) into k6’s request.
Is this manual process of translating browser actions and selectors into k6 requests the standard and recommended way to use Playwright recordings (or similar browser automation flows) for k6 load testing? Or is there a method to use Playwright scripts with k6 with fewer changes?

Playwright Script:

K6 Script:

@priyavp,

Thank you for starting this discussion! This is something that we are currently focused on. At the moment this is unfortunately the only way to migrate tests from Playwright to k6 – a very manual and tedious way, i know.

However we are working on bringing more of Playwrights APIs to k6 that we see the community need and request.

I’m keen to understand a few things from you:

  1. I understand that you want to perform browser based load testing, but have you considered the parallel execution of Playwright? What is k6 doing that meets your needs in this space, and obviously what would help to enhance the experience (apart from better playwright parity).
  2. Is there anyway we can explore more of your Playwright test scripts to get an idea of what APIs you work with to help us prioritise the APIs that are most used by the community?
  3. When you use Playwright to record a script, what else do you do to the script to make it work for your use case? Or do you just migrate it over as is?

We’re currently working on implementing page.getBy* and page.route since there has been a large demand for these APIs from the community, and they should make it into the v1.1.0 release of k6.

Best,
Ankur