{"id":16567524,"url":"https://github.com/badgerati/monocle","last_synced_at":"2026-03-04T00:32:32.436Z","repository":{"id":53109835,"uuid":"69507991","full_name":"Badgerati/Monocle","owner":"Badgerati","description":"PowerShell Web Automation module, made to make automating websites easier","archived":false,"fork":false,"pushed_at":"2021-04-06T10:09:44.000Z","size":137232,"stargazers_count":68,"open_issues_count":7,"forks_count":12,"subscribers_count":8,"default_branch":"develop","last_synced_at":"2025-08-01T09:47:12.387Z","etag":null,"topics":["automation","chrome","cross-platform","docker","edge","firefox","ie","internet-explorer","linux","powershell","selenium","web","websites"],"latest_commit_sha":null,"homepage":null,"language":"PowerShell","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/Badgerati.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-28T22:13:48.000Z","updated_at":"2025-07-17T14:46:15.000Z","dependencies_parsed_at":"2022-09-13T15:02:56.652Z","dependency_job_id":null,"html_url":"https://github.com/Badgerati/Monocle","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/Badgerati/Monocle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Badgerati%2FMonocle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Badgerati%2FMonocle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Badgerati%2FMonocle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Badgerati%2FMonocle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Badgerati","download_url":"https://codeload.github.com/Badgerati/Monocle/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Badgerati%2FMonocle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30067726,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-03T18:21:05.932Z","status":"ssl_error","status_checked_at":"2026-03-03T18:20:59.341Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["automation","chrome","cross-platform","docker","edge","firefox","ie","internet-explorer","linux","powershell","selenium","web","websites"],"created_at":"2024-10-11T21:06:49.664Z","updated_at":"2026-03-04T00:32:32.399Z","avatar_url":"https://github.com/Badgerati.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Monocle\n\n[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/Badgerati/Monocle/master/LICENSE.txt)\n[![PowerShell](https://img.shields.io/powershellgallery/dt/monocle.svg?label=PowerShell\u0026colorB=085298)](https://www.powershellgallery.com/packages/Monocle)\n[![Docker](https://img.shields.io/docker/pulls/badgerati/monocle.svg?label=Docker)](https://hub.docker.com/r/badgerati/monocle/)\n\nMonocle is a Cross-Platform PowerShell Web Automation module, made to make automating and testing websites easier. It's a PowerShell wrapper around Selenium, with the aim of abstracting Selenium away from the user.\n\n* [Install](#install)\n* [Example](#example)\n* [Documentation](#documentation)\n  * [Functions](#functions)\n  * [Screenshots](#screenshots)\n  * [2FA Codes](#2fa-codes)\n  * [Docker](#docker)\n\nMonocle currently supports the following browsers:\n\n* IE (v3.150.1.2)\n* Chrome (v85.0.4183.8300)\n* Firefox (driver: v0.27.0)\n* Edge (driver: v81.0.416.77)\n* EdgeLegacy (driver: v17.17134)\n\n## Install\n\n```powershell\nInstall-Module -Name Monocle\n```\n\n## Example\n\n```powershell\nImport-Module Monocle\n\n# create a browser\n$browser = New-MonocleBrowser -Type Chrome\n\n# Monocle runs commands in web flows, for easy disposal and test tracking\nStart-MonocleFlow -Name 'Load YouTube' -Browser $browser -ScriptBlock {\n\n    # tell the browser which URL to navigate to, will wait for the page to load\n    Set-MonocleUrl -Url 'https://www.youtube.com'\n\n    # sets the element's value, selecting the element by ID/Name\n    Get-MonocleElement -Id 'search_query' | Set-MonocleElementValue -Value 'Beerus Madness (Extended)'\n\n    # click the search button\n    Get-MonocleElement -Id 'search-icon-legacy' | Invoke-MonocleElementClick\n\n    # wait for the URL to change to start with the following value\n    Wait-MonocleUrl -Url 'https://www.youtube.com/results?search_query=' -StartsWith\n\n    # downloads an image from the page, selcted by using an XPath to an element\n    Get-MonocleElement -XPath \"//div[@data-context-item-id='SI6Yyr-iI6M']/img[1]\" | Save-MonocleImage -FilePath '.\\beerus.jpg'\n\n    # tells the browser to click the video in the results\n    Get-MonocleElement -XPath \"//a[@title='Dragon Ball Super Soundtrack - Beerus Madness (Extended)']\" | Invoke-MonocleElementClick\n\n    # wait for the URL to be loaded\n    Wait-MonocleUrl -Url 'https://www.youtube.com/watch?v=SI6Yyr-iI6M'\n\n}\n\n# dispose the browser\nClose-MonocleBrowser -Browser $browser\n```\n\n## Documentation\n\n### Functions\n\nThe following is a list of available functions in Monocle:\n\n* Add-MonocleElementClass\n* Assert-MonocleBodyValue\n* Assert-MonocleElementValue\n* Clear-MonocleElementValue\n* Close-MonocleBrowser\n* Edit-MonocleUrl\n* Enter-MonocleFrame\n* Get-Monocle2FACode\n* Get-MonocleElement\n* Get-MonocleElementAttribute\n* Get-MonocleElementChild\n* Get-MonocleElementCSS\n* Get-MonocleElementParent\n* Get-MonocleElementSibling\n* Get-MonocleElementValue\n* Get-MonocleHtml\n* Get-MonoclePageSize\n* Get-MonocleTimeout\n* Get-MonocleUrl\n* Install-MonocleDriver\n* Invoke-MonocleElementCheck\n* Invoke-MonocleElementClick\n* Invoke-MonocleJavaScript\n* Invoke-MonocleRetryScript\n* Invoke-MonocleScreenshot\n* Measure-MonocleElement\n* Measure-MonocleElementChild\n* Move-MonoclePage\n* New-MonocleBrowser\n* Remove-MonocleElementClass\n* Remove-MonocleElementCSS\n* Restart-MonocleBrowser\n* Save-MonocleImage\n* Set-MonocleElementAttribute\n* Set-MonocleElementCSS\n* Set-MonocleElementValue\n* Set-MonocleTimeout\n* Set-MonocleUrl\n* Start-MonocleFlow\n* Start-MonocleSleep\n* Submit-MonocleForm\n* Test-MonocleElement\n* Test-MonocleElementAttribute\n* Test-MonocleElementChecked\n* Test-MonocleElementChild\n* Test-MonocleElementClass\n* Test-MonocleElementCSS\n* Test-MonocleElementVisible\n* Wait-MonocleElement\n* Wait-MonocleElementVisible\n* Wait-MonocleUrl\n* Wait-MonocleUrlDifferent\n* Wait-MonocleValue\n\n### Custom Drivers\n\nIf you need to use an earlier/later version of a driver, you manually download the driver and then supply a `-Path` to `New-MonocleBrowser` which is the directory that contains the driver.\n\n```powershell\nNew-MonocleBrowser -Type Chrome -Path 'C:\\Drivers\\Chrome\\70.0.3156.0'\n```\n\nAlso, you could use `Install-MonocleDriver`. This will download a driver for you, and be automatically used by Monocle. This does require the `nuget` CLI being installed.\n\n### Screenshots\n\nThere are two main ways to take a screenshot of the browser. The first it to tell Monocle to automatically take a screenshot whenever a flow fails. You can do this by using the `-ScreenshotPath` and `-ScreenshotOnFail` parameters on the `Start-MonocleFlow` function:\n\n```powershell\nStart-MonocleFlow -Name '\u003cname\u003e' -Browser $browser -ScriptBlock {\n    # failing logic\n} -ScreenshotPath './path' -ScreenshotOnFail\n```\n\nOr, you can take a screenshot directly:\n\n```powershell\nInvoke-MonocleScreenshot -Name 'screenshot.png' -Path './path'\n```\n\n\u003e Not supplying `-ScreenshotPath` or `-Path` will default to the current path.\n\n### 2FA Codes\n\nMonocle has inbuilt support for generating 2FA codes. To do this you need the Secret Code that is normally presented with the QR code, and you pass this to the `Get-Monocle2FACode` function with a date - which is defaulted to now:\n\n```powershell\n$code = Get-Monocle2FACode -Secret 'FAKENDMYJWLLB'\nGet-MonocleElement -Id '2fa-code' | Set-MonocleElementValue -Value $code -Mask\n```\n\n### Docker\n\nMonocle has an official Docker image, which comes preloaded with:\n\n* Monocle (obviously!)\n* Firefox\n* Google Chrome\n\nYou can use this image to run your Monocle flows - and they will also automatically run headless.\n\nAn example `Dockerfile` could be:\n\n```dockerfile\nFROM badgerati/monocle:latest\nCOPY . /usr/src/scripts\nCMD [ \"pwsh\", \"-c\", \"cd /usr/src/scripts; ./flow.ps1\" ]\n```\n\nThe you can build and run the image as follows:\n\n```powershell\ndocker build -t monocle/test .\ndocker run --rm monocle/test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadgerati%2Fmonocle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbadgerati%2Fmonocle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadgerati%2Fmonocle/lists"}