Skip to content

Commit

Permalink
Merge pull request #2460 from corbob/2179-AddsSeleniumPowerShell
Browse files Browse the repository at this point in the history
  • Loading branch information
AdmiringWorm authored May 3, 2024
2 parents 10f2717 + 6468471 commit 5d965c8
Show file tree
Hide file tree
Showing 10 changed files with 351 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
*/nexus-repository* @chocolatey-community/chocolatey-team-maintainers
*/totalcommander* @pauby
*/kubescape* @HollowMan6
*/azcopy10* @chocolatey-community/chocolatey-team-maintainers
*/googlechromebeta* @tunisiano187
*/krita* @tunisiano187
*/selenium.powershell* @chocolatey-community/chocolatey-team-maintainers

# Other
# This can be any file other that won't be matched as a package
Expand Down
22 changes: 22 additions & 0 deletions automatic/selenium.powershell/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Selenium PowerShell Module

The Selenium PowerShell module allows you to automate browser interaction using the [Selenium API](https://selenium.dev/). You can navigate to pages, find elements, click buttons, enter text and even take screenshots.

## Features

- Wraps the C# WebDriver for Selenium
- Easily execute web-based tests
- Works well with Pester

## Package Parameters

The following package parameters can be set:

- `/core` - Installs the module in the AllUsers scope for PowerShell Core
- `/desktop` - Installs the module in the AllUsers scope for Windows PowerShell (ie. Desktop Edition)

To pass parameters, use `--params "''"` (e.g. `choco install selenium.powershell [other options] --params="'/Core'"`).

## Notes

- **If the package is out of date please check [Version History](#versionhistory) for the latest submitted version. If you have a question, please ask it in [Chocolatey Community Package Discussions](https://github.com/chocolatey-community/chocolatey-packages/discussions) or raise an issue on the [Chocolatey Community Packages Repository](https://github.com/chocolatey-community/chocolatey-packages/issues) if you have problems with the package. Disqus comments will generally not be responded to.**
21 changes: 21 additions & 0 deletions automatic/selenium.powershell/legal/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Adam Driscoll

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
119 changes: 119 additions & 0 deletions automatic/selenium.powershell/legal/VERIFICATION.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
VERIFICATION
Verification is intended to assist the Chocolatey moderators and community
in verifying that this package's contents are trustworthy.

The file 'LICENSE.txt' is obtained from <https://github.com/adamdriscoll/selenium-powershell/blob/478369b92437f7bfba14ddc64109ee07ee2ecca2/LICENSE>

The module has been downloaded from <https://www.powershellgallery.com/packages/Selenium>
and zipped into 'selenium.zip'. It can be verified by following these steps:

1. Save the module from the PowerShell Gallery:
- Save-Module -Name Selenium -Path . -RequiredVersion 0.0.0
2. Get the checksum for each file saved to `Selenium\0.0.0` using one of the following methods:
- Using powershell function 'Get-FileHash'
- Use chocolatey utility 'checksum.exe'
3. The checksums should match the following:

file name: LICENSE
checksum type: SHA256
checksum: BAEB4A5B8A2F782E21C9F508EEBC728ADBA739F7B7FB8BA3FF07747A4C9FE296

file name: README.md
checksum type: SHA256
checksum: D7DAE9FDD317D06EC5E33AE032963095DD6D4A0850DCF5939F65784237294A47

file name: Selenium-Binary-Updater.ps1
checksum type: SHA256
checksum: 5EB49321251411333B4FB00E4F3695B5E5F2B8B5B5179E8041AEE32E05F0C12D

file name: Selenium.psd1
checksum type: SHA256
checksum: BDFBD97AD53905E6921AD44C3BFE1790A8DDDF8FA30411877E0CC2C18DB30B2E

file name: Selenium.psm1
checksum type: SHA256
checksum: CA60DD2DAEF1204540C2A35D5849E9F25BADD76328DFD71A33DD4CA16E9F88CF

file name: SeleniumClasses.ps1
checksum type: SHA256
checksum: 884A78F44A0A36FD0F5EA4279E75F976D3A3CBB3C95F2C1203816F3ACD93A66B

file name: assemblies\chromedriver.exe
checksum type: SHA256
checksum: 55C5203DB4D44D96F4124C60E69AE0823F4372EFA4B5416675D9564A83D6AD2C

file name: assemblies\chromedriver.exe.sha256
checksum type: SHA256
checksum: B9ECBDF7B19AD0E4099141514D4DEF7C16334570524D750D12DE57F006317116

file name: assemblies\geckodriver.exe
checksum type: SHA256
checksum: 255C9D3571C86841213F49B26D176A6AD440BE8C720E3C2D9226076ADF4F603D

file name: assemblies\geckodriver.exe.sha256
checksum type: SHA256
checksum: B5A4EF0226B2D98DF9EAC1AD5D2DAAB97B04C2D5D65D7A002CE7ADE56A6DB061

file name: assemblies\IEDriverServer.exe
checksum type: SHA256
checksum: A1E26B0E8CB5F8DB1CD784BAC71BBF540485D81E697293B0B4586E25A31A8187

file name: assemblies\IEDriverServer.exe.sha256
checksum type: SHA256
checksum: E487929ABADCCDC39B295212F6FA49632463C2707FC51A4FD406394E8E5970A3

file name: assemblies\msedgedriver.exe
checksum type: SHA256
checksum: 509FFD6D321EF78C8319E68B89807D2437D8DB1718000FE2BB7ECACB1529730D

file name: assemblies\msedgedriver.exe.sha256
checksum type: SHA256
checksum: EFC53256B6BB3D081BDEC13F8BA8398BA999EC69701CD33EADE3C7D5437FE2A8

file name: assemblies\WebDriver.dll
checksum type: SHA256
checksum: 0EE619B1786CF5971C0F9C6EE1859497AECBA93A4953CF92FEA998E8EEFADF3C

file name: assemblies\WebDriver.dll.sha256
checksum type: SHA256
checksum: 7DAA46C412793A6590E03ED079CED7397C6F63005B3EF9D48F897F1E520FEA70

file name: assemblies\WebDriver.Support.dll
checksum type: SHA256
checksum: B59BA7D0CFFE43E722B13AD737CF596F030788B86B5B557CB479F0B6957CCE8A

file name: assemblies\WebDriver.Support.dll.sha256
checksum type: SHA256
checksum: FE5FAAE2D9AE96394020A7617929DAF3E355D8C656A6CB65F9912CA222D25CD8

file name: assemblies\linux\chromedriver
checksum type: SHA256
checksum: B561EFE1551F9CB45DDE6BBF804CA2BC06359415CDAC1B6B16556B095A55011F

file name: assemblies\linux\chromedriver.sha256
checksum type: SHA256
checksum: EF2B40C71F202B4FC5A81B19FF261FC99A54FB89A7AA3BC9B0FE2D4111CFEFEE

file name: assemblies\linux\geckodriver
checksum type: SHA256
checksum: 6590E3B9D9BF292C8DF50B6DF5BCF8A5191D999F9E48F68AA2055EB5746B2C05

file name: assemblies\linux\geckodriver.sha256
checksum type: SHA256
checksum: F1C6C148105997A73960BEC7498B2BBD3875AB6D1B18004880F99B4BCDC22939

file name: assemblies\macos\chromedriver
checksum type: SHA256
checksum: AD35D47CA5CD075939F7F6638188A56B648663D38A0719AF28B3F004BF95E0DD

file name: assemblies\macos\chromedriver.sha256
checksum type: SHA256
checksum: 6FD1760A76C04219E4B5A9382EBF9CB8200A03A555B5EDCAB5950D78D3807504

file name: assemblies\macos\geckodriver
checksum type: SHA256
checksum: D62C2178377ADDEB1BB860426B2C9B10B68D2EEABF0C521529A4A6A7B1E208C4

file name: assemblies\macos\geckodriver.sha256
checksum type: SHA256
checksum: B2F96FFF2033943087EF6066587D770C78604FF3EC7A29A735E6A30E8C66B418
46 changes: 46 additions & 0 deletions automatic/selenium.powershell/selenium.powershell.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>selenium.powershell</id>
<version>0.0.0</version>
<title>Selenium PowerShell Module</title>
<authors>Adam Driscoll</authors>
<owners>chocolatey-community</owners>
<licenseUrl>https://github.com/adamdriscoll/selenium-powershell/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/adamdriscoll/selenium-powershell</projectUrl>
<projectSourceUrl>https://github.com/adamdriscoll/selenium-powershell</projectSourceUrl>
<iconUrl>https://github.com/chocolatey-community/chocolatey-packages/blob/master/icons/selenium.powershell.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description><![CDATA[The Selenium PowerShell module allows you to automate browser interaction using the [Selenium API](https://selenium.dev/). You can navigate to pages, find elements, click buttons, enter text and even take screenshots.
## Features
- Wraps the C# WebDriver for Selenium
- Easily execute web-based tests
- Works well with Pester
## Package Parameters
The following package parameters can be set:
- `/core` - Installs the module in the AllUsers scope for PowerShell Core
- `/desktop` - Installs the module in the AllUsers scope for Windows PowerShell (ie. Desktop Edition)
To pass parameters, use `--params "''"` (e.g. `choco install selenium.powershell [other options] --params="'/Core'"`).
## Notes
- **If the package is out of date please check [Version History](#versionhistory) for the latest submitted version. If you have a question, please ask it in [Chocolatey Community Package Discussions](https://github.com/chocolatey-community/chocolatey-packages/discussions) or raise an issue on the [Chocolatey Community Packages Repository](https://github.com/chocolatey-community/chocolatey-packages/issues) if you have problems with the package. Disqus comments will generally not be responded to.**
]]></description>
<summary>Web automation using the Selenium Web Driver, via PowerShell.</summary>
<releaseNotes>https://github.com/adamdriscoll/selenium-powershell/releases</releaseNotes>
<copyright>Chromium and WebDriver teams. All Rights Reserved.</copyright>
<tags>selenium powershell addon foss cross-platform automation web module testing</tags>
<packageSourceUrl>https://github.com/chocolatey-community/chocolatey-packages/tree/master/automatic/selenium.powershell</packageSourceUrl>
<bugTrackerUrl>https://github.com/adamdriscoll/selenium-powershell/issues</bugTrackerUrl>
</metadata>
<files>
<file src="tools\**" target="tools" />
<file src="legal\**" target="legal" />
</files>
</package>
Empty file.
51 changes: 51 additions & 0 deletions automatic/selenium.powershell/tools/chocolateyInstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
$ErrorActionPreference = 'Stop'

$toolsDir = Split-Path -Parent $MyInvocation.MyCommand.Definition

$moduleName = "Selenium"
$moduleVersion = $env:ChocolateyPackageVersion

$sourcePath = Join-Path $toolsDir "$($moduleName).zip"
$savedPaths = Join-Path $ToolsDir 'installedpaths'

$destinationPath = switch ((Get-PackageParameters).Keys) {
"Core" {
Join-Path $env:ProgramFiles "PowerShell\Modules"
}
"Desktop" {
Join-Path $env:ProgramFiles "WindowsPowerShell\Modules"
}
}

# By default, install for Windows PowerShell
if (-not $destinationPath) {
$destinationPath = Join-Path $env:ProgramFiles "WindowsPowerShell\Modules"
}

$unzipArgs = @{
FileFullPath = $sourcePath
PackageName = $env:ChocolateyPackageName
}

$installedPaths = $destinationPath | ForEach-Object {
Write-Verbose "Installing '$moduleName' to '$_'"

# PS > 5 needs to extract to a versioned folder
$path = if ($PSVersionTable.PSVersion.Major -ge 5 -or $_ -notmatch 'Windows') {
Join-Path $_ "$($moduleName)\$($moduleVersion)"
} else {
Join-Path $_ "$($moduleName)"
}

if (-not (Test-Path $path)) {
$null = New-Item $path -ItemType Directory -Force
}

Get-ChocolateyUnzip @unzipArgs -Destination $path
}

# Cleanup the module from the Chocolatey $toolsDir folder
Remove-Item $sourcePath -Force -Recurse

# Store the installed locations, so we can remove them during uninstall
Set-Content $savedPaths -Value $installedPaths
28 changes: 28 additions & 0 deletions automatic/selenium.powershell/tools/chocolateyUninstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
$ErrorActionPreference = 'Stop'

$toolsDir = Split-Path -Parent $MyInvocation.MyCommand.Definition

$moduleName = "Selenium"
$moduleVersion = $env:ChocolateyPackageVersion
$savedPaths = Join-Path $toolsDir 'installedpaths'

$pathsToRemove = if (Test-Path $savedPaths) {
Get-Content $savedPaths
} elseif ($PSVersionTable.PSVersion.Major -ge 5) {
Join-Path $env:ProgramFiles "WindowsPowerShell\Modules\$($moduleName)\$($moduleVersion)"
} else {
Join-Path $env:ProgramFiles "WindowsPowerShell\Modules\$($moduleName)"
}

$pathsToRemove | ForEach-Object {
Write-Verbose "Removing '$moduleName' from '$_'."
try {
# First attempt to remove the DLLs. If they're loaded, then we shouldn't remove the rest of the module.
Get-ChildItem -Path $_ -Recurse -Include *.dll | Remove-Item -Force
Remove-Item -Path $_ -Recurse -Force
}
catch {
Write-Warning "We were unable to remove some of the files at $_. This generally means Selenium is currently loaded in a PowerShell session. Please close the PowerShell session it's loaded in and try again."
throw
}
}
63 changes: 63 additions & 0 deletions automatic/selenium.powershell/update.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
param(
[string]$ModuleName = 'Selenium'
)
Import-Module Chocolatey-AU

function global:au_SearchReplace {
@{
".\legal\VERIFICATION.txt" = @{
# Replace the module version on the Save-Module line
"(?i)(-RequiredVersion\s+).*" = "`${1}$($Latest.ModuleVersion)"
"(?i)(Selenium\\).*``" = "`${1}$($Latest.ModuleVersion)``"
}
}
}

function global:au_BeforeUpdate() {
# Get an unused directory
do {
$tempPath = Join-Path $env:TEMP "$([GUID]::NewGuid())"
}
while (Test-Path $tempPath)
$null = New-Item -Path $tempPath -ItemType Directory

# Save the module to the directory, and then compress the content into the package tools directory
Save-Module -Name $ModuleName -RequiredVersion $Latest.ModuleVersion -Path $tempPath

$archiveArgs = @{
Path = Join-Path $tempPath "\$ModuleName\$($Latest.ModuleVersion)\*"
DestinationPath = Join-Path $PSScriptRoot "\tools\$ModuleName.zip"
CompressionLevel = "Optimal"
Force = $true
}
Compress-Archive @archiveArgs

$Latest.ModuleChecksums = Get-ChildItem $archiveArgs.Path -Recurse -File | Get-FileHash

# Clean up the downloaded module
Remove-Item $tempPath -Recurse -Force -ErrorAction SilentlyContinue
}

function global:au_AfterUpdate {
$verificationFile = "$PSScriptRoot\legal\VERIFICATION.txt"
(Get-Content $verificationFile | Select-Object -First 16) | Set-Content -Path $verificationFile
@($Latest.ModuleChecksums.ForEach{
@(
" file name: $($_.Path -replace "^(?<BasePath>.+)\\Selenium\\$($Latest.ModuleVersion)\\")"
" checksum type: $($_.Algorithm)"
" checksum: $($_.Hash)"
"`n"
) -join "`n"
}) -join '' | Add-Content -Path $verificationFile -NoNewline
}

function global:au_GetLatest {
$version = (Find-Module -Name $ModuleName).Version.ToString()

@{
Version = $version
ModuleVersion = $version
}
}

update -ChecksumFor none
Binary file added icons/selenium.powershell.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5d965c8

Please sign in to comment.