Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7dd2a97

Browse files
Merge pull request #102 from adamdriscoll/feature/documentation-and-scaffolding
Feature/documentation and scaffolding
2 parents 79b1bcf + 99b8f93 commit 7dd2a97

File tree

108 files changed

+15393
-1803
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+15393
-1803
lines changed

‎.gitignore‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
.vscode/launch.json
2-
CI/LocalPostProcessing.ps1
3-
1+
.vscode
2+
CI/LocalPostProcessing.ps1
3+
Scratchpad.ps1
4+
Output/testResults*.xml
5+
Output/stats.json

‎CI/CI.ps1‎

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,69 @@
11
param (
2-
[string[]]$BrowserList=@('Chrome','Firefox')
2+
[string[]]$BrowserList=@('Chrome','Firefox')
33
)
44
#Get the OS/PS version info for later. On Linux run headless On windows and PS 6 (but not 7) add WindowsPowershell to the module path.
5-
$Platform = ([environment]::OSVersion.Platform).ToString() + ' PS' + $PSVersionTable.PSVersion.Major
6-
if ($Platform -notlike 'win*') {$env:AlwaysHeadless = $true}
7-
if ($Platform -like 'win*6') {
8-
$env:PSModulePath -split ';' | Where-Object {$_ -match "\w:\\Prog.*PowerShell\\modules"} | ForEach-Object {
9-
$env:PSModulePath = ($_ -replace "PowerShell","WindowsPowerShell") + ";" + $env:PSModulePath
10-
}
5+
$Platform = ([environment]::OSVersion.Platform).ToString() + ' PS' + $PSVersionTable.PSVersion.Major
6+
if ($Platform -notlike 'win*') { $env:AlwaysHeadless = $true}
7+
if ($Platform -like 'win*6') {
8+
$env:PSModulePath -split ';' | Where-Object {$_ -match "\w:\\Prog.*PowerShell\\modules"} | ForEach-Object {
9+
$env:PSModulePath = ($_ -replace "PowerShell","WindowsPowerShell") + ";" + $env:PSModulePath
10+
}
1111
}
1212

1313
#Make sure we have the modules we need
14-
Import-Module .\Selenium.psd1 -Force -ErrorAction Stop
14+
Import-Module .\Output\Selenium\Selenium.psd1 -Force -ErrorAction Stop
1515
$checkImportExcel = Get-Module -ListAvailable ImportExcel
1616
if (-not ($checkImportExcel)) {
1717
Write-Verbose -Verbose 'Installing ImportExcel'
1818
Install-Module ImportExcel -Force -SkipPublisherCheck
1919
}
20-
else {$checkImportExcel | Out-Host}
21-
$checkPester = Get-Module -ListAvailable Pester| Where-Object {$_.version.major -ge 4 -and $_.version.minor -ge 4}
20+
else {$checkImportExcel | Out-Host}
21+
$checkPester = Get-Module -ListAvailable Pester| Where-Object {$_.version.major -ge 4 -and $_.version.minor -ge 4}
2222
if (-not $checkPester) {
2323
Write-Verbose -Verbose 'Installing Pester'
2424
Install-Module Pester -Force -SkipPublisherCheck
2525
}
26-
else {$checkPester | Out-Host}
26+
else {$checkPester | Out-Host}
2727

2828
#Run the test and results export to an Excel file for current OS - Test picks up the selected browser from an environment variable.
29-
$RunParameters = @{
30-
XLFile = '{0}/results/Results-{1}.xlsx' -f $env:BUILD_ARTIFACTSTAGINGDIRECTORY, [environment]::OSVersion.Platform.ToString()
31-
Script = Join-Path -Path (Join-Path $pwd 'Examples') -ChildPath 'Combined.tests.ps1'
29+
$RunParameters = @{
30+
XLFile = '{0}/results/Results-{1}.xlsx' -f $env:BUILD_ARTIFACTSTAGINGDIRECTORY, [environment]::OSVersion.Platform.ToString()
31+
Script = Join-Path -Path (Join-Path $pwd 'Examples') -ChildPath 'Combined.tests.ps1'
3232
}
3333
foreach ( $b in $BrowserList) {
3434
$env:DefaultBrowser = $b
35-
$RunParameters['OutputFile'] = Join-Path $pwd "TestResults-$platform$b.xml"
36-
$RunParameters['WorkSheetName'] = "$B $Platform"
35+
$RunParameters['OutputFile'] = Join-Path $pwd "TestResults-$platform$b.xml"
36+
$RunParameters['WorkSheetName'] = "$B $Platform"
3737
$RunParameters | Out-Host
3838
& "$PSScriptRoot\Pester-To-XLSx.ps1" @RunParameters
3939
}
4040

4141
#Merge the results sheets into a sheet named 'combined'.
42-
$excel = Open-ExcelPackage $RunParameters.XLFile
43-
$wslist = $excel.Workbook.Worksheets.name
42+
$excel = Open-ExcelPackage $RunParameters.XLFile
43+
$wslist = $excel.Workbook.Worksheets.name
4444
Close-ExcelPackage -NoSave $excel
45-
Merge-MultipleSheets -path $RunParameters.XLFile -WorksheetName $wslist -OutputSheetName combined -OutputFile $RunParameters.XLFile -HideRowNumbers -Property name,result
45+
Merge-MultipleSheets -path $RunParameters.XLFile -WorksheetName $wslist -OutputSheetName combined -OutputFile $RunParameters.XLFile -HideRowNumbers -Property name,result
4646

4747
#Hide everything on 'combined' except test name, results for each browser, and test group, Set column widths, tweak titles, apply conditional formatting.
48-
$excel = Open-ExcelPackage $RunParameters.XLFile
49-
$ws = $excel.combined
48+
$excel = Open-ExcelPackage $RunParameters.XLFile
49+
$ws = $excel.combined
5050
2..$ws.Dimension.end.Column | ForEach-Object {
51-
if ($ws.Cells[1,$_].value -notmatch '^Name|Result$|PS\dGroup$') {
51+
if ($ws.Cells[1,$_].value -notmatch '^Name|Result$|PS\dGroup$') {
5252
Set-ExcelColumn -Worksheet $ws -Column $_ -Hid
5353
}
54-
elseif ($ws.Cells[1,$_].value -match 'Result$' ) {
54+
elseif ($ws.Cells[1,$_].value -match 'Result$' ) {
5555
Set-ExcelColumn -Worksheet $ws -Column $_ -Width 17
56-
Set-ExcelRange $ws.Cells[1,$_] -WrapText
56+
Set-ExcelRange $ws.Cells[1,$_] -WrapText
5757
}
58-
if ($ws.cells[1,$_].value -match 'PS\dGroup$') {
59-
Set-ExcelRange $ws.Cells[1,$_] -WrapText -Value 'Group'
58+
if ($ws.cells[1,$_].value -match 'PS\dGroup$') {
59+
Set-ExcelRange $ws.Cells[1,$_] -WrapText -Value 'Group'
6060
}
61-
if ($ws.cells[1,$_].value -match '^Name|PS\dGroup$' -and ($ws.Column($_).Width -gt 80)) {
61+
if ($ws.cells[1,$_].value -match '^Name|PS\dGroup$' -and ($ws.Column($_).Width -gt 80)) {
6262
$ws.Column($_).Width = 80
6363
}
6464
}
6565
Set-ExcelRow -Worksheet $ws -Height 28.5
66-
$cfRange = [OfficeOpenXml.ExcelAddress]::new(2,3,$ws.Dimension.end.Row, (3*$wslist.count -2)).Address
66+
$cfRange = [OfficeOpenXml.ExcelAddress]::new(2,3,$ws.Dimension.end.Row, (3*$wslist.count -2)).Address
6767
Add-ConditionalFormatting -WorkSheet $ws -range $cfRange -RuleType ContainsText -ConditionValue "Failure" -BackgroundPattern None -ForegroundColor Red -Bold
6868
Add-ConditionalFormatting -WorkSheet $ws -range $cfRange -RuleType ContainsText -ConditionValue "Success" -BackgroundPattern None -ForeGroundColor Green
6969
Close-ExcelPackage $excel

‎CI/pipeline.yml‎

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
11
# https://aka.ms/yaml
22

33
trigger:
4-
branches:
5-
include:
6-
- '*'
7-
# - master
8-
# - releases/*
9-
paths:
10-
exclude:
4+
branches:
5+
include:
6+
- "*"
7+
# - master
8+
# - releases/*
9+
paths:
10+
exclude:
1111
- additions.md
1212
- ChangeLog.Txt
1313
- README.md
1414

1515
jobs:
16-
- job: 'Windows'
16+
- job: "Windows"
1717
pool:
18-
vmImage: 'windows-latest'
18+
vmImage: "windows-latest"
1919
steps:
20-
- powershell: './CI/CI.ps1 -browserlist Chrome,Firefox,IE'
21-
displayName: 'Run Test on Windows PowerShell'
22-
- pwsh: './CI/CI.ps1 -browserlist Chrome'
23-
displayName: 'Run Test on PowerShell core on Windows'
24-
- task: PublishPipelineArtifact@1
25-
inputs:
26-
targetPath: '$(Build.ArtifactStagingDirectory)/results'
27-
artifact: 'Windows Results'
28-
- task: PublishTestResults@2
29-
inputs:
30-
testResultsFormat: 'NUnit'
31-
testResultsFiles: '**/TestResults*.xml'
32-
failTaskOnFailedTests: true
20+
- powershell: "./CI/CI.ps1 -browserlist Chrome,Firefox,IE"
21+
displayName: "Run Test on Windows PowerShell"
22+
- pwsh: "./CI/CI.ps1 -browserlist Chrome"
23+
displayName: "Run Test on PowerShell core on Windows"
24+
- task: PublishPipelineArtifact@1
25+
inputs:
26+
targetPath: "$(Build.ArtifactStagingDirectory)/results"
27+
artifact: "Windows Results"
28+
- task: PublishTestResults@2
29+
inputs:
30+
testResultsFormat: "NUnit"
31+
testResultsFiles: "**/TestResults*.xml"
32+
failTaskOnFailedTests: true
3333

34-
- job: 'Ubuntu'
34+
- job: "Ubuntu"
3535
pool:
36-
vmImage: 'ubuntu-latest'
36+
vmImage: "ubuntu-latest"
3737
steps:
38-
- powershell: './CI/CI.ps1 -browserlist Chrome,Firefox'
39-
displayName: 'Run Test on Linux'
40-
- task: PublishPipelineArtifact@1
41-
inputs:
42-
targetPath: '$(Build.ArtifactStagingDirectory)/results'
43-
artifact: 'Linux Results'
44-
- task: PublishTestResults@2
45-
inputs:
46-
testResultsFormat: 'NUnit'
47-
testResultsFiles: '**/TestResults*.xml'
48-
failTaskOnFailedTests: true
38+
- powershell: "./CI/CI.ps1 -browserlist Chrome,Firefox"
39+
displayName: "Run Test on Linux"
40+
- task: PublishPipelineArtifact@1
41+
inputs:
42+
targetPath: "$(Build.ArtifactStagingDirectory)/results"
43+
artifact: "Linux Results"
44+
- task: PublishTestResults@2
45+
inputs:
46+
testResultsFormat: "NUnit"
47+
testResultsFiles: "**/TestResults*.xml"
48+
failTaskOnFailedTests: true

‎ChangeLog.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44

55
- Added -IgnoreProtectedModeSettings to Start-SeInternetExplorer - https://github.com/adamdriscoll/selenium-powershell/issues/79 - Thanks, @MysticRyuujin!
66

7+
- Added Markdown documentation (See Help subfolder) for all the cmdlets (PlatyPS is used behind the scene to maintain it)
8+
- Added MAML embedded help that can be accessed through `Get-Help`(eg: `Get-Help Start-SeChrome -Examples`)
9+
710
# 3.0.0 - 3/31/2020
811

912
## Changed
1013

1114
- Fixed issue with importing module in PSv5.1 - https://github.com/adamdriscoll/selenium-powershell/issues/69
1215
- Updated Chrome drivers
16+
- Converted monolythic module into a scaffolded module through a Plaster template. Module will now have a debug version and a compiled version that need to be built with Invoke-Build. See the Debug folder for additional informations on how to debug.
1317

1418
# 3.0.0-beta2 - 1/29/2020
1519

‎Debug/Debug.ps1‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import-module Platyps
2+
import-module InvokeBuild
3+
4+
# Just a line to replace $PsScriptRoot since the former does not work when debugging with F8
5+
$ScriptFullPath, $ScriptRoot, $ScriptName, $ScriptNameShort = @('', '', '', ''); $ScriptFullPath = if (-not [String]::IsNullOrEmpty($PSCommandPath)) { $PSCommandPath } elseif ($psEditor -ne $null) { $psEditor.GetEditorContext().CurrentFile.Path } elseif ($psise -ne $null) { $psise.CurrentFile.FullPath }; $ScriptRoot = Split-Path -Path $ScriptFullPath -Parent; $ScriptName = Split-Path -Path $ScriptFullPath -Leaf; $ScriptNameShort = ([System.IO.Path]::GetFileNameWithoutExtension($ScriptFullPath))
6+
$ProjectPath = Split-Path $ScriptRoot
7+
8+
# Load Debug version
9+
#import-module "$ProjectPath\Selenium.psd1" -Force
10+
11+
#Load Compiled version
12+
import-module "$ProjectPath\output\selenium\Selenium.psd1" -Force
13+
Invoke-Pester -Script 'C:\Github\selenium-powershell\Examples\Combined.tests.ps1'
14+
15+
# Build module
16+
#invoke-build -File "$ProjectPath\Selenium.build.ps1"
17+
18+
19+
20+
21+

‎Debug/README.md‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Instructions
2+
3+
## Prerequisites
4+
- InvokeBuild module
5+
- PlatyPS module
6+
7+
## How to
8+
9+
### Debug
10+
11+
To load the debugging version, simply load the Selenium.psd1 located at the root of this directory.
12+
13+
`import-module "$ProjectPath\Selenium.psd1" -Force`
14+
15+
To load the compiled version, load the psd1 located in the output directory instead.
16+
17+
`import-module "$ProjectPath\output\selenium\Selenium.psd1" -Force`
18+
19+
When developping, you should always load the development version of the module. Never work in the files from the **output** directory directly as these will be wiped out whenever you compile the module again.
20+
21+
### Compile the module
22+
The module is scaffolded into multiple files for convenience and compiled into a psm1 file when ready to be published.
23+
24+
Alongside this, additional tasks are performed suche as basic Powershell validation, self-updating Markdown documentation, embedded help file generation, psd1 function replace based on Public folder content, etc.
25+
26+
To perform these tasks and produce a compiled (but not packaged) version of the module, run the following
27+
28+
`invoke-build -File "$ProjectPath\Selenium.build.ps1"`
29+
30+
31+
See the debug.ps1 file in this directory to get started.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /