Skip to content

Commit

Permalink
Merge pull request #44 from Badgerati/develop
Browse files Browse the repository at this point in the history
v1.3.0
  • Loading branch information
Badgerati committed Feb 9, 2020
2 parents 2c2586c + 2451a56 commit ba80464
Show file tree
Hide file tree
Showing 18 changed files with 734 additions and 77 deletions.
31 changes: 28 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ Monocle is a Cross-Platform PowerShell Web Automation module, made to make autom

Monocle currently supports the following browsers:

* IE
* Google Chrome
* Firefox
* IE (v3.150)
* Chrome (v80.0.3987.1600)
* Firefox (driver: v0.26)
* Edge (driver: v79.0.309.71)
* EdgeLegacy (driver: v17.17134)

## Install

Expand Down Expand Up @@ -70,6 +72,7 @@ Close-MonocleBrowser -Browser $browser

The following is a list of available functions in Monocle:

* Add-MonocleElementClass
* Assert-MonocleBodyValue
* Assert-MonocleElementValue
* Clear-MonocleElementValue
Expand All @@ -78,19 +81,27 @@ The following is a list of available functions in Monocle:
* Get-Monocle2FACode
* Get-MonocleElement
* Get-MonocleElementAttribute
* Get-MonocleElementCSS
* Get-MonocleElementValue
* Get-MonocleHtml
* Get-MonoclePageSize
* Get-MonocleTimeout
* Get-MonocleUrl
* Install-MonocleDriver
* Invoke-MonocleElementCheck
* Invoke-MonocleElementClick
* Invoke-MonocleJavaScript
* Invoke-MonocleRetryScript
* Invoke-MonocleScreenshot
* Measure-MonocleElement
* Move-MonoclePage
* New-MonocleBrowser
* Remove-MonocleElementClass
* Remove-MonocleElementCSS
* Restart-MonocleBrowser
* Save-MonocleImage
* Set-MonocleElementAttribute
* Set-MonocleElementCSS
* Set-MonocleElementValue
* Set-MonocleTimeout
* Set-MonocleUrl
Expand All @@ -99,11 +110,25 @@ The following is a list of available functions in Monocle:
* Submit-MonocleForm
* Test-MonocleElement
* Test-MonocleElementAttribute
* Test-MonocleElementChecked
* Test-MonocleElementClass
* Test-MonocleElementCSS
* Test-MonocleElementVisible
* Wait-MonocleElement
* Wait-MonocleUrl
* Wait-MonocleUrlDifferent
* Wait-MonocleValue

### Custom Drivers

If 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.

```powershell
New-MonocleBrowser -Type Chrome -Path 'C:\Drivers\Chrome\70.0.3156.0'
```

Also, 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.

### Screenshots

There 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:
Expand Down
18 changes: 18 additions & 0 deletions examples/checkbox.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
$path = Split-Path -Parent -Path (Split-Path -Parent -Path $MyInvocation.MyCommand.Path)
$path = "$($path)/src/Monocle.psm1"
Import-Module $path -Force -ErrorAction Stop

# Create a browser object
$browser = New-MonocleBrowser -Type Chrome

# Monocle runs commands in web flows, for easy disposal and test tracking
Start-MonocleFlow -Name 'Load Html' -Browser $browser -ScriptBlock {

Set-MonocleUrl -Url 'https://html.com/input-type-checkbox/'

$element = Get-MonocleElement -Id 'love'
$element | Test-MonocleElementChecked
$element | Invoke-MonocleElementCheck
$element | Test-MonocleElementChecked

} -CloseBrowser
18 changes: 18 additions & 0 deletions examples/dropdowns.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
$path = Split-Path -Parent -Path (Split-Path -Parent -Path $MyInvocation.MyCommand.Path)
$path = "$($path)/src/Monocle.psm1"
Import-Module $path -Force -ErrorAction Stop

# Create a browser object
$browser = New-MonocleBrowser -Type Chrome

# Monocle runs commands in web flows, for easy disposal and test tracking
Start-MonocleFlow -Name 'Load Html' -Browser $browser -ScriptBlock {

Set-MonocleUrl -Url 'https://html.com/tags/select/'

$element = Get-MonocleElement -Selector 'select'
$element | Set-MonocleElementValue -Value 'Lesser flamingo'
$element | Get-MonocleElementValue
$element | Test-MonocleElementVisible

} -CloseBrowser
29 changes: 29 additions & 0 deletions examples/google.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
$path = Split-Path -Parent -Path (Split-Path -Parent -Path $MyInvocation.MyCommand.Path)
$path = "$($path)/src/Monocle.psm1"
Import-Module $path -Force -ErrorAction Stop

# Create a browser object
$browser = New-MonocleBrowser -Type Chrome

# Monocle runs commands in web flows, for easy disposal and test tracking
Start-MonocleFlow -Name 'Google Search' -Browser $browser -ScriptBlock {

# navigate to google
Set-MonocleUrl -Url 'https://www.google.com'

# enter search value
Get-MonocleElement -Id 'q' | Set-MonocleElementValue -Value 'PowerShell'

# click search button
Get-MonocleElement -TagName 'input' -AttributeName 'value' -AttributeValue 'Google Search' | Invoke-MonocleElementClick

# wait for search page
Wait-MonocleUrl -Url 'https://www.google.com/search' -StartsWith

# click the google logo (back to home)
Get-MonocleElement -Id 'logo' | Invoke-MonocleElementClick

# ensure we're back home
Wait-MonocleElement -Id 'q'

} -CloseBrowser
5 changes: 3 additions & 2 deletions examples/youtube.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ Import-Module $path -Force -ErrorAction Stop
#Import-Module -Name Monocle -Force -ErrorAction Stop

# Create a browser object
#$browser = New-MonocleBrowser -Type Firefox
#Install-MonocleDriver -Type Chrome -Version '79.0.3945.3600'
$browser = New-MonocleBrowser -Type Chrome

# Monocle runs commands in web flows, for easy disposal and test tracking
# Each flow needs a name
Start-MonocleFlow -Name 'Load YouTube' <#-Browser $browser#> -ScriptBlock {
Start-MonocleFlow -Name 'Load YouTube' -Browser $browser -ScriptBlock {

# Tell the browser which URL to navigate to, will sleep while page is loading
Set-MonocleUrl -Url 'https://www.youtube.com'
Expand Down
5 changes: 3 additions & 2 deletions src/Monocle.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
RootModule = 'Monocle.psm1'

# Version number of this module.
ModuleVersion = '1.2.0'
ModuleVersion = '1.3.0'

# ID used to uniquely identify this module
GUID = '9dc3c8a1-664d-4253-a5d2-920250d3a15f'
Expand All @@ -34,7 +34,8 @@

# Tags applied to this module. These help with module discovery in online galleries.
Tags = @('powershell', 'web', 'automation', 'testing', 'ie', 'internet-explorer', 'websites', 'chrome', '2fa',
'firefox', 'selenium', 'cross-platform', 'PSEdition_Core', 'PSEdition_Desktop', 'linux', 'google-chrome')
'firefox', 'selenium', 'cross-platform', 'PSEdition_Core', 'PSEdition_Desktop', 'linux', 'google-chrome',
'edge', 'chromium')

# A URL to the license for this module.
LicenseUri = 'https://raw.githubusercontent.com/Badgerati/Monocle/master/LICENSE.txt'
Expand Down
Loading

0 comments on commit ba80464

Please sign in to comment.