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

Thank you @ankur for the confirmation.

  1. No, we are not running the parallel execution of playwright. Just using the playwright to record the flow.
  2. We are not supposed to share the info.
  3. While doing the scripting, used to change the interaction method (await.page.locator) and element selectors. Add the necessary text check, error handling and think time.

Hi @priyavp,

Thanks for the reply. Apart form page.getByRole, what other Playwright APIs would you like to see in k6?

We don’t aim to have 100% parity with Playwright, but we do want to incorporate the most used, modern and useful APIs from Playwright into k6. So, for now, I think the expectation is that users migrating from Playwright will need to do some manual adjusments to their scripts to get it to work for k6. We do aim to make this less painful, especially after the next release of k6 (v1.2.0) which should include all the page.getBy* APIs, page.route, page.all, and page.waitForURL.

Best,
Ankur