{"id":13342849,"url":"https://github.com/nicholasvuono/xk6-playwright","last_synced_at":"2025-04-13T05:11:27.857Z","repository":{"id":49811342,"uuid":"428379263","full_name":"nicholasvuono/xk6-playwright","owner":"nicholasvuono","description":"k6 extension that adds support for browser automation and end-to-end web testing using playwright-go","archived":false,"fork":false,"pushed_at":"2024-06-10T16:52:04.000Z","size":116,"stargazers_count":51,"open_issues_count":0,"forks_count":11,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-26T22:03:09.129Z","etag":null,"topics":["browser-automation","end-to-end-testing","k6","playwright","xk6","xk6-playwright"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nicholasvuono.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-15T18:34:18.000Z","updated_at":"2025-02-27T10:32:51.000Z","dependencies_parsed_at":"2024-06-10T19:07:36.696Z","dependency_job_id":"75709d4a-aacc-4cd5-8c54-782438dec9e4","html_url":"https://github.com/nicholasvuono/xk6-playwright","commit_stats":null,"previous_names":["nicholasvuono/xk6-playwright","wosp-io/xk6-playwright"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholasvuono%2Fxk6-playwright","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholasvuono%2Fxk6-playwright/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholasvuono%2Fxk6-playwright/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholasvuono%2Fxk6-playwright/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nicholasvuono","download_url":"https://codeload.github.com/nicholasvuono/xk6-playwright/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248665746,"owners_count":21142123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browser-automation","end-to-end-testing","k6","playwright","xk6","xk6-playwright"],"created_at":"2024-07-29T19:30:06.148Z","updated_at":"2025-04-13T05:11:27.837Z","avatar_url":"https://github.com/nicholasvuono.png","language":"Go","funding_links":[],"categories":["Extensions"],"sub_categories":["Community"],"readme":"\u003e ℹ️\n\u003e\n\u003e This is not supported by the k6 team, and is worked on by a(n) individual contributor(s).\n\u003e It may also break in the future as both xk6 and playwright-go evolve.\n\u003e Any issues with the tool should be raised [here](https://github.com/nicholasvuono/xk6-playwright/issues).\n\u003e\n\u003eIt is not production ready yet, but definitely works as intended! Please enjoy the tool!\n\n\u003cbr\u003e\u003cbr\u003e\n\u003cdiv align=\"center\"\u003e\n   \u003cimg src=\"images/xk6_logo.PNG\" width=\"400\" alt=\"xk6-playwright\"/\u003e\u003cbr\u003e\n   \u003ch1\u003e\u003cb\u003exk6 playwright\u003c/b\u003e\u003c/h1\u003e\u003cbr\u003e\n   \u003cp\u003ek6 extension that adds support for browser automation and end-to-end web testing using \u003ca href=\"https://github.com/mxschmitt/playwright-go\" target=\"_blank\"\u003eplaywright-go\u003c/a\u003e\u003c/p\u003e\n   \u003cp\u003eSpecial thanks to all the contributors over at \u003ca href=\"https://github.com/grafana/k6/graphs/contributors\" target=\"_blank\"\u003ek6\u003c/a\u003e and \u003ca href=\"https://github.com/mxschmitt/playwright-go/graphs/contributors\" target=\"_blank\"\u003eplaywright-go\u003c/a\u003e\n   \u003cp\u003eHere's to open source!\u003c/p\u003e\n\n   \u003ca href=\"https://github.com/nicholasvuono/xk6-playwright/releases\"\u003e\u003cimg alt=\"GitHub license\" src=\"https://img.shields.io/badge/release-v0.3.3-blue\"\u003e\u003c/a\u003e\n   \u003ca href=\"https://goreportcard.com/report/github.com/wosp-io/xk6-playwright\"\u003e\u003cimg src=\"https://goreportcard.com/badge/github.com/wosp-io/xk6-playwright?dummy=unused\" alt=\"Go Report Card\"\u003e\u003c/a\u003e\n   \u003ca href=\"https://github.com/wosp-io/xk6-playwright/blob/main/LICENSE\"\u003e\u003cimg alt=\"GitHub license\" src=\"https://img.shields.io/github/license/wosp-io/xk6-playwright?color=red\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n----\n\u003cbr\u003e\u003cbr\u003e\n## Origin Story\n\nThis project was inspired by \u003ca href=\"https://github.com/grafana/xk6-browser\" target=\"_blank\"\u003exk6-browser\u003c/a\u003e. Having previously worked with \u003ca href=\"https://github.com/mxschmitt/playwright-go\" target=\"_blank\"\u003eplaywright-go\u003c/a\u003e we thought it would be a great idea to create an alternative extension around browser automation for the k6 community. Thus \u003ca href=\"https://github.com/wosp-io/xk6-playwright\" target=\"_blank\"\u003exk6 playwright\u003c/a\u003e was born!\n\n#### Note\u003c/br\u003e\nAlthough xk6-browser is still experimental it is pretty awesome and now comes bundled with k6 v0.46.0 and greater! In case this doesn't fit all your needs, go check that out!\n\n\u003c/br\u003e\n\n## Build the executable\n\nTo build a `k6` binary with this extension, first ensure you have the prerequisites:\n\n- Docker\n\nThen:\n\n1. Build the binary:\n  ```shell\n  docker run --rm -e GOOS=darwin -u \"$(id -u):$(id -g)\" -v \"${PWD}:/xk6\" \\\n  grafana/xk6 build \\\n  --with github.com/wosp-io/xk6-playwright\n  ```\n  on Windows:\n  ```shell\n  docker run --rm -e GOOS=windows -u \"$(id -u):$(id -g)\" -v \"${PWD}:/xk6\" `\n\n  grafana/xk6 build --output k6.exe `\n  --with github.com/wosp-io/xk6-playwright\n  ```\n  This will create a `k6` binary file in the current working directory. This file can be used exactly the same as the main `k6` binary, with the addition of being able to run xk6-playwright scripts.\n  \n3. For the tool to work, the browsers and OS dependencies must be installed locally. You can use the following command for this:\n  ```shell\n  go run github.com/playwright-community/playwright-go/cmd/playwright@v0.2000.1  install --with-deps\n  ```\n\n4. Run scripts that import `k6/x/playwright` with the new `k6` binary. On Linux and macOS make sure this is done by referencing the file in the current directory, e.g. `./k6 run \u003cscript\u003e`, or you can place it somewhere in your `PATH` so that it can be run from anywhere on your system.\n\n\u003c/br\u003e\n\n## Simplest Working Example\n\n```JavaScript\nimport pw from 'k6/x/playwright';\n\nexport default function () {\n  try {\n    pw.launch();\n    pw.newPage();\n    pw.goto('https://test.k6.io/my_messages.php', { waitUntil: 'networkidle' });\n    pw.waitForSelector(\"input[name='login']\", { state: 'visible' });\n  } catch (err) {\n    console.log(err);\n  } finally {\n    pw.kill();\n  }\n}\n```\n\n\u003c/br\u003e\n\n## Simplest Headful Example\n\n```JavaScript\nimport pw from 'k6/x/playwright';\n\nexport default function () {\n  try {\n    pw.launch({ headless: false });\n    pw.newPage();\n    pw.goto('https://test.k6.io/my_messages.php', { waitUntil: 'networkidle' });\n    pw.waitForSelector(\"input[name='login']\", { state: 'visible' });\n  } catch (err) {\n    console.log(err);\n  } finally {\n    pw.kill();\n  }\n}\n```\n\n## Monitor Real User Metrics\n\n```JavaScript\nimport pw from 'k6/x/playwright';\n\nexport default function () {\n  try {\n    pw.launch()\n    pw.newPage()\n    pw.goto('https://test.k6.io/my_messages.php', { waitUntil: 'networkidle' });\n    pw.waitForSelector(\"input[name='login']\", { state: 'visible' });\n    pw.type(\"input[name='login']\", \"admin\")\n    pw.sleep(500)//give a chance for the browser apis to catch up \n\n    //print out real user metrics of the google search page\n    console.log(`First Paint: ${pw.firstPaint()}ms`)\n    console.log(`First Contentful Paint: ${pw.firstContentfulPaint()}ms`)\n    console.log(`Time to Minimally Interactive: ${pw.timeToMinimallyInteractive()}ms`)\n    console.log(`First Input Delay: ${pw.firstInputDelay()}ms`)\n  } catch (err) {\n    console.log(err);\n  } finally {\n    pw.kill();\n  }\n}\n```\n\n\u003c/br\u003e\n\n## Examples\n\nMore example can be found in the `./examples` directory\n\n\u003cbr\u003e\n\n## Currently Supported Actions\n\n[Playwright API](https://playwright.dev/docs/api/class-playwright) coverage is as follows:\n\n| Action | Encompassed Playwright Function(s) | Description |\n|   :---   | :--- | :--- |\n| launch() | [`Run()`](https://pkg.go.dev/github.com/mxschmitt/playwright-go#Run) \u0026 [`Launch()`](https://pkg.go.dev/github.com/mxschmitt/playwright-go#BrowserType.Launch) | starts playwright client and launches Chromium browser|\n| connect() | [`Run()`](https://pkg.go.dev/github.com/mxschmitt/playwright-go#Run) \u0026 [`Connect()`](https://pkg.go.dev/github.com/mxschmitt/playwright-go#BrowserType.Connect) | attaches playwright client to existing browser instance|\n| newPage() | [`NewPage()`](https://pkg.go.dev/github.com/mxschmitt/playwright-go#Browser.NewPage) | opens up a new page within the browser |\n| goto() | [`Goto()`](https://pkg.go.dev/github.com/mxschmitt/playwright-go#Page.Goto) | navigates to a specified url |\n| waitForSelector() | [`WaitForSelector()`](https://pkg.go.dev/github.com/mxschmitt/playwright-go#Page.WaitForSelector) | waits for an element to be on the page based on the provided selector |\n| click() | [`Click()`](https://pkg.go.dev/github.com/mxschmitt/playwright-go#Page.Click) | clicks an element on the page based on the provided selector |\n| type() | [`Type()`](https://pkg.go.dev/github.com/mxschmitt/playwright-go#Page.Type) | types in an 'input' element on the page based on the provided selector and string to be entered |\n| pressKey() | [`PressKey()`](https://pkg.go.dev/github.com/mxschmitt/playwright-go#Page.PressKey) | simulates pressing a key, types in an 'input' element on the page based on a key to be entered |\n| sleep() | [`Sleep()`](https://pkg.go.dev/github.com/mxschmitt/playwright-go#Page.WaitForTimeout) | waits for a specified amount of time in milliseconds |\n| screenshot() | [`Screenshot()`](https://pkg.go.dev/github.com/mxschmitt/playwright-go#Page.Screenshot) | attempts to take and save a png image of the current screen |\n| focus() | [`Focus()`](https://pkg.go.dev/github.com/mxschmitt/playwright-go#Page.Focus) | focuses a spcific element based on the provided selector |\n| fill() | [`Fill()`](https://pkg.go.dev/github.com/mxschmitt/playwright-go#Page.Fill) | fills an 'input' element on the page based on the provided selector and string to be entered |\n| selectOptions() | [`SelectOption()`](https://pkg.go.dev/github.com/playwright-community/playwright-go#Page.SelectOption) | selects an 'input' element from a list or dropdown of options on the page based on the provided selector and values to be selected |\n| check() | [`Check()`](https://pkg.go.dev/github.com/mxschmitt/playwright-go#Page.Check) | checks an element on the page based on the provided selector |\n| uncheck() | [`Uncheck()`](https://pkg.go.dev/github.com/mxschmitt/playwright-go#Page.Uncheck) | unchecks an element on the page based on the provided selector |\n| dragAndDrop() | [`DragAndDrop()`](https://pkg.go.dev/github.com/mxschmitt/playwright-go#Page.DragAndDrop) | drag an item from one place to another based on two selectors |\n| evaluate() | [`Evaluate()`](https://pkg.go.dev/github.com/mxschmitt/playwright-go#Page.Evaluate) | evaluate an expresion or function and get the return value |\n| reload() | [`Reload()`](https://pkg.go.dev/github.com/mxschmitt/playwright-go#Page.Reload) | reloads the current page |\n| cookies() | [`Cookies()`](https://pkg.go.dev/github.com/mxschmitt/playwright-go#BrowserContext.Cookies) | get all the cookies available for the default browser context.|\n| firstPaint() | N/A this function is unique to xk6-playwright [`What is First Paint?`](https://developer.mozilla.org/en-US/docs/Glossary/First_paint) | captures the first paint metric of the current page milliseconds |\n| firstContentfulPaint() | N/A this function is unique to xk6-playwright [`What is First Contentful Paint?`](https://web.dev/fcp/) | captures the first contentful paint metric of the current page milliseconds |\n| timeToMinimallyInteractive() | N/A this function is unique to xk6-playwright - This is based on the first input registerd on the current page - NOTE: this is how we personally like to determine when a page is minimally interactive. | captures the time to minimally interactive metric of the current page milliseconds |\n| firstInputDelay() | N/A this function is unique to xk6-playwright [`What is First Input Delay?`](https://web.dev/fid/) | captures the first input delay metric of the current page in milliseconds |\n\nThe above 'Encompassed Playwright Function(s)' will link to the [playwright-go package documentation](https://pkg.go.dev/github.com/mxschmitt/playwright-go#section-readme) to give an in-depth overview of how these functions will behave from a low-level perspective.\n\nIf you would like a high-level perspective on how these actions work you will be better served with the [Playwright API Documentation](https://playwright.dev/docs/api/class-playwright)\n\n\u003c/br\u003e\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/your-github-user/xk6-playwright/fork\u003e)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n\u003c/br\u003e\n\n## Contributors\n\n[Nick Vuono](https://github.com/nicholasvuono) - creator and maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicholasvuono%2Fxk6-playwright","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnicholasvuono%2Fxk6-playwright","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicholasvuono%2Fxk6-playwright/lists"}