{"id":28839439,"url":"https://github.com/coldbox-modules/cbplaywright","last_synced_at":"2025-07-10T16:05:25.530Z","repository":{"id":58273200,"uuid":"530819152","full_name":"coldbox-modules/cbPlaywright","owner":"coldbox-modules","description":"A library for integrating Playwright and TestBox","archived":false,"fork":false,"pushed_at":"2025-05-28T04:38:20.000Z","size":84269,"stargazers_count":9,"open_issues_count":4,"forks_count":4,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-06-19T14:53:18.064Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"ColdFusion","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coldbox-modules.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null}},"created_at":"2022-08-30T20:26:57.000Z","updated_at":"2025-05-28T04:38:22.000Z","dependencies_parsed_at":"2023-01-21T05:01:26.891Z","dependency_job_id":"11981442-62de-420a-952a-123dac5443f4","html_url":"https://github.com/coldbox-modules/cbPlaywright","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/coldbox-modules/cbPlaywright","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coldbox-modules%2FcbPlaywright","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coldbox-modules%2FcbPlaywright/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coldbox-modules%2FcbPlaywright/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coldbox-modules%2FcbPlaywright/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coldbox-modules","download_url":"https://codeload.github.com/coldbox-modules/cbPlaywright/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coldbox-modules%2FcbPlaywright/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264604685,"owners_count":23635920,"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":[],"created_at":"2025-06-19T14:41:17.647Z","updated_at":"2025-07-10T16:05:25.513Z","avatar_url":"https://github.com/coldbox-modules.png","language":"ColdFusion","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cbPlaywright\n\n## CFML integration with TestBox and Playwright to run tests in actual browsers\n\n### Dependencies\n\nTestbox v4+\n\n\u003e ColdBox is **not** required.\n\n### Installation\n\n1. Add Java Jars to `tests/Application.cfc`\n\n```\nthis.javaSettings = {\n\tloadPaths: directoryList(\n\t\trootPath \u0026  \"modules/cbPlaywright/lib\",\n\t\ttrue,\n\t\t\"array\",\n\t\t\"*jar\"\n\t),\n\tloadColdFusionClassPath: true,\n\treloadOnChange: false\n};\n```\n\n2. Make sure you have a mapping to `cbPlaywright` as well.\n\n```\nthis.mappings[ \"/cbPlaywright\" ] = rootPath \u0026 \"/modules/cbPlaywright\";\n```\n\n\u003e Note: You can't use the mapping in the `javaSettings` since they are both in the psuedo-constructor.\n\n3. (OPTIONAL) If you have installed CommandBox or commandbox-cbplaywright in a non-standard location, set the `CBPLAYWRIGHT_DRIVER_DIR`\nenvironment variable to the correct location of the Playwright driver.\n\n### Playwright CLI\n\nTo interact with the Playwright CLI, use `commandbox-cbplaywright`:\n\n```sh\nplaywright-cli\n# or\nplaywright\n```\n\nYou can see the documentation for the [Playwright Java CLI here](https://playwright.dev/java/docs/cli).\n\n### Installing Test browsers\n\nTo use Playwright, first you must install one or more test browsers.\nRefer to the Playwright docs on [Browsers](https://playwright.dev/java/docs/browsers#installing-browsers)\nfor more information.\n\nExamples:\n\n```sh\nbox playwright install chromium\nbox playwright install firefox\nbox playwright install webkit\nbox playwright install msedge\n```\n\n### Usage\n\nTo use cbPlaywright, create a test spec that extends either `cbPlaywright.models.PlaywrightTestCase`\nor `cbPlaywright.models.ColdBoxPlaywrightTestCase`. What's the difference between these two?\n`PlaywrightTestCase` extends `testbox.system.BaseSpec` while\n`ColdBoxPlaywrightTestCase` extends `coldbox.system.testing.BaseTestCase`.\nBasically, if you need to access your ColdBox app in your Playwright test, use `ColdBoxPlaywrightTestCase`.\n\n\u003e NOTE: ColdBox is **not** required to use cbPlaywright. The only dependency is TestBox.\n\n```cfc\ncomponent extends=\"cbPlaywright.models.PlaywrightTestCase\" {\n\t// ...\n}\n```\n\nA `PlaywrightTestCase` CFC automatically creates a `variables.playwright` instance in the `beforeAll` method.\n\n\u003e If you have a `beforeAll` on your test case, make sure to call `super.beforeAll()`. Otherwise, you will\n\u003e not have access to the `variables.playwright` instance.\n\nThis `playwright` variable is an instance of the Java `Playwright` class. From this variable you can\ncreate browsers to start running your tests.\n\n```cfc\ncomponent extends=\"cbPlaywright.models.PlaywrightTestCase\" {\n\n\tfunction run() {\n\t\tdescribe( \"home page\", () =\u003e {\n\t\t\tit( \"can visit the home page\", () =\u003e {\n\t\t\t\tvar browser = variables.playwright.firefox().launch();\n\t\t\t\tvar page = browser.newPage();\n\t\t\t\tnavigate( page, \"http://\" \u0026 CGI.HTTP_HOST );\n\t\t\t\twaitForLoadState( page );\n\t\t\t\texpect( page.title() ).toBe( \"Welcome to my site!\" );\n\t\t\t} );\n\t\t} );\n\t}\n\n}\n```\n\nAll of the methods above are called on the Java objects provided by the Playwright Java SDK.\nWhen using cbPlaywright, you will often reference the [Playwright Java SDK documentation](https://playwright.dev/java/docs/intro).\n\n### Helper Functions\n\ncbPlaywright provides helper functions to make interacting with the Java SDK easier.\n\n\u003e You can find all of these helper functions inside `cbPlaywright.models.PlaywrightMixins`\n\n#### route\n\nBuilds up a URL string to the currently running server. It can take any amount of arguments and will\nintelligently combine them into a path prepended with the current `CGI.HTTP_HOST`.\n\n| Name  | Type   | Required | Default | Description                                                                                                                                                                      |\n| ----- | ------ | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| paths | string | false    | null    | This is a variadic parameter. Any number of strings can be passed as separate arguments. They will all be combined into one URL path prepended with the current `CGI.HTTP_HOST`. |\n\nExample:\n\n```cfc\nroute( \"/users\", userId, \"edit\" );\n// http://127.0.0.1:51423/users/42/edit\n```\n\n#### regex\n\nConverts a string an optional flags into a Java Regex Pattern\n\n| Name  | Type   | Required | Default | Description                                                                                                                                                                      |\n| ----- | ------ | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| pattern | string | true    | | The regex pattern to search for.  Don't include any surrounding slashes `/` or flags. |\n| flags | String OR [String] | false | `null` | Any flags for the regex.  Supported flags are `i` (case insensitive), `m` (multiline), `s` (dotall), and `u` (unicode). |\n\nExample:\n\n```cfc\nvar browser = launchBrowser( variables.playwright.webkit() );\nvar page = browser.newPage();\nnavigate( page, \"https://coldbox.org\" );\nclick( getByRole( coldbox, \"link\", { \"name\": regex( \"CFCASTS\", \"i\" ), \"exact\": true } ) );\n```\n\n#### navigate\n\nNavigates a [Page](https://playwright.dev/java/docs/api/class-page) to a URL.\n\n| Name | Type | Required | Default | Description |\n| ----- | ------ | -------- | ------- | |\n| page | com.microsoft.playwright.Page | true | | A Playwright page to navigate. |\n| path | string | true | | The path to navigate to. |\n\nExample:\n\n```cfc\nvar browser = launchBrowser( variables.playwright.webkit() );\nvar page = browser.newPage();\nnavigate( page, route( \"/\" ) );\nexpect( page.title() ).toBe( \"My Site\" );\n```\n\n#### locateElement\n\nFinds an [ElementHandle](https://playwright.dev/java/docs/api/class-elementhandle) in the\ngiven [Page](https://playwright.dev/java/docs/api/class-page) by selector.\n\n| Name | Type | Required | Default | Description |\n| ----- | ------ | -------- | ------- | |\n| page | com.microsoft.playwright.Page | true | | A Playwright page in which to find the selector. |\n| selector | string | true | | A selector to use when resolving DOM element. |\n\nExample:\n\n```cfc\nvar browser = launchBrowser( variables.playwright.chromium() );\nvar page = browser.newPage();\nnavigate( page, \"https://google.com\" );\nwaitForLoadState( page );\nexpect( page.title() ).toBe( \"Google\" );\nvar searchBox = locateElement( page, '[aria-label=\"Search\"]' );\n```\n\n#### getByRole\nhttps://playwright.dev/docs/locators#locate-by-role\nhttps://playwright.dev/java/docs/api/class-page#page-get-by-role\n\nAllows locating elements by their ARIA role, ARIA attributes and accessible name.\n\nConsider the following DOM structure.\n\n```html\n\u003ch3\u003eSign up\u003c/h3\u003e\n\u003clabel\u003e\n  \u003cinput type=\"checkbox\" /\u003e Subscribe\n\u003c/label\u003e\n\u003cbr/\u003e\n\u003cbutton\u003eSubmit\u003c/button\u003e\n```\n\nYou can locate each element by it's implicit role:\n```cfc\nexpect( getByRole( page, \"heading\", { name: \"Sign up\" } ).isVisible() ).toBeTrue();\ncheck( getByRole( page, \"checkbox\", { name: \"Subscribe\" } ) );\nclick( getByRole( page, \"button\", { name: regex( \"submit\", \"i\" ) } ) );\n```\n\n| Name | Type | Required | Default | Description |\n| ----- | ------ | -------- | ------- | |\n| page | com.microsoft.playwright.Page | true | | A Playwright page in which to find the selector. |\n| role | string | true | | One of the valid Aria roles |\n| options | struct | false | `{}` | Additional options to further refine the selection. Valid options are: `checked, disabled, exact, expanded, includeHidden, level, name, pressed, selected` |\n\nValid Aria roles include:\n```\nrole enum AriaRole { ALERT, ALERTDIALOG, APPLICATION, ARTICLE, BANNER, BLOCKQUOTE, BUTTON, CAPTION, CELL, CHECKBOX, CODE, COLUMNHEADER, COMBOBOX, COMPLEMENTARY, CONTENTINFO, DEFINITION, DELETION, DIALOG, DIRECTORY, DOCUMENT, EMPHASIS, FEED, FIGURE, FORM, GENERIC, GRID, GRIDCELL, GROUP, HEADING, IMG, INSERTION, LINK, LIST, LISTBOX, LISTITEM, LOG, MAIN, MARQUEE, MATH, METER, MENU, MENUBAR, MENUITEM, MENUITEMCHECKBOX, MENUITEMRADIO, NAVIGATION, NONE, NOTE, OPTION, PARAGRAPH, PRESENTATION, PROGRESSBAR, RADIO, RADIOGROUP, REGION, ROW, ROWGROUP, ROWHEADER, SCROLLBAR, SEARCH, SEARCHBOX, SEPARATOR, SLIDER, SPINBUTTON, STATUS, STRONG, SUBSCRIPT, SUPERSCRIPT, SWITCH, TAB, TABLE, TABLIST, TABPANEL, TERM, TEXTBOX, TIME, TIMER, TOOLBAR, TOOLTIP, TREE, TREEGRID, TREEITEM }\n```\n\nExample:\n\n```cfc\nvar browser = launchBrowser( variables.playwright.chromium() );\nvar page = browser.newPage();\nnavigate( page, \"https://coldbox.org\" );\nwaitForLoadState( page );\nvar cfcastsLink = getByRole( page, \"link\", { \"name\": regex( \"CFCASTS\", \"i\" ), \"exact\": true } );\nclick( cfcastsLink );\n```\n\n#### getByLabel\nhttps://playwright.dev/docs/locators#locate-by-label\nhttps://playwright.dev/java/docs/api/class-page#page-get-by-label\n\nAllows locating input elements by the text of the associated \u003clabel\u003e or aria-labelledby element, or by the aria-label attribute.\n\nFor example, this method will find inputs by label \"Username\" and \"Password\" in the following DOM:\n\n```html\n\u003cinput aria-label=\"Username\"\u003e\n\u003clabel for=\"password-input\"\u003ePassword:\u003c/label\u003e\n\u003cinput id=\"password-input\"\u003e\n```\n\n```cfc\nfill( getByLabel( page, \"Username\" ), \"john\" );\nfill( getByLabel( page, \"Password\" ), \"secret\" );\n```\n\n| Name | Type | Required | Default | Description |\n| ----- | ------ | -------- | ------- | |\n| page | com.microsoft.playwright.Page | true | | A Playwright page in which to find the selector. |\n| text | string | true | | Text to locate the element. |\n| exact | boolean | false | `false` | Whether to find an exact match: case-sensitive and whole-string. Default to false. Ignored when locating by a regular expression. Note that exact match still trims whitespace. |\n\nExample:\n\n```cfc\nvar browser = launchBrowser( variables.playwright.chromium() );\nvar page = browser.newPage();\nnavigate( page, \"https://google.com\" );\nwaitForLoadState( page );\nvar searchField = getByLabel( page, \"Search\" );\nfill( searchField, \"coldbox\" );\n```\n\n#### check\n\nChecks an [Locator](https://playwright.dev/java/docs/api/class-locator).\n\n| Name | Type | Required | Default | Description |\n| ----- | ------ | -------- | ------- | |\n| locator | com.microsoft.playwright.Locator | true | | A Playwright Locator. You usually retrieve this from a `locateElement` or `getBy*` call. |\n| options | struct | false | `{}` | Options for the check event. Valid options are: `force` (boolean), `noWaitAfter` (boolean), `position` ( { x: double, y: double } ), `timeout` (double), and `trial` (boolean) |\n\nExample:\n\n```cfc\nvar browser = launchBrowser( variables.playwright.chromium() );\nvar page = browser.newPage();\nnavigate( page, \"https://cfcasts.com/login\" );\nwaitForLoadState( page );\ncheck( getByLabel( \"Remember Me\" ) );\n```\n\n#### click\n\nClicks an [ElementHandle](https://playwright.dev/java/docs/api/class-elementhandle).\n\n| Name | Type | Required | Default | Description |\n| ----- | ------ | -------- | ------- | |\n| element | com.microsoft.playwright.ElementHandle | true | | A Playwright ElementHandle. You usually retrieve this from a `locateElement` call. |\n\nExample:\n\n```cfc\nvar browser = launchBrowser( variables.playwright.chromium() );\nvar page = browser.newPage();\nnavigate( page, \"https://google.com\" );\nwaitForLoadState( page );\nexpect( page.title() ).toBe( \"Google\" );\nvar searchBox = locateElement( page, '[aria-label=\"Search\"]' );\nclick( searchBox );\n```\n\n#### fill\n\nFills an [ElementHandle](https://playwright.dev/java/docs/api/class-elementhandle) with the given value.\n\n| Name | Type | Required | Default | Description |\n| ----- | ------ | -------- | ------- | |\n| element | com.microsoft.playwright.ElementHandle | true | | A Playwright ElementHandle. You usually retrieve this from a `locateElement` call. |\n| value | string | true | | The value to fill. |\n\nExample:\n\n```cfc\nvar browser = launchBrowser( variables.playwright.chromium() );\nvar page = browser.newPage();\nnavigate( page, \"https://google.com\" );\nwaitForLoadState( page );\nexpect( page.title() ).toBe( \"Google\" );\nvar searchBox = locateElement( page, '[aria-label=\"Search\"]' );\nclick( searchBox );\nfill( searchBox, \"playwright\" );\n```\n\n#### press\n\nPresses a given key on an [ElementHandle](https://playwright.dev/java/docs/api/class-elementhandle).\n\n| Name | Type | Required | Default | Description |\n| ----- | ------ | -------- | ------- | |\n| element | com.microsoft.playwright.ElementHandle | true | | A Playwright ElementHandle. You usually retrieve this from a `locateElement` call. |\n| key | string | true | | The key to press. |\n\nExample:\n\n```cfc\nvar browser = launchBrowser( variables.playwright.chromium() );\nvar page = browser.newPage();\nnavigate( page, \"https://google.com\" );\nwaitForLoadState( page );\nexpect( page.title() ).toBe( \"Google\" );\nvar searchBox = locateElement( page, '[aria-label=\"Search\"]' );\nclick( searchBox );\nfill( searchBox, \"playwright\" );\npress( searchBox, \"Enter\" );\n```\n\n#### launchBrowser\n\nLaunches a Browser from a Playwright [BrowserType](https://playwright.dev/java/docs/api/class-browsertype) instance. Returns a Playwright [Browser](https://playwright.dev/java/docs/api/class-browser) instance.\n\n| Name        | Type                                 | Required | Default | Description                                                                          |\n| ----------- | ------------------------------------ | -------- | ------- | ------------------------------------------------------------------------------------ |\n| browserType | com.microsoft.playwright.BrowserType | true     |         | A Playwright BrowserType to launch.                                                  |\n| headless    | boolean                              | false    | `true`  | Flag to launch the browser in headless mode. Only interactive browser can be paused. |\n\nExample:\n\n```cfc\nvar browser = launchBrowser( variables.playwright.firefox() );\n```\n\n#### launchInteractiveBrowser\n\nLaunches an interactive Browser from a Playwright [BrowserType](https://playwright.dev/java/docs/api/class-browsertype) instance. An interactive Browser is one that is not running in headless mode. Returns a Playwright [Browser](https://playwright.dev/java/docs/api/class-browser) instance.\n\n| Name        | Type                                 | Required | Default | Description                         |\n| ----------- | ------------------------------------ | -------- | ------- | ----------------------------------- |\n| browserType | com.microsoft.playwright.BrowserType | true     |         | A Playwright BrowserType to launch. |\n\nExample:\n\n```cfc\nvar browser = launchInteractiveBrowser( variables.playwright.msedge() );\n```\n\n#### screenshotPage\n\nCaptures a screenshot from a [Page](https://playwright.dev/java/docs/api/class-page) instance.\nReturns the same Page instance.\n\n| Name    | Type                          | Required | Default | Description                                     |\n| ------- | ----------------------------- | -------- | ------- | ----------------------------------------------- |\n| page    | com.microsoft.playwright.Page | true     |         | A Playwright Page to capture as a screenshot.   |\n| path    | string                        | true     |         | The path to save the screenshot.                |\n| options | struct                        | false    | `{}`    | Additional options to customize the screenshot. |\n\nAdditional options are as follows:\n\n```cfc\n{\n\t// set a region to capture for the screenshot\n\t\"clip\": {\n\t\t\"x\": 100,\n\t\t\"y\": 100,\n\t\t\"width\": 100,\n\t\t\"height\": 100\n\t}\n\t// captures the full scrollable page instead of the currently visible viewport\n\t\"fullPage\": true,\n\t// Hides default white background and allows capturing screenshots with transparency. Defaults to false.\n\t\"omitBackground\": true,\n\t// The quality of the image, between 0-100. Not applicable to `png` images.\n\t\"quality\": 75,\n\t// Maximum time in milliseconds to capture the screenshot. Defaults to 30 seconds. Pass 0 to disable.\n\t\"timeout\": 5 * 1000,\n\t// The screenshot type, \"png\" or \"jpeg\". Defaults to \"png\".\n\t\"type\": \"jpeg\"\n}\n```\n\nExample:\n\n```cfc\nvar browser = launchBrowser( variables.playwright.webkit() );\nvar page = browser.newPage();\npage.navigate( route( \"/\" ) );\nscreenshotPage( page, \"/tests/results/homePage.png\", { \"type\": \"jpeg\" } );\n```\n\n#### newRecordedContextForBrowser\n\nCreates a new recorded [BrowserContext](https://playwright.dev/java/docs/api/class-browsercontext)\nfrom a Playwright [Browser](https://playwright.dev/java/docs/api/class-browser).\nA recorded context saves one or more videos of all the actions taken by the context. The context is created\nand provided to you via a callback. If any additional pages or popups are created, the context will save a\nvideo for each of them.\n\nReturns the passed in Browser instance.\n\n| Name      | Type                             | Required | Default | Description                                                                                                                              |\n| --------- | -------------------------------- | -------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------- |\n| browser   | com.microsoft.playwright.Browser | true     |         | A Playwright Browser from which to create a recorded BrowserContext.                                                                     |\n| directory | string                           | true     |         | The path to a directory to save any generated videos.                                                                                    |\n| callback  | function                         | true     |         | A callback that receives the recorded context. All actions to be recorded should be called on this context variable inside the callback. |\n| options   | struct                           | false    | `{}`    | Additional options to customize the recordings.                                                                                          |\n\nAdditional options are as follows:\n\n```cfc\n{\n\t// Dimensions of the recorded videos. If not specified the size will be equal to viewport\n\t// scaled down to fit into 800x800. If viewport is not configured explicitly the video size\n\t// defaults to 800x450. Actual picture of each page will be scaled down if necessary\n\t// to fit the specified size.\n\t\"recordVideoSize\": {\n\t\t\"height\": 1280,\n\t\t\"width\": 720\n\t}\n}\n```\n\nExample:\n\n```cfc\nvar browser = launchBrowser( variables.playwright.chromium() );\nnewRecordedContextForBrowser( browser, \"/tests/results/videos\", function( context ) {\n\tvar page = context.newPage();\n\tpage.navigate( route( \"/\" ) );\n\tscreenshotPage( page, \"/tests/results/homePage.png\" );\n\texpect( page.title() ).toBe( \"Welcome to Coldbox!\" );\n\tpage.locator( \"text=About\" ).click();\n\tpage.locator( \"text=Official Site\" ).click();\n\texpect( page.url() ).toBe( \"https://coldbox.org/\" );\n\tpage.waitForLoadState();\n\tscreenshotPage( page, \"/tests/results/coldboxPage.png\" );\n} );\n```\n\n#### traceContext\n\nSets up a Playwright [BrowserContext](https://playwright.dev/java/docs/api/class-browsercontext) to allow tracing. Tracing creates a zip archive that can be replayed either locally or on https://trace.playwright.dev/.\n\n| Name         | Type                                    | Required | Default | Description                                                                                                                                        |\n| ------------ | --------------------------------------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |\n| context      | com.microsoft.playwright.BrowserContext | true     |         | A Playwright BrowserContext to capture a trace.                                                                                                    |\n| path         | string                                  | true     |         | The path to save the trace.                                                                                                                        |\n| callback     | function                                | true     |         | A callback to run additional Playwright methods. Any methods called on the passed in `context` inside this callback will be recorded in the trace. |\n| startOptions | struct                                  | false    | `{}`    | Additional start options to customize the trace.                                                                                                   |\n\nAdditional startOptions are as follows:\n\n```cfc\n{\n\t// Whether to capture screenshots during tracing. Screenshots are used to build a timeline preview.\n\t// Defaults to `true`.\n\t\"screenshots\": false\n\t// If this option is true tracing will capture DOM snapshot on every action record network activity.\n\t// Defaults to `true`.\n\t\"snapshots\": false,\n\t// Whether to include source files for trace actions.\n\t// List of the directories with source code for the application must be provided via\n\t// `PLAYWRIGHT_JAVA_SRC` environment variable.\n\t// (The paths should be separated by ';' on Windows and by ':' on other platforms.)\n\t// Defaults to `false`.\n\t\"sources\": true,\n\t// Trace name to be shown in the Trace Viewer.\n\t\"title\": \"My Home Page\"\n}\n```\n\nExample:\n\n```cfc\nvar browser = launchBrowser( variables.playwright.firefox() );\nvar context = browser.newContext();\ntraceContext( context, \"/tests/results/trace.zip\", function() {\n\tvar page = browser.newPage();\n\tpage.navigate( route( \"/\" ) );\n\tscreenshotPage( page, \"/tests/results/homePage.png\" );\n} );\n```\n\n#### waitForPopup\n\nWaits for a popup to load after running the actions inside the callback,\nthen returns the new popup [Page](https://playwright.dev/java/docs/api/class-page).\nThis action will fail if the navigation does not happen after 30 seconds.\n\n\u003e Popups include any new pages opened by browser interactions (like `\u003ca href=\"www.google.com\" target=\"_blank\"\u003eGoogle\u003c/a\u003e`)\n\n| Name     | Type                          | Required | Default | Description                                                                         |\n| -------- | ----------------------------- | -------- | ------- | ----------------------------------------------------------------------------------- |\n| page     | com.microsoft.playwright.Page | true     |         | A Playwright Page that will launch a popup.                                         |\n| callback | function                      | true     |         | A callback containing Playwright actions that will end with launching a popup page. |\n\nExample:\n\n```cfc\nvar browser = launchBrowser( variables.playwright.chromium() );\nvar page = browser.newPage();\npage.navigate( \"https://coldbox.org/\" );\npage.waitForLoadState();\nscreenshotPage( page, \"/tests/results/coldboxPage.png\" );\nvar popup = waitForPopup( page, function() {\n\tpage.locator( 'a:has-text(\"CFCASTS\")' ).click();\n} );\nexpect( popup.url() ).toBe( \"https://cfcasts.com/\" );\n```\n\n#### waitForNavigation\n\nWaits for a navigation event to finish after running the actions inside the callback.\nThis action will fail if the navigation does not happen after 30 seconds.\n\n| Name     | Type                          | Required | Default | Description                                                                                 |\n| -------- | ----------------------------- | -------- | ------- | ------------------------------------------------------------------------------------------- |\n| page     | com.microsoft.playwright.Page | true     |         | A Playwright Page that will perform a navigation action.                                    |\n| callback | function                      | true     |         | A callback containing Playwright actions that will end with performing a navigation action. |\n\nExample:\n\n```cfc\nvar browser = launchBrowser( variables.playwright.chromium() );\nvar page = browser.newPage();\npage.navigate( \"https://cfcasts.com/\" );\nexpect( page.url() ).toBe( \"https://cfcasts.com/\" );\nvar searchField = page.locator( '[placeholder=\"Search (Ctrl + K)\"]' ).first();\nsearchField.click();\nsearchField.fill( \"commandbox\" );\nwaitForNavigation( page, function() {\n\tsearchField.press( \"Enter\" );\n} )\nexpect( page.url() ).toBe( \"https://cfcasts.com/browse?q=commandbox\" );\nscreenshotPage( page, \"/tests/results/cfcastsPage.png\" );\n```\n\n#### waitForLoadState\n\nWaits for the LOAD event from the DOM before continuing.\nThis action will fail if the LOAD event is not fired before 30 seconds.\n\n| Name | Type                          | Required | Default | Description                    |\n| ---- | ----------------------------- | -------- | ------- | ------------------------------ |\n| page | com.microsoft.playwright.Page | true     |         | A Playwright Page to wait for. |\n\nExample:\n\n```cfc\nvar browser = launchBrowser( variables.playwright.chromium() );\nvar page = browser.newPage();\nnavigate( page, \"https://google.com\" );\nwaitForLoadState( page );\nexpect( page.title() ).toBe( \"Google\" );\n```\n\n#### waitForUrl\n\nWaits for the browser's url to be the given string.\nThis action will fail if the url does not become the given string before 30 seconds.\n\n| Name | Type                          | Required | Default | Description                    |\n| ---- | ----------------------------- | -------- | ------- | ------------------------------ |\n| page | com.microsoft.playwright.Page | true     |         | A Playwright Page to wait for. |\n\nExample:\n\n```cfc\nvar browser = launchBrowser( variables.playwright.chromium() );\nvar page = context.newPage();\nnavigate( page, \"https://google.com\" );\nwaitForLoadState( page );\nexpect( page.title() ).toBe( \"Google\" );\nvar searchBox = locateElement( page, '[aria-label=\"Search\"]' );\nclick( searchBox );\nfill( searchBox, \"playwright\" );\npress( searchBox, \"Enter\" );\nexpect( page.url() ).toInclude( \"https://www.google.com/search?q=playwright\" );\nclick(\n\tlocateElement(\n\t\tpage,\n\t\t\"text=Playwright: Fast and reliable end-to-end testing for modern ...\"\n\t)\n);\nwaitForUrl( page, \"https://playwright.dev/\" );\n```\n\n### Running a Codegen Session\n\nCodgen is a way to interact with a browser and record the actions to copy to your test.\nYou can do this from the Playwright Java CLI.\n\n```sh\njava -cp \"modules/cbPlaywright/lib/*\" -Dplaywright.cli.dir=\"lib/driver/linux/\" com.microsoft.playwright.CLI codegen {YOUR_SITE_HERE}\n```\n\n\u003e Make sure to copy the code out before closing any windows. You will need to massage some\n\u003e of the generated Java code to fit CFML, specifically anything with arrow functions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoldbox-modules%2Fcbplaywright","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoldbox-modules%2Fcbplaywright","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoldbox-modules%2Fcbplaywright/lists"}