{"id":34777637,"url":"https://github.com/adamdriscoll/psplaywright","last_synced_at":"2026-05-28T07:31:13.642Z","repository":{"id":322082761,"uuid":"1088146191","full_name":"adamdriscoll/psplaywright","owner":"adamdriscoll","description":"Playwright browser automation for PowerShell.","archived":false,"fork":false,"pushed_at":"2025-11-05T23:01:02.000Z","size":147,"stargazers_count":13,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-01-24T01:40:08.669Z","etag":null,"topics":["browser-automation","powershell"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adamdriscoll.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"adamdriscoll"}},"created_at":"2025-11-02T12:08:28.000Z","updated_at":"2026-01-22T01:10:29.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/adamdriscoll/psplaywright","commit_stats":null,"previous_names":["adamdriscoll/psplaywright"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/adamdriscoll/psplaywright","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamdriscoll%2Fpsplaywright","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamdriscoll%2Fpsplaywright/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamdriscoll%2Fpsplaywright/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamdriscoll%2Fpsplaywright/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adamdriscoll","download_url":"https://codeload.github.com/adamdriscoll/psplaywright/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamdriscoll%2Fpsplaywright/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33599465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","powershell"],"created_at":"2025-12-25T08:37:31.111Z","updated_at":"2026-05-28T07:31:13.630Z","avatar_url":"https://github.com/adamdriscoll.png","language":"PowerShell","funding_links":["https://github.com/sponsors/adamdriscoll"],"categories":[],"sub_categories":[],"readme":"# PSPlaywright\n\n\u003e **Work in Progress \u0026 Experimentation**\n\u003e\n\u003e This project is currently a work in progress and serves as an experiment in using GitHub Copilot to generate PowerShell modules for browser automation. The code, structure, and documentation are actively evolving as new features and improvements are explored. Feedback and contributions are welcome!\n\nPSPlaywright is a PowerShell module that provides a set of commands for browser automation and web testing using [Microsoft Playwright](https://playwright.dev/). It enables users to control browsers, interact with web pages, and automate UI testing scenarios directly from PowerShell scripts.\n\n## About Microsoft Playwright\n\nMicrosoft Playwright is a Node.js library for browser automation. It supports Chromium, Firefox, and WebKit, allowing for cross-browser web automation and testing. Playwright enables reliable end-to-end testing for modern web applications, supporting features like headless execution, network interception, and advanced page interactions.\n\n## Commands\n\n### Browser Commands\n\n- [`Start-PlaywrightBrowser`](PSPlaywright/docs/PSPlaywright/Start-PlaywrightBrowser.md) - Start a new browser instance\n- [`Stop-PlaywrightBrowser`](PSPlaywright/docs/PSPlaywright/Stop-PlaywrightBrowser.md) - Stop the browser instance\n- [`Enter-PlaywrightBrowser`](PSPlaywright/docs/PSPlaywright/Enter-PlaywrightBrowser.md) - Enter a browser context\n- [`Exit-PlaywrightBrowser`](PSPlaywright/docs/PSPlaywright/Exit-PlaywrightBrowser.md) - Exit the browser context\n- [`Open-PlaywrightPage`](PSPlaywright/docs/PSPlaywright/Open-PlaywrightPage.md) - Open a new page in the browser\n\n### Page Commands\n\nThe following Page cmdlets are available:\n\n- [`Add-PlaywrightPageInitScript`](PSPlaywright/docs/PSPlaywright/Add-PlaywrightPageInitScript.md) - Add an initialization script to the page\n- [`Add-PlaywrightPageLocatorHandler`](PSPlaywright/docs/PSPlaywright/Add-PlaywrightPageLocatorHandler.md) - Add a locator handler to the page\n- [`Set-PlaywrightPageToFront`](PSPlaywright/docs/PSPlaywright/Set-PlaywrightPageToFront.md) - Bring the page to the front\n- [`Close-PlaywrightPage`](PSPlaywright/docs/PSPlaywright/Close-PlaywrightPage.md) - Close the current page\n- [`Get-PlaywrightPageContent`](PSPlaywright/docs/PSPlaywright/Get-PlaywrightPageContent.md) - Get the content of the page\n- [`Set-PlaywrightPageDragAndDrop`](PSPlaywright/docs/PSPlaywright/Set-PlaywrightPageDragAndDrop.md) - Perform drag and drop on the page\n- [`Set-PlaywrightPageMedia`](PSPlaywright/docs/PSPlaywright/Set-PlaywrightPageMedia.md) - Emulate media features on the page\n- [`Enter-PlaywrightPage`](PSPlaywright/docs/PSPlaywright/Enter-PlaywrightPage.md) - Enter the page context\n- [`Get-PlaywrightPageJavascriptHandle`](PSPlaywright/docs/PSPlaywright/Get-PlaywrightPageJavascriptHandle.md) - Evaluate JavaScript and get a handle\n- [`Exit-PlaywrightPage`](PSPlaywright/docs/PSPlaywright/Exit-PlaywrightPage.md) - Exit the page context\n- [`Find-PlaywrightPageElement`](PSPlaywright/docs/PSPlaywright/Find-PlaywrightPageElement.md) - Find an element on the page\n- [`Open-PlaywrightPageUrl`](PSPlaywright/docs/PSPlaywright/Open-PlaywrightPageUrl.md) - Navigate to a URL\n- [`Invoke-PlaywrightPageJavascript`](PSPlaywright/docs/PSPlaywright/Invoke-PlaywrightPageJavascript.md) - Invoke JavaScript on the page\n- [`Invoke-PlaywrightPageKeyboard`](PSPlaywright/docs/PSPlaywright/Invoke-PlaywrightPageKeyboard.md) - Send keyboard input to the page\n- [`Invoke-PlaywrightPageMouse`](PSPlaywright/docs/PSPlaywright/Invoke-PlaywrightPageMouse.md) - Send mouse input to the page\n- [`Get-PlaywrightPageOpener`](PSPlaywright/docs/PSPlaywright/Get-PlaywrightPageOpener.md) - Get the opener of the page\n- [`Invoke-PlaywrightPageNavigation`](PSPlaywright/docs/PSPlaywright/Invoke-PlaywrightPageNavigation.md) - Handle page navigation\n- [`Suspend-PlaywrightPage`](PSPlaywright/docs/PSPlaywright/Suspend-PlaywrightPage.md) - Pause the page\n- [`Get-PlaywrightPagePdf`](PSPlaywright/docs/PSPlaywright/Get-PlaywrightPagePdf.md) - Generate a PDF of the page\n- [`Reset-PlaywrightPage`](PSPlaywright/docs/PSPlaywright/Reset-PlaywrightPage.md) - Reload the current page\n- [`Remove-PlaywrightPageLocatorHandler`](PSPlaywright/docs/PSPlaywright/Remove-PlaywrightPageLocatorHandler.md) - Remove a locator handler from the page\n- [`Invoke-PlaywrightPageGarageCollection`](PSPlaywright/docs/PSPlaywright/Invoke-PlaywrightPageGarageCollection.md) - Request garbage collection on the page\n- [`Get-PlaywrightPageScreenshot`](PSPlaywright/docs/PSPlaywright/Get-PlaywrightPageScreenshot.md) - Take a screenshot of the page\n- [`Set-PlaywrightPageContent`](PSPlaywright/docs/PSPlaywright/Set-PlaywrightPageContent.md) - Set the HTML content of the page\n- [`Set-PlaywrightPageViewportSize`](PSPlaywright/docs/PSPlaywright/Set-PlaywrightPageViewportSize.md) - Set the viewport size of the page\n- [`Get-PlaywrightPageTitle`](PSPlaywright/docs/PSPlaywright/Get-PlaywrightPageTitle.md) - Get the title of the page\n- [`Wait-PlaywrightPageEvent`](PSPlaywright/docs/PSPlaywright/Wait-PlaywrightPageEvent.md) - Wait for a page event\n\n### Locator Commands\n\n- [`Assert-PlaywrightLocator`](PSPlaywright/docs/PSPlaywright/Assert-PlaywrightLocator.md) - Assert conditions on a locator\n- [`Invoke-PlaywrightLocatorAdvanced`](PSPlaywright/docs/PSPlaywright/Invoke-PlaywrightLocatorAdvanced.md) - Perform advanced actions on a locator\n- [`Invoke-PlaywrightLocatorClick`](PSPlaywright/docs/PSPlaywright/Invoke-PlaywrightLocatorClick.md) - Click an element\n- [`Set-PlaywrightLocatorInput`](PSPlaywright/docs/PSPlaywright/Set-PlaywrightLocatorInput.md) - Set input value for an element\n- [`Set-PlaywrightLocatorSelect`](PSPlaywright/docs/PSPlaywright/Set-PlaywrightLocatorSelect.md) - Select an option in a dropdown\n\n\n\n## Prerequisites\n\n**Node.js must be installed** for PSPlaywright to work. You can download Node.js from [nodejs.org](https://nodejs.org/). The module uses Playwright, which requires Node.js to run browser automation.\n\n## Installation\n\nYou can install the PSPlaywright module from the PowerShell Gallery:\n\n```powershell\nInstall-Module -Name 'PSPlaywright'\n```\n\nAfter importing the module, you must install the Playwright browsers required for automation:\n\n```powershell\nInstall-Playwright\n```\n\nThis will download and install Chromium, Firefox, and WebKit browsers for Playwright automation.\n\n## Examples\n\n### Getting Started\n\n#### Basic Browser Setup\n\nStart a browser session and navigate to a webpage:\n\n```powershell\n# Start Playwright and launch a Chromium browser in headless mode\nStart-Playwright\nStart-PlaywrightBrowser -BrowserType Chromium -Headless -Enter\n\n# Open a new page and navigate to a URL\nOpen-PlaywrightPage -Url \"https://playwright.dev/\"\n\n# Get the page title\n$title = Get-PlaywrightPageTitle\nWrite-Host \"Page title: $title\"\n\n# Clean up\nExit-PlaywrightBrowser\nStop-Playwright\n```\n\n#### Interactive Browser Session\n\nLaunch a visible browser for debugging and manual interaction:\n\n```powershell\n# Start browser with visible window (non-headless)\nStart-Playwright\nStart-PlaywrightBrowser -BrowserType Chromium -Enter\n\n# Open a page and pause for manual inspection\nOpen-PlaywrightPage -Url \"https://example.com\"\nSuspend-PlaywrightPage  # Opens Playwright Inspector for debugging\n\n# Continue automation after inspection\nExit-PlaywrightBrowser\nStop-Playwright\n```\n\n### Web Navigation \u0026 Content\n\n#### Navigate and Interact with Pages\n\n```powershell\nStart-Playwright\nStart-PlaywrightBrowser -BrowserType Chromium -Headless -Enter\n\n# Open a page\nOpen-PlaywrightPage -Url \"https://www.bing.com\"\n\n# Get page content\n$content = Get-PlaywrightPageContent\nWrite-Host \"Page HTML length: $($content.Length) characters\"\n\n# Take a screenshot\nGet-PlaywrightPageScreenshot -Path \".\\bing-homepage.png\" -FullPage\n\n# Navigate to another page\nOpen-PlaywrightPageUrl -Url \"https://github.com\"\n\n# Go back\nInvoke-PlaywrightPageNavigation -Action GoBack\n\n# Reload the page\nReset-PlaywrightPage\n\nExit-PlaywrightBrowser\nStop-Playwright\n```\n\n#### Set Custom Content\n\n```powershell\nStart-Playwright\nStart-PlaywrightBrowser -BrowserType Chromium -Enter\n\nOpen-PlaywrightPage -Url \"about:blank\"\n\n# Set custom HTML content\n$html = @\"\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\u003ctitle\u003eTest Page\u003c/title\u003e\u003c/head\u003e\n\u003cbody\u003e\n    \u003ch1\u003eHello from PowerShell!\u003c/h1\u003e\n    \u003cbutton id=\"myButton\"\u003eClick Me\u003c/button\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n\"@\n\nSet-PlaywrightPageContent -Html $html\n\n# Take a screenshot of custom content\nGet-PlaywrightPageScreenshot -Path \".\\custom-page.png\"\n\nExit-PlaywrightBrowser\nStop-Playwright\n```\n\n### Finding \u0026 Interacting with Elements\n\n#### Find Elements Using Different Selectors\n\n```powershell\nStart-Playwright\nStart-PlaywrightBrowser -BrowserType Chromium -Enter\nOpen-PlaywrightPage -Url \"https://github.com/login\"\n\n# Find by role (accessibility)\n$loginButton = Find-PlaywrightPageElement -Role \"button\" -Name \"Sign in\"\n\n# Find by label (form fields)\n$usernameField = Find-PlaywrightPageElement -Label \"Username or email address\"\n\n# Find by placeholder text\n$searchBox = Find-PlaywrightPageElement -Placeholder \"Search GitHub\"\n\n# Find by text content\n$linkElement = Find-PlaywrightPageElement -Text \"Create an account\"\n\n# Find by alt text (images)\n$logo = Find-PlaywrightPageElement -AltText \"GitHub\"\n\nExit-PlaywrightBrowser\nStop-Playwright\n```\n\n#### Click Elements\n\n```powershell\nStart-Playwright\nStart-PlaywrightBrowser -BrowserType Chromium -Enter\nOpen-PlaywrightPage -Url \"https://example.com\"\n\n# Find and click a button\n$button = Find-PlaywrightPageElement -Role \"button\" -Name \"Submit\"\nInvoke-PlaywrightLocatorClick -Locator $button\n\n# Click with options (double-click, right-click, etc.)\n$element = Find-PlaywrightPageElement -Role \"link\" -Name \"More info\"\nInvoke-PlaywrightLocatorClick -Locator $element -ClickCount 2  # Double-click\n\nExit-PlaywrightBrowser\nStop-Playwright\n```\n\n### Form Automation\n\n#### Fill Out and Submit a Form\n\n```powershell\nStart-Playwright\nStart-PlaywrightBrowser -BrowserType Chromium -Enter\nOpen-PlaywrightPage -Url \"https://example.com/contact\"\n\n# Fill text inputs\n$nameField = Find-PlaywrightPageElement -Label \"Name\"\nSet-PlaywrightLocatorInput -Locator $nameField -Value \"John Doe\"\n\n$emailField = Find-PlaywrightPageElement -Label \"Email\"\nSet-PlaywrightLocatorInput -Locator $emailField -Value \"john@example.com\"\n\n$messageField = Find-PlaywrightPageElement -Label \"Message\"\nSet-PlaywrightLocatorInput -Locator $messageField -Value \"This is a test message from PSPlaywright!\"\n\n# Select from dropdown\n$countryDropdown = Find-PlaywrightPageElement -Label \"Country\"\nSet-PlaywrightLocatorSelect -Locator $countryDropdown -Value \"USA\"\n\n# Submit the form\n$submitButton = Find-PlaywrightPageElement -Role \"button\" -Name \"Submit\"\nInvoke-PlaywrightLocatorClick -Locator $submitButton\n\n# Wait for navigation or success message\nStart-Sleep -Seconds 2\n\nExit-PlaywrightBrowser\nStop-Playwright\n```\n\n### Assertions \u0026 Testing\n\n#### Verify Element States\n\n```powershell\nStart-Playwright\nStart-PlaywrightBrowser -BrowserType Chromium -Enter\nOpen-PlaywrightPage -Url \"https://example.com\"\n\n# Assert element is visible\n$header = Find-PlaywrightPageElement -Role \"heading\" -Name \"Example Domain\"\nAssert-PlaywrightLocator -Locator $header -IsVisible\n\n# Assert element contains text\n$paragraph = Find-PlaywrightPageElement -Role \"paragraph\"\nAssert-PlaywrightLocator -Locator $paragraph -ContainsText \"This domain is for use\"\n\n# Assert element is enabled\n$button = Find-PlaywrightPageElement -Role \"button\"\nAssert-PlaywrightLocator -Locator $button -IsEnabled\n\n# Assert element count\n$links = Find-PlaywrightPageElement -Role \"link\"\nAssert-PlaywrightLocator -Locator $links -Count 1\n\nExit-PlaywrightBrowser\nStop-Playwright\n```\n\n### Advanced Scenarios\n\n#### Keyboard \u0026 Mouse Interactions\n\n```powershell\nStart-Playwright\nStart-PlaywrightBrowser -BrowserType Chromium -Enter\nOpen-PlaywrightPage -Url \"https://www.google.com\"\n\n# Type text using keyboard\nInvoke-PlaywrightPageKeyboard -Action Type -Text \"PowerShell automation\"\n\n# Press specific keys\nInvoke-PlaywrightPageKeyboard -Action Press -Key \"Enter\"\n\n# Use keyboard shortcuts\nInvoke-PlaywrightPageKeyboard -Action Press -Key \"Control+A\"  # Select all\n\n# Mouse interactions\nInvoke-PlaywrightPageMouse -Action Click -X 100 -Y 200\nInvoke-PlaywrightPageMouse -Action Move -X 300 -Y 400\n\nExit-PlaywrightBrowser\nStop-Playwright\n```\n\n#### Generate PDF from Webpage\n\n```powershell\nStart-Playwright\nStart-PlaywrightBrowser -BrowserType Chromium -Enter\nOpen-PlaywrightPage -Url \"https://playwright.dev/\"\n\n# Generate PDF with custom options\nGet-PlaywrightPagePdf -Path \".\\playwright-docs.pdf\" -Format \"A4\" -PrintBackground\n\nExit-PlaywrightBrowser\nStop-Playwright\n```\n\n#### Execute JavaScript\n\n```powershell\nStart-Playwright\nStart-PlaywrightBrowser -BrowserType Chromium -Enter\nOpen-PlaywrightPage -Url \"https://example.com\"\n\n# Execute JavaScript on the page\n$result = Invoke-PlaywrightPageJavascript -Script \"return document.title;\"\nWrite-Host \"Page title from JS: $result\"\n\n# Execute more complex JavaScript\n$links = Invoke-PlaywrightPageJavascript -Script @\"\n    return Array.from(document.querySelectorAll('a')).map(a =\u003e a.href);\n\"@\nWrite-Host \"Found $($links.Count) links\"\n\nExit-PlaywrightBrowser\nStop-Playwright\n```\n\n#### Viewport \u0026 Media Emulation\n\n```powershell\nStart-Playwright\nStart-PlaywrightBrowser -BrowserType Chromium -Enter\nOpen-PlaywrightPage -Url \"https://example.com\"\n\n# Set viewport size (mobile device simulation)\nSet-PlaywrightPageViewportSize -Width 375 -Height 667\n\n# Emulate media features\nSet-PlaywrightPageMedia -ColorScheme \"dark\" -ReducedMotion \"reduce\"\n\n# Take screenshot with mobile viewport\nGet-PlaywrightPageScreenshot -Path \".\\mobile-view.png\"\n\nExit-PlaywrightBrowser\nStop-Playwright\n```\n\n#### Wait for Events\n\n```powershell\nStart-Playwright\nStart-PlaywrightBrowser -BrowserType Chromium -Enter\nOpen-PlaywrightPage -Url \"https://example.com\"\n\n# Click a link and wait for navigation\n$link = Find-PlaywrightPageElement -Role \"link\"\nInvoke-PlaywrightLocatorClick -Locator $link\n\n# Wait for a specific event\nWait-PlaywrightPageEvent -Event \"load\" -Timeout 30000\n\nExit-PlaywrightBrowser\nStop-Playwright\n```\n\n### Multi-Browser Testing\n\n#### Test Across Different Browsers\n\n```powershell\nStart-Playwright\n\n$browsers = @('Chromium', 'Firefox', 'Webkit')\n$results = @()\n\nforeach ($browser in $browsers) {\n    Write-Host \"Testing with $browser...\"\n    \n    Start-PlaywrightBrowser -BrowserType $browser -Headless -Enter\n    Open-PlaywrightPage -Url \"https://example.com\"\n    \n    # Perform tests\n    $title = Get-PlaywrightPageTitle\n    $screenshot = \".\\test-$browser.png\"\n    Get-PlaywrightPageScreenshot -Path $screenshot\n    \n    $results += [PSCustomObject]@{\n        Browser = $browser\n        Title = $title\n        Screenshot = $screenshot\n    }\n    \n    Exit-PlaywrightBrowser\n}\n\n# Display results\n$results | Format-Table -AutoSize\n\nStop-Playwright\n```\n\n### Complete Example: Web Scraping\n\n```powershell\n# Scrape article titles from a news website\nStart-Playwright\nStart-PlaywrightBrowser -BrowserType Chromium -Headless -Enter\n\nOpen-PlaywrightPage -Url \"https://news.ycombinator.com\"\n\n# Wait for content to load\nStart-Sleep -Seconds 2\n\n# Execute JavaScript to extract article titles\n$titles = Invoke-PlaywrightPageJavascript -Script @\"\n    return Array.from(document.querySelectorAll('.titleline \u003e a'))\n        .map(a =\u003e ({\n            title: a.textContent,\n            url: a.href\n        }))\n        .slice(0, 10);\n\"@\n\n# Display results\nWrite-Host \"Top 10 Articles:`n\"\n$titles | ForEach-Object {\n    Write-Host \"- $($_.title)\"\n    Write-Host \"  URL: $($_.url)`n\"\n}\n\nExit-PlaywrightBrowser\nStop-Playwright\n```\n\n## Additional Resources\n\nFor detailed information about each command and its parameters, refer to the command documentation links in the [Commands](#commands) section above.\n\nFor more information about Playwright capabilities, visit the [official Playwright documentation](https://playwright.dev/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamdriscoll%2Fpsplaywright","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadamdriscoll%2Fpsplaywright","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamdriscoll%2Fpsplaywright/lists"}