Skip to content

Commit ba80464

Browse files
authored
Merge pull request #44 from Badgerati/develop
v1.3.0
2 parents 2c2586c + 2451a56 commit ba80464

18 files changed

+734
-77
lines changed

README.md

+28-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ Monocle is a Cross-Platform PowerShell Web Automation module, made to make autom
1616

1717
Monocle currently supports the following browsers:
1818

19-
* IE
20-
* Google Chrome
21-
* Firefox
19+
* IE (v3.150)
20+
* Chrome (v80.0.3987.1600)
21+
* Firefox (driver: v0.26)
22+
* Edge (driver: v79.0.309.71)
23+
* EdgeLegacy (driver: v17.17134)
2224

2325
## Install
2426

@@ -70,6 +72,7 @@ Close-MonocleBrowser -Browser $browser
7072

7173
The following is a list of available functions in Monocle:
7274

75+
* Add-MonocleElementClass
7376
* Assert-MonocleBodyValue
7477
* Assert-MonocleElementValue
7578
* Clear-MonocleElementValue
@@ -78,19 +81,27 @@ The following is a list of available functions in Monocle:
7881
* Get-Monocle2FACode
7982
* Get-MonocleElement
8083
* Get-MonocleElementAttribute
84+
* Get-MonocleElementCSS
8185
* Get-MonocleElementValue
8286
* Get-MonocleHtml
87+
* Get-MonoclePageSize
8388
* Get-MonocleTimeout
8489
* Get-MonocleUrl
90+
* Install-MonocleDriver
8591
* Invoke-MonocleElementCheck
8692
* Invoke-MonocleElementClick
8793
* Invoke-MonocleJavaScript
8894
* Invoke-MonocleRetryScript
8995
* Invoke-MonocleScreenshot
96+
* Measure-MonocleElement
97+
* Move-MonoclePage
9098
* New-MonocleBrowser
99+
* Remove-MonocleElementClass
100+
* Remove-MonocleElementCSS
91101
* Restart-MonocleBrowser
92102
* Save-MonocleImage
93103
* Set-MonocleElementAttribute
104+
* Set-MonocleElementCSS
94105
* Set-MonocleElementValue
95106
* Set-MonocleTimeout
96107
* Set-MonocleUrl
@@ -99,11 +110,25 @@ The following is a list of available functions in Monocle:
99110
* Submit-MonocleForm
100111
* Test-MonocleElement
101112
* Test-MonocleElementAttribute
113+
* Test-MonocleElementChecked
114+
* Test-MonocleElementClass
115+
* Test-MonocleElementCSS
116+
* Test-MonocleElementVisible
102117
* Wait-MonocleElement
103118
* Wait-MonocleUrl
104119
* Wait-MonocleUrlDifferent
105120
* Wait-MonocleValue
106121

122+
### Custom Drivers
123+
124+
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.
125+
126+
```powershell
127+
New-MonocleBrowser -Type Chrome -Path 'C:\Drivers\Chrome\70.0.3156.0'
128+
```
129+
130+
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.
131+
107132
### Screenshots
108133

109134
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:

examples/checkbox.ps1

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
$path = Split-Path -Parent -Path (Split-Path -Parent -Path $MyInvocation.MyCommand.Path)
2+
$path = "$($path)/src/Monocle.psm1"
3+
Import-Module $path -Force -ErrorAction Stop
4+
5+
# Create a browser object
6+
$browser = New-MonocleBrowser -Type Chrome
7+
8+
# Monocle runs commands in web flows, for easy disposal and test tracking
9+
Start-MonocleFlow -Name 'Load Html' -Browser $browser -ScriptBlock {
10+
11+
Set-MonocleUrl -Url 'https://html.com/input-type-checkbox/'
12+
13+
$element = Get-MonocleElement -Id 'love'
14+
$element | Test-MonocleElementChecked
15+
$element | Invoke-MonocleElementCheck
16+
$element | Test-MonocleElementChecked
17+
18+
} -CloseBrowser

examples/dropdowns.ps1

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
$path = Split-Path -Parent -Path (Split-Path -Parent -Path $MyInvocation.MyCommand.Path)
2+
$path = "$($path)/src/Monocle.psm1"
3+
Import-Module $path -Force -ErrorAction Stop
4+
5+
# Create a browser object
6+
$browser = New-MonocleBrowser -Type Chrome
7+
8+
# Monocle runs commands in web flows, for easy disposal and test tracking
9+
Start-MonocleFlow -Name 'Load Html' -Browser $browser -ScriptBlock {
10+
11+
Set-MonocleUrl -Url 'https://html.com/tags/select/'
12+
13+
$element = Get-MonocleElement -Selector 'select'
14+
$element | Set-MonocleElementValue -Value 'Lesser flamingo'
15+
$element | Get-MonocleElementValue
16+
$element | Test-MonocleElementVisible
17+
18+
} -CloseBrowser

examples/google.ps1

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
$path = Split-Path -Parent -Path (Split-Path -Parent -Path $MyInvocation.MyCommand.Path)
2+
$path = "$($path)/src/Monocle.psm1"
3+
Import-Module $path -Force -ErrorAction Stop
4+
5+
# Create a browser object
6+
$browser = New-MonocleBrowser -Type Chrome
7+
8+
# Monocle runs commands in web flows, for easy disposal and test tracking
9+
Start-MonocleFlow -Name 'Google Search' -Browser $browser -ScriptBlock {
10+
11+
# navigate to google
12+
Set-MonocleUrl -Url 'https://www.google.com'
13+
14+
# enter search value
15+
Get-MonocleElement -Id 'q' | Set-MonocleElementValue -Value 'PowerShell'
16+
17+
# click search button
18+
Get-MonocleElement -TagName 'input' -AttributeName 'value' -AttributeValue 'Google Search' | Invoke-MonocleElementClick
19+
20+
# wait for search page
21+
Wait-MonocleUrl -Url 'https://www.google.com/search' -StartsWith
22+
23+
# click the google logo (back to home)
24+
Get-MonocleElement -Id 'logo' | Invoke-MonocleElementClick
25+
26+
# ensure we're back home
27+
Wait-MonocleElement -Id 'q'
28+
29+
} -CloseBrowser

examples/youtube.ps1

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ Import-Module $path -Force -ErrorAction Stop
44
#Import-Module -Name Monocle -Force -ErrorAction Stop
55

66
# Create a browser object
7-
#$browser = New-MonocleBrowser -Type Firefox
7+
#Install-MonocleDriver -Type Chrome -Version '79.0.3945.3600'
8+
$browser = New-MonocleBrowser -Type Chrome
89

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

1314
# Tell the browser which URL to navigate to, will sleep while page is loading
1415
Set-MonocleUrl -Url 'https://www.youtube.com'

src/Monocle.psd1

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
RootModule = 'Monocle.psm1'
1212

1313
# Version number of this module.
14-
ModuleVersion = '1.2.0'
14+
ModuleVersion = '1.3.0'
1515

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

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

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

0 commit comments

Comments
 (0)