├── .github └── workflows │ ├── build-test.yml │ └── release.yml ├── .gitignore ├── CI ├── CI.ps1 ├── Pester-To-XLSx.ps1 ├── RunTest.yml └── pipeline.yml ├── ChangeLog.md ├── Classes ├── PointTransformAttribute.ps1 ├── SeDriverConditionsCompleter.ps1 ├── SeDriverUserAgentCompleter.ps1 ├── SeDriverUserAgentTransformAttribute.ps1 ├── SeElementsConditionsCompleter.ps1 ├── SeMouseActionCompleter.ps1 ├── SeMouseClickActionCompleter.ps1 ├── SizeTransformAttribute.ps1 └── StringUrlTransformAttribute.ps1 ├── Debug ├── Debug.ps1 └── README.md ├── Examples ├── A-Simple-Google-Search.ps1 ├── Combined.tests.ps1 ├── Example.side ├── _TestDependencies.ps1 ├── comparison.ps1 └── test-seremote.ps1 ├── Help ├── Clear-SeAlert.md ├── Clear-SeSelectValue.md ├── ConvertTo-SeSelenium.md ├── Get-SeCookie.md ├── Get-SeDriver.md ├── Get-SeDriverTimeout.md ├── Get-SeElement.md ├── Get-SeElementAttribute.md ├── Get-SeElementCssValue.md ├── Get-SeFrame.md ├── Get-SeHtml.md ├── Get-SeInput.md ├── Get-SeKeys.md ├── Get-SeSelectValue.md ├── Get-SeUrl.md ├── Get-SeWindow.md ├── Invoke-SeClick.md ├── Invoke-SeJavascript.md ├── Invoke-SeKeys.md ├── Invoke-SeMouseAction.md ├── New-SeDriverOptions.md ├── New-SeDriverService.md ├── New-SeScreenshot.md ├── New-SeWindow.md ├── Pop-SeUrl.md ├── Push-SeUrl.md ├── README.MD ├── Remove-SeCookie.md ├── Remove-SeWindow.md ├── Save-SeScreenshot.md ├── SeShouldHave.md ├── Set-SeCookie.md ├── Set-SeDriverTimeout.md ├── Set-SeSelectValue.md ├── Set-SeUrl.md ├── Start-SeDriver.md ├── Start-SeRemote.md ├── Stop-SeDriver.md ├── Switch-SeDriver.md ├── Switch-SeFrame.md ├── Switch-SeWindow.md ├── Update-SeDriver.md ├── Wait-SeDriver.md └── Wait-SeElement.md ├── Internal ├── Disable-SeDriverImplicitTimeout.ps1 ├── Enable-SeDriverImplicitTimeout .ps1 ├── Get-DriverProcessId.ps1 ├── Get-OptionsSwitchValue.ps1 ├── Get-SeElementsConditionsValueType.ps1 ├── Get-WildcardsIndices.ps1 ├── Init-SeDriver.ps1 ├── Start-SeChromeDriver.ps1 ├── Start-SeEdgeDriver.ps1 ├── Start-SeFirefoxDriver.ps1 ├── Start-SeInternetExplorerDriver.ps1 ├── Start-SeMSEdgeDriver.ps1 ├── Test-SeDriverAcceptInsecureCertificates.ps1 ├── Test-SeDriverConditionsValueValidation.ps1 ├── Test-SeDriverUserAgent.ps1 ├── Test-SeElementConditionsValueValidation.ps1 ├── Test-SeMouseActionValueValidation.ps1 └── init.ps1 ├── LICENSE ├── Output └── Selenium │ ├── ChangeLog.md │ ├── Examples │ ├── A-Simple-Google-Search.ps1 │ ├── Combined.tests.ps1 │ ├── Example.side │ ├── _TestDependencies.ps1 │ ├── comparison.ps1 │ └── test-seremote.ps1 │ ├── README.md │ ├── Selenium-Binary-Updater.ps1 │ ├── Selenium.psd1 │ ├── Selenium.psm1 │ ├── Selenium.tests.ps1 │ ├── SeleniumClasses.ps1 │ ├── assemblies │ ├── IEDriverServer.exe │ ├── IEDriverServer.exe.sha256 │ ├── WebDriver.Support.dll │ ├── WebDriver.Support.dll.sha256 │ ├── WebDriver.dll │ ├── WebDriver.dll.sha256 │ ├── chromedriver.exe │ ├── chromedriver.exe.sha256 │ ├── geckodriver.exe │ ├── geckodriver.exe.sha256 │ ├── linux │ │ ├── chromedriver │ │ ├── chromedriver.sha256 │ │ ├── geckodriver │ │ └── geckodriver.sha256 │ ├── macos │ │ ├── chromedriver │ │ ├── chromedriver.sha256 │ │ ├── geckodriver │ │ └── geckodriver.sha256 │ ├── msedgedriver.exe │ └── msedgedriver.exe.sha256 │ ├── en-US │ └── Selenium-help.xml │ ├── formats │ └── Selenium.format.ps1xml │ └── types │ └── Selenium.types.ps1xml ├── Public ├── Clear-SeAlert.ps1 ├── Clear-SeSelectValue.ps1 ├── ConvertTo-SeSelenium.ps1 ├── Get-SeCookie.ps1 ├── Get-SeDriver.ps1 ├── Get-SeDriverTimeout.ps1 ├── Get-SeElement.ps1 ├── Get-SeElementAttribute.ps1 ├── Get-SeElementCssValue.ps1 ├── Get-SeFrame.ps1 ├── Get-SeHtml.ps1 ├── Get-SeInput.ps1 ├── Get-SeKeys.ps1 ├── Get-SeSelectValue.ps1 ├── Get-SeUrl.ps1 ├── Get-SeWindow.ps1 ├── Invoke-SeClick.ps1 ├── Invoke-SeJavascript.ps1 ├── Invoke-SeKeys.ps1 ├── Invoke-seMouseAction.ps1 ├── New-SeDriverOptions.ps1 ├── New-SeDriverService.ps1 ├── New-SeScreenshot.ps1 ├── New-SeWindow.ps1 ├── Pop-SeUrl.ps1 ├── Push-SeUrl.ps1 ├── Remove-SeCookie.ps1 ├── Remove-SeWindow.ps1 ├── Save-SeScreenshot.ps1 ├── SeShouldHave.ps1 ├── Set-SeCookie.ps1 ├── Set-SeDriverTimeout.ps1 ├── Set-SeSelectValue.ps1 ├── Set-SeUrl.ps1 ├── Start-SeDriver.ps1 ├── Start-SeRemote.ps1 ├── Stop-SeDriver.ps1 ├── Switch-SeDriver.ps1 ├── Switch-SeFrame.ps1 ├── Switch-SeWindow.ps1 ├── Update-SeDriver.ps1 ├── Wait-SeDriver.ps1 └── Wait-SeElement.ps1 ├── README.md ├── Selenium-Binary-Updater.ps1 ├── Selenium.EzFormat.ps1 ├── Selenium.build.ps1 ├── Selenium.psd1 ├── Selenium.psm1 ├── Selenium.tests.ps1 ├── SeleniumClasses.ps1 ├── Tests └── selenium-powershell.tests.ps1 ├── Views └── SeSelectValueInfo.ps1xml ├── assemblies ├── IEDriverServer.exe ├── IEDriverServer.exe.sha256 ├── WebDriver.Support.dll ├── WebDriver.Support.dll.sha256 ├── WebDriver.dll ├── WebDriver.dll.sha256 ├── chromedriver.exe ├── chromedriver.exe.sha256 ├── geckodriver.exe ├── geckodriver.exe.sha256 ├── linux │ ├── chromedriver │ ├── chromedriver.sha256 │ ├── geckodriver │ └── geckodriver.sha256 ├── macos │ ├── chromedriver │ ├── chromedriver.sha256 │ ├── geckodriver │ └── geckodriver.sha256 ├── msedgedriver.exe └── msedgedriver.exe.sha256 ├── formats └── Selenium.format.ps1xml └── types └── Selenium.Types.ps1xml /.github/workflows/build-test.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ${{ matrix.os }} 9 | strategy: 10 | matrix: 11 | os: [ubuntu-latest, windows-latest, macOS-latest] 12 | 13 | steps: 14 | - uses: actions/checkout@v1 15 | - name: Run a one-line script 16 | run: | 17 | pwsh -Command "Install-Module Pester -Force -Scope CurrentUser" 18 | pwsh ./Selenium.tests.ps1 19 | 20 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | release: 5 | types: [published] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | env: 11 | ApiKey: ${{ secrets.API_KEY }} 12 | 13 | steps: 14 | - uses: actions/checkout@v1 15 | - name: Publish 16 | run: | 17 | pwsh -Command "Publish-Module -Path ${{ github.workspace }}/Output/Selenium/ -NuGetApiKey ${{secrets.API_KEY}}" 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | CI/LocalPostProcessing.ps1 3 | Scratchpad.ps1 4 | Output/testResults*.xml 5 | Output/stats.json 6 | debug.log 7 | -------------------------------------------------------------------------------- /CI/RunTest.yml: -------------------------------------------------------------------------------- 1 | # https://aka.ms/yaml 2 | 3 | parameters: 4 | - name: Browser 5 | type: string 6 | values: 7 | - Chrome 8 | - Edge 9 | - Firefox 10 | - InternetExplorer 11 | - MSEdge 12 | - name: OS 13 | type: string 14 | default: ubuntu 15 | values: 16 | - ubuntu 17 | - windows 18 | - name: Stack 19 | type: string 20 | default: pwsh 21 | values: 22 | - powershell 23 | - pwsh 24 | 25 | jobs: 26 | - job: "${{ parameters.OS }}_${{ parameters.Browser }}_${{ parameters.Stack }}" 27 | displayName: "${{ parameters.Browser }} - ${{ parameters.OS }} (${{ parameters.Stack }})" 28 | pool: 29 | vmImage: "${{ parameters.OS }}-latest" 30 | steps: 31 | - checkout: none 32 | - task: DownloadPipelineArtifact@2 33 | inputs: 34 | artifactName: "dependencies_pwsh" 35 | #artifactName: "dependencies_${{ parameters.Stack }}" 36 | - task: DownloadPipelineArtifact@2 37 | inputs: 38 | artifactName: "checkout" 39 | - ${{ if eq(parameters.Stack, 'Powershell') }}: 40 | - powershell: "$(Pipeline.Workspace)/CI/CI.ps1 -ModulePath '$(Pipeline.Workspace)' -browserlist ${{ parameters.Browser }}" 41 | displayName: "Run ${{ parameters.Browser }} Test on ${{ parameters.OS }} (ps)" 42 | - ${{ if eq(parameters.Stack, 'pwsh') }}: 43 | - pwsh: "$(Pipeline.Workspace)/CI/CI.ps1 -ModulePath '$(Pipeline.Workspace)' -browserlist ${{ parameters.Browser }}" 44 | displayName: "Run ${{ parameters.Browser }} Test on ${{ parameters.OS }} (pwsh)" 45 | - task: PublishPipelineArtifact@1 46 | inputs: 47 | targetPath: "$(Build.ArtifactStagingDirectory)/results" 48 | artifact: "${{ parameters.OS }} - ${{ parameters.Browser }} - ${{ parameters.Stack }} Results" 49 | - task: PublishTestResults@2 50 | condition: succeededOrFailed() 51 | inputs: 52 | testResultsFormat: "NUnit" 53 | testResultsFiles: "$(Pipeline.Workspace)/testResults.xml" 54 | failTaskOnFailedTests: true 55 | -------------------------------------------------------------------------------- /Classes/PointTransformAttribute.ps1: -------------------------------------------------------------------------------- 1 | class PointTransformAttribute : System.Management.Automation.ArgumentTransformationAttribute { 2 | # Implement the Transform() method 3 | [object] Transform([System.Management.Automation.EngineIntrinsics]$engineIntrinsics, [object] $inputData) { 4 | <# 5 | The parameter value(s) are passed in here as $inputData. We aren't accepting array input 6 | for our function, but it's good to make these fairly versatile where possible, so that 7 | you can reuse them easily! 8 | #> 9 | $outputData = switch ($inputData) { 10 | { $_ -is [PointTransformAttribute] } { $_ } 11 | { $_ -is [int] } { [System.Drawing.Point]::new($_, $_) } 12 | { $_ -is [string] -and (($_ -split '[,x]').count -eq 2) } { 13 | $sp = $_ -split '[,x]' 14 | [System.Drawing.Point]::new($sp[0], $sp[1]) 15 | } 16 | default { 17 | # If we hit something we can't convert, throw an exception 18 | throw [System.Management.Automation.ArgumentTransformationMetadataException]::new( 19 | "Could not convert input '$_' to a valid Point object." 20 | ) 21 | } 22 | } 23 | 24 | return $OutputData 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /Classes/SeDriverConditionsCompleter.ps1: -------------------------------------------------------------------------------- 1 | $Script:SeDriverConditions = @( 2 | [PSCustomObject]@{Text = 'AlertState'; ValueType = [bool]; Tooltip = "A value indicating whether or not an alert should be displayed in order to meet this condition." } 3 | [PSCustomObject]@{Text = 'ScriptBlock'; ValueType = [ScriptBlock]; Tooltip = "A scriptblock to be evaluated." } 4 | [PSCustomObject]@{Text = 'TitleContains'; ValueType = [String]; Tooltip = "An expectation for checking that the title of a page contains a case-sensitive substring." } 5 | [PSCustomObject]@{Text = 'TitleIs'; ValueType = [String]; Tooltip = "An expectation for checking the title of a page." } 6 | [PSCustomObject]@{Text = 'UrlContains'; ValueType = [String]; Tooltip = "An expectation for the URL of the current page to be a specific URL." } 7 | [PSCustomObject]@{Text = 'UrlMatches'; ValueType = [String]; Tooltip = "An expectation for the URL of the current page to be a specific URL." } 8 | [PSCustomObject]@{Text = 'UrlToBe'; ValueType = [String]; Tooltip = "An expectation for the URL of the current page to be a specific URL." } 9 | ) 10 | 11 | class SeDriverConditionsCompleter : System.Management.Automation.IArgumentCompleter { 12 | [System.Collections.Generic.IEnumerable[System.Management.Automation.CompletionResult]] CompleteArgument( 13 | [string] $CommandName , 14 | [string] $ParameterName, 15 | [string] $WordToComplete, 16 | [System.Management.Automation.Language.CommandAst] $CommandAst, 17 | [system.Collections.IDictionary] $FakeBoundParameters 18 | ) { 19 | $wildcard = ("*" + $wordToComplete + "*") 20 | $CompletionResults = [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new() 21 | 22 | $Script:SeDriverConditions.where( { $_.Text -like $wildcard }) | 23 | ForEach-Object { 24 | $Valuetype = $_.ValueType 25 | if ($null -eq $ValueType) { $Valuetype = 'None' } 26 | $pvalue = [System.Management.Automation.CompletionResultType]::ParameterValue 27 | $CompletionResults.Add(([System.Management.Automation.CompletionResult]::new($_.Text, $_.Text, $pvalue, "Value: $ValueType`n$($_.Tooltip)") ) ) 28 | } 29 | return $CompletionResults 30 | } 31 | } -------------------------------------------------------------------------------- /Classes/SeDriverUserAgentCompleter.ps1: -------------------------------------------------------------------------------- 1 | class SeDriverUserAgentCompleter : System.Management.Automation.IArgumentCompleter { 2 | [System.Collections.Generic.IEnumerable[System.Management.Automation.CompletionResult]] CompleteArgument( 3 | [string] $CommandName , 4 | [string] $ParameterName, 5 | [string] $WordToComplete, 6 | [System.Management.Automation.Language.CommandAst] $CommandAst, 7 | [system.Collections.IDictionary] $FakeBoundParameters 8 | ) { 9 | $CompletionResults = [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new() 10 | 11 | $pvalue = [System.Management.Automation.CompletionResultType]::ParameterValue 12 | 13 | [System.Collections.Generic.List[PSObject]]$Predefined = 14 | [Microsoft.PowerShell.Commands.PSUserAgent].GetProperties() | 15 | Select-Object Name, @{n = 'UserAgent'; e = { [Microsoft.PowerShell.Commands.PSUserAgent]::$($_.Name) } } 16 | 17 | $Predefined.Add([PSCustomObject]@{Name = 'Android'; UserAgent = 'Android' }) 18 | $Predefined.Add([PSCustomObject]@{Name = 'Iphone'; UserAgent = 'Iphone' }) 19 | 20 | $Predefined | 21 | ForEach-Object { 22 | $CompletionResults.Add(([System.Management.Automation.CompletionResult]::new($_.Name, $_.Name, $pvalue, $_.UserAgent) ) ) 23 | } 24 | return $CompletionResults 25 | } 26 | } -------------------------------------------------------------------------------- /Classes/SeDriverUserAgentTransformAttribute.ps1: -------------------------------------------------------------------------------- 1 | class SeDriverUserAgentTransformAttribute : System.Management.Automation.ArgumentTransformationAttribute { 2 | # Implement the Transform() method 3 | [object] Transform([System.Management.Automation.EngineIntrinsics]$engineIntrinsics, [object] $inputData) { 4 | <# 5 | The parameter value(s) are passed in here as $inputData. We aren't accepting array input 6 | for our function, but it's good to make these fairly versatile where possible, so that 7 | you can reuse them easily! 8 | #> 9 | $outputData = switch ($inputData) { 10 | { $_ -is [string] } { 11 | $output = [Microsoft.PowerShell.Commands.PSUserAgent]::$_ 12 | if ($null -ne $output) { $output } else { $_ } 13 | } 14 | default { 15 | # If we hit something we can't convert, throw an exception 16 | throw [System.Management.Automation.ArgumentTransformationMetadataException]::new( 17 | "Only String attributes are supported." 18 | ) 19 | } 20 | } 21 | 22 | return $OutputData 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /Classes/SeElementsConditionsCompleter.ps1: -------------------------------------------------------------------------------- 1 | $Script:SeElementsConditions = @( 2 | [PSCustomObject]@{Text = 'ElementExists'; ValueType = $null; By_Element = 1; Tooltip = 'An expectation for checking that an element is present on the DOM of a page. This does not necessarily mean that the element is visible.' } 3 | [PSCustomObject]@{Text = 'ElementIsVisible'; ValueType = $null; By_Element = 1; Tooltip = 'An expectation for checking that an element is present on the DOM of a page and visible. Visibility means that the element is not only displayed but also has a height and width that is greater than 0.' } 4 | [PSCustomObject]@{Text = 'ElementToBeSelected'; ValueType = [bool]; By_Element = 0; Tooltip = 'An expectation for checking if the given element is selected.' } 5 | [PSCustomObject]@{Text = 'InvisibilityOfElementLocated'; ValueType = [bool]; By_Element = 1; Tooltip = 'An expectation for checking that an element is either invisible or not present on the DOM.' } 6 | [PSCustomObject]@{Text = 'ElementToBeClickable'; ValueType = $null; By_Element = 0; Tooltip = 'An expectation for checking an element is visible and enabled such that you can click it.' } 7 | [PSCustomObject]@{Text = 'InvisibilityOfElementWithText'; ValueType = [string]; By_Element = 1; Tooltip = 'An expectation for checking that an element with text is either invisible or not present on the DOM.' } 8 | [PSCustomObject]@{Text = 'PresenceOfAllElementsLocatedBy'; ValueType = $null; By_Element = 1; Tooltip = 'An expectation for checking that all elements present on the web page that match the locator.' } 9 | [PSCustomObject]@{Text = 'TextToBePresentInElement'; ValueType = [string]; By_Element = 2; Tooltip = 'An expectation for checking if the given text is present in the specified element.' } 10 | [PSCustomObject]@{Text = 'TextToBePresentInElementValue'; ValueType = [string]; By_Element = 0; Tooltip = 'An expectation for checking if the given text is present in the specified elements value attribute.' } 11 | [PSCustomObject]@{Text = 'StalenessOf'; ValueType = $null; By_Element = 2; Tooltip = 'Wait until an element is no longer attached to the DOM.' } 12 | ) 13 | 14 | class SeElementsConditionsCompleter : System.Management.Automation.IArgumentCompleter { 15 | [System.Collections.Generic.IEnumerable[System.Management.Automation.CompletionResult]] CompleteArgument( 16 | [string] $CommandName , 17 | [string] $ParameterName, 18 | [string] $WordToComplete, 19 | [System.Management.Automation.Language.CommandAst] $CommandAst, 20 | [system.Collections.IDictionary] $FakeBoundParameters 21 | ) { 22 | $wildcard = ("*" + $wordToComplete + "*") 23 | $CompletionResults = [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new() 24 | 25 | $pvalue = [System.Management.Automation.CompletionResultType]::ParameterValue 26 | $SearchBy = 0 27 | switch ($true) { 28 | { $fakeBoundParameters.ContainsKey('By') } { $SearchBy = 1; break } 29 | { $fakeBoundParameters.ContainsKey('Element') } { $SearchBy = 2; break } 30 | } 31 | $Script:SeElementsConditions.where( { $_.Text -like $wildcard -and $_.By_Element -in @(0, $SearchBy) }) | 32 | ForEach-Object { 33 | $Valuetype = $_.ValueType 34 | if ($null -eq $ValueType) { $Valuetype = 'None' } 35 | $CompletionResults.Add(([System.Management.Automation.CompletionResult]::new($_.Text, $_.Text, $pvalue, "Value: $ValueType`n$($_.Tooltip)") ) ) 36 | } 37 | return $CompletionResults 38 | } 39 | } -------------------------------------------------------------------------------- /Classes/SeMouseActionCompleter.ps1: -------------------------------------------------------------------------------- 1 | class SeMouseActionCompleter : System.Management.Automation.IArgumentCompleter { 2 | [System.Collections.Generic.IEnumerable[System.Management.Automation.CompletionResult]] CompleteArgument( 3 | [string] $CommandName , 4 | [string] $ParameterName, 5 | [string] $WordToComplete, 6 | [System.Management.Automation.Language.CommandAst] $CommandAst, 7 | [system.Collections.IDictionary] $FakeBoundParameters 8 | ) { 9 | $wildcard = ("*" + $wordToComplete + "*") 10 | $CompletionResults = [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new() 11 | 12 | $pvalue = [System.Management.Automation.CompletionResultType]::ParameterValue 13 | 14 | $Script:SeMouseAction.where( { $_.Text -like $wildcard }) | 15 | ForEach-Object { 16 | $Valuetype = $_.ValueType 17 | if ($null -eq $ValueType) { $Valuetype = 'None' } 18 | $ElementRequired = 'N/A' 19 | switch ($_.ElementRequired) { 20 | $true { $ElementRequired = 'Required' } 21 | $false { $ElementRequired = 'Optional' } 22 | } 23 | 24 | 25 | $CompletionResults.Add(([System.Management.Automation.CompletionResult]::new($_.Text, $_.Text, $pvalue, "Element: $ElementRequired`nValue: $ValueType`n$($_.Tooltip)") ) ) 26 | } 27 | return $CompletionResults 28 | } 29 | } -------------------------------------------------------------------------------- /Classes/SeMouseClickActionCompleter.ps1: -------------------------------------------------------------------------------- 1 | $Script:SeMouseClickAction = @( 2 | New-Condition -Text 'Click' -Tooltip 'Clicks the mouse on the specified element.' 3 | New-Condition -Text 'Click_JS' -ElementRequired $true -Tooltip 'Clicks the mouse on the specified element using Javascript.' 4 | New-Condition -Text 'ClickAndHold' -Tooltip 'Clicks and holds the mouse button down on the specified element.' 5 | New-Condition -Text 'ContextClick' -Tooltip 'Right-clicks the mouse on the specified element.' 6 | New-Condition -Text 'DoubleClick' -Tooltip 'Double-clicks the mouse on the specified element.' 7 | New-Condition -Text 'Release' -Tooltip 'Releases the mouse button at the last known mouse coordinates or specified element.' 8 | ) 9 | 10 | class SeMouseClickActionCompleter : System.Management.Automation.IArgumentCompleter { 11 | [System.Collections.Generic.IEnumerable[System.Management.Automation.CompletionResult]] CompleteArgument( 12 | [string] $CommandName , 13 | [string] $ParameterName, 14 | [string] $WordToComplete, 15 | [System.Management.Automation.Language.CommandAst] $CommandAst, 16 | [system.Collections.IDictionary] $FakeBoundParameters 17 | ) { 18 | $wildcard = ("*" + $wordToComplete + "*") 19 | $CompletionResults = [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new() 20 | $pvalue = [System.Management.Automation.CompletionResultType]::ParameterValue 21 | 22 | 23 | $Script:SeMouseClickAction.where( { $_.Text -like $wildcard }) | 24 | ForEach-Object { 25 | $Valuetype = $_.ValueType 26 | if ($null -eq $ValueType) { $Valuetype = 'None' } 27 | $CompletionResults.Add(([System.Management.Automation.CompletionResult]::new($_.Text, $_.Text, $pvalue, $_.Tooltip) ) ) 28 | } 29 | return $CompletionResults 30 | } 31 | } -------------------------------------------------------------------------------- /Classes/SizeTransformAttribute.ps1: -------------------------------------------------------------------------------- 1 | class SizeTransformAttribute : System.Management.Automation.ArgumentTransformationAttribute { 2 | # Implement the Transform() method 3 | [object] Transform([System.Management.Automation.EngineIntrinsics]$engineIntrinsics, [object] $inputData) { 4 | <# 5 | The parameter value(s) are passed in here as $inputData. We aren't accepting array input 6 | for our function, but it's good to make these fairly versatile where possible, so that 7 | you can reuse them easily! 8 | #> 9 | $outputData = switch ($inputData) { 10 | { $_ -is [SizeTransformAttribute] } { $_ } 11 | { $_ -is [int] } { [System.Drawing.Size]::new($_, $_) } 12 | { $_ -is [string] -and (($_ -split '[,x]').count -eq 2) } { 13 | $sp = $_ -split '[,x]' 14 | [System.Drawing.Size]::new($sp[0], $sp[1]) 15 | } 16 | default { 17 | # If we hit something we can't convert, throw an exception 18 | throw [System.Management.Automation.ArgumentTransformationMetadataException]::new( 19 | "Could not convert input '$_' to a valid Size object." 20 | ) 21 | } 22 | } 23 | 24 | return $OutputData 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /Classes/StringUrlTransformAttribute.ps1: -------------------------------------------------------------------------------- 1 | class StringUrlTransformAttribute : System.Management.Automation.ArgumentTransformationAttribute { 2 | # Implement the Transform() method 3 | [object] Transform([System.Management.Automation.EngineIntrinsics]$engineIntrinsics, [object] $inputData) { 4 | <# 5 | The parameter value(s) are passed in here as $inputData. We aren't accepting array input 6 | for our function, but it's good to make these fairly versatile where possible, so that 7 | you can reuse them easily! 8 | #> 9 | $outputData = switch ($inputData) { 10 | { $_ -is [string] } { 11 | if ($_ -match '://') { 12 | $_ 13 | } 14 | else { 15 | "https://$_" 16 | } 17 | } 18 | default { 19 | # If we hit something we can't convert, throw an exception 20 | throw [System.Management.Automation.ArgumentTransformationMetadataException]::new( 21 | "Only String attributes are supported." 22 | ) 23 | } 24 | } 25 | 26 | return $OutputData 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /Debug/Debug.ps1: -------------------------------------------------------------------------------- 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 | 14 | # CI tests 15 | . $ProjectPath\CI\CI.ps1 -browserlist Chrome, Firefox 16 | 17 | # Build module 18 | Get-Module pester | Remove-Module; Import-Module pester -RequiredVersion 4.10.1 19 | invoke-build -File "$ProjectPath\Selenium.build.ps1" 20 | 21 | 22 | # Documentation update only 23 | Update-MarkdownHelpModule -Path "$ProjectPath\Help" -ModulePagePath "$ProjectPath\Help\README.MD" -RefreshModulePage -Verbose 24 | 25 | #Tests 26 | #Invoke-Pester -Script 'C:\Github\selenium-powershell\Examples\Combined.tests.ps1' 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Debug/README.md: -------------------------------------------------------------------------------- 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. -------------------------------------------------------------------------------- /Examples/_TestDependencies.ps1: -------------------------------------------------------------------------------- 1 | 2 | Function Get-DefaultParams() { 3 | if ($null -eq $Global:DefaultBrowser) { $Global:DefaultBrowser = 'Firefox' } 4 | if ($null -eq $env:SITE_URL) { $env:SITE_URL = 'http://tailspin-spacegame-web.azurewebsites.net' } 5 | if ($null -eq $Global:HeadlessOnly) { $Global:HeadlessOnly = $False } 6 | } 7 | Get-DefaultParams 8 | 9 | 10 | Function Get-TestCasesSettings() { 11 | $HeadlessState = if ($Global:HeadlessOnly) { 'Headless' } else { 'Maximized' } 12 | return @{ 13 | 'NewEdge' = @{ 14 | DefaultOptions = @{State = $HeadlessState } 15 | PrivateOptions = @{ 16 | PrivateBrowsing = $true 17 | State = $HeadlessState 18 | } 19 | # InPrivateLabel = 'InPrivate' 20 | } # broken after build 79 of web driver#> 21 | 'Chrome' = @{ 22 | PrivateOptions = @{ 23 | PrivateBrowsing = $true 24 | State = $HeadlessState 25 | } 26 | DefaultOptions = @{State = $HeadlessState } 27 | HeadlessOptions = @{State = 'Headless' } 28 | } 29 | 'Firefox' = @{ 30 | PrivateOptions = @{ 31 | PrivateBrowsing = $true 32 | State = $HeadlessState 33 | } 34 | DefaultOptions = @{State = $HeadlessState } 35 | HeadlessOptions = @{State = 'Headless' } 36 | } 37 | 'MSEdge' = @{ 38 | DefaultOptions = @{State = $HeadlessState } 39 | PrivateOptions = @{PrivateBrowsing = $true } 40 | } 41 | 'InternetExplorer' = @{ 42 | DefaultOptions = @{ImplicitWait = 30 } 43 | PrivateOptions = @{ImplicitWait = 30 } 44 | } 45 | } 46 | } 47 | 48 | function Build-StringFromHash { 49 | param ($Hash) 50 | $(foreach ($k in $Hash.Keys) { "$K`:$($hash[$K])" }) -join '; ' 51 | } 52 | 53 | 54 | 55 | function Get-ModalTestCases() { 56 | return @( 57 | @{Name = 'Download Page' 58 | linkXPath = '/html/body/div/div/section[2]/div[2]/a' 59 | modalXPath = '//*[@id="pretend-modal"]/div/div' 60 | }, 61 | @{Name = 'Screen Image' 62 | linkXPath = '/html/body/div/div/section[3]/div/ul/li[1]/a' 63 | modalXPath = '/html/body/div[1]/div/div[2]' 64 | }, 65 | @{Name = 'Top Player' 66 | linkXPath = '/html/body/div/div/section[4]/div/div/div[1]/div[2]/div[2]/div/a/div' 67 | modalXPath = '//*[@id="profile-modal-1"]/div/div' 68 | } 69 | ) 70 | } 71 | -------------------------------------------------------------------------------- /Examples/comparison.ps1: -------------------------------------------------------------------------------- 1 | 2 | <# 3 | public void testClass() throws Exception { 4 | driver.get("http://www.wikipedia.org/") ; 5 | Assert.assertequals("wikipedia", driver.getTitle()); 6 | Assert.assertequals("English", driver.findElement(By.cssselector("strong")).getText()) 7 | driver.findElement(By.cssSetector("strong")).click() ; 8 | Assert.assertEquals("Wikipedia. the free encyclopedia", driver.getTitle()); 9 | } 10 | #> 11 | Start-SeDriver -Browser Chrome -StartURL "https://www.wikipedia.org/" 12 | SeShouldHave -Title eq Wikipedia 13 | SeShouldHave 'strong' -By CssSelector -With Text eq 'English' -PassThru | Invoke-SeClick 14 | SeShouldHave -Title eq 'Wikipedia, the free encyclopedia' 15 | 16 | <# 17 | line 2 ## SeShouldHave -Title eq Wikipedia 18 | is actutally short for ## SeShouldHave -Title -Operator 'eq' -Value Wikipedia 19 | other values for -operator will translate to "eq", and parameters are defined so you can use -eq -contains, -match etc 20 | so you can use ## SeShouldHave -Title equalTo Wikipedia 21 | or ## SeShouldHave -Title -eq Wikipedia 22 | line 3 ## SeShouldHave 'strong' -By CssSelector Text eq 'English' 23 | This is short for ## SeShouldHave -Selection 'strong' -By CssSelector -With Text -operator "eq" -value 'English' 24 | if the selector is an xPath the -By parameter can be omitted; but if used -By must specified explicitly 25 | The first unnamed parameter will be treated as selection, the second as "with" , the third as operator and the fourth as value. 26 | SeShouldhave can take a -passthru parameter allowing the original lines 3 and 4 to be merged, 27 | 28 | The last line 5 is similar to line 2 but the parameter value has a sppace so must be wrapped in quotes 29 | #> 30 | 31 | <#https://www.guru99.com/first-webdriver-script.html had this 32 | public static void main(String[] args) { 33 | System.setProperty("webdriver.gecko.driver","C:\\geckodriver.exe"); 34 | WebDriver driver = new FirefoxDriver(); 35 | //comment the above 2 lines and uncomment below 2 lines to use Chrome 36 | //System.setProperty("webdriver.chrome.driver","G:\\chromedriver.exe"); 37 | //WebDriver driver = new ChromeDriver(); 38 | 39 | String baseUrl = "http://demo.guru99.com/test/newtours/"; 40 | driver.get(baseUrl); 41 | 42 | String expectedTitle = "Welcome: Mercury Tours"; 43 | String actualTitle = ""; 44 | actualTitle = driver.getTitle(); 45 | if (actualTitle.contentEquals(expectedTitle)){ 46 | System.out.println("Test Passed!"); 47 | } else { 48 | System.out.println("Test Failed"); 49 | } 50 | 51 | driver.close(); 52 | } 53 | #> 54 | 55 | Start-SeDriver -Browser Firefox -StartURL "http://demo.guru99.com/test/newtours/" 56 | SeShouldHave -Title eq "Welcome: Mercury Tours" 57 | 58 | #Stop opened drivers 59 | Get-SeDriver | Stop-SeDriver 60 | 61 | -------------------------------------------------------------------------------- /Help/Clear-SeAlert.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Clear-SeAlert 9 | 10 | ## SYNOPSIS 11 | Clear alert popup by dismissing or accepting it. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Clear-SeAlert [-Action ] [-Alert ] [-PassThru] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Clear alert popup by dismissing or accepting it. 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> Clear-SeAlert -Action Dismiss 27 | ``` 28 | 29 | Dismiss an alert on the currently selected driver. 30 | 31 | ## PARAMETERS 32 | 33 | ### -Action 34 | Action to be performed on the alert popup 35 | 36 | ```yaml 37 | Type: Object 38 | Parameter Sets: (All) 39 | Aliases: 40 | Accepted values: Accept, Dismiss 41 | 42 | Required: False 43 | Position: Named 44 | Default value: None 45 | Accept pipeline input: False 46 | Accept wildcard characters: False 47 | ``` 48 | 49 | ### -Alert 50 | Specify alert window. Seems to be ignored in favor of Target / Default Target. 51 | 52 | ```yaml 53 | Type: Object 54 | Parameter Sets: (All) 55 | Aliases: 56 | 57 | Required: False 58 | Position: Named 59 | Default value: None 60 | Accept pipeline input: True (ByValue) 61 | Accept wildcard characters: False 62 | ``` 63 | 64 | ### -PassThru 65 | Return Alert object. 66 | 67 | ```yaml 68 | Type: SwitchParameter 69 | Parameter Sets: (All) 70 | Aliases: 71 | 72 | Required: False 73 | Position: Named 74 | Default value: None 75 | Accept pipeline input: False 76 | Accept wildcard characters: False 77 | ``` 78 | 79 | ### CommonParameters 80 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 81 | 82 | ## INPUTS 83 | 84 | ### System.Object 85 | 86 | ## OUTPUTS 87 | 88 | ### System.Object 89 | ## NOTES 90 | 91 | ## RELATED LINKS 92 | -------------------------------------------------------------------------------- /Help/Clear-SeSelectValue.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Clear-SeSelectValue 9 | 10 | ## SYNOPSIS 11 | Clear all selected entries of a SELECT element. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Clear-SeSelectValue [-Element] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Clear all selected entries of a SELECT element. 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> Clear-SeSelectValue -Element $Select 27 | ``` 28 | 29 | Clear the selected value from the specified SELECT element. 30 | 31 | ## PARAMETERS 32 | 33 | ### -Element 34 | Target IWebElement 35 | 36 | ```yaml 37 | Type: IWebElement 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: True 42 | Position: 0 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### CommonParameters 49 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 50 | 51 | ## INPUTS 52 | 53 | ### None 54 | 55 | ## OUTPUTS 56 | 57 | ### System.Object 58 | ## NOTES 59 | 60 | ## RELATED LINKS 61 | -------------------------------------------------------------------------------- /Help/ConvertTo-SeSelenium.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # ConvertTo-Selenium 9 | 10 | ## SYNOPSIS 11 | Convert Selenium IDE .side recording file to PowerShell commands. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | ConvertTo-Selenium [-Path] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Convert Selenium IDE .side recording file to PowerShell commands. 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### -Path 34 | Path to .side file. 35 | 36 | ```yaml 37 | Type: String 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: True 42 | Position: 1 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### CommonParameters 49 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 50 | 51 | ## INPUTS 52 | 53 | ## OUTPUTS 54 | 55 | ## NOTES 56 | 57 | ## RELATED LINKS 58 | -------------------------------------------------------------------------------- /Help/Get-SeCookie.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-SeCookie 9 | 10 | ## SYNOPSIS 11 | List all cookies 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-SeCookie [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | List all cookies 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> Get-SeCookie 27 | ``` 28 | 29 | List all cookies of the default webdriver 30 | 31 | ## PARAMETERS 32 | 33 | ### CommonParameters 34 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 35 | 36 | ## INPUTS 37 | 38 | ### System.Object 39 | 40 | ## OUTPUTS 41 | 42 | ### System.Object 43 | ## NOTES 44 | 45 | ## RELATED LINKS 46 | -------------------------------------------------------------------------------- /Help/Get-SeDriver.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-SeDriver 9 | 10 | ## SYNOPSIS 11 | Get the list of all active drivers. 12 | 13 | ## SYNTAX 14 | 15 | ### All (Default) 16 | ``` 17 | Get-SeDriver [] 18 | ``` 19 | 20 | ### Current 21 | ``` 22 | Get-SeDriver [-Current] [] 23 | ``` 24 | 25 | ### ByName 26 | ``` 27 | Get-SeDriver [[-Name] ] [] 28 | ``` 29 | 30 | ### ByBrowser 31 | ``` 32 | Get-SeDriver [-Browser ] [] 33 | ``` 34 | 35 | ## DESCRIPTION 36 | Get the list of all active drivers or drivers matching the specified criterias. 37 | 38 | ## EXAMPLES 39 | 40 | ### Example 1 41 | ```powershell 42 | PS C:\> Get-SeDriver 43 | ``` 44 | 45 | Return the list of all active drivers. 46 | 47 | ### Example 2 48 | ```powershell 49 | PS C:\> Get-SeDriver -Current 50 | ``` 51 | 52 | Return the currently selected browser. 53 | 54 | ### Example 3 55 | ```powershell 56 | PS C:\> Get-SeDriver -Browser Chrome 57 | ``` 58 | 59 | Returh the list of all active "Chrome" browsers. 60 | 61 | ### Example 3 62 | ```powershell 63 | PS C:\> Get-SeDriver -Name '70c91e0f112dcdbd22b84dd567560b8d' 64 | ``` 65 | 66 | Return the driver with the specified name. 67 | 68 | ## PARAMETERS 69 | 70 | ### -Browser 71 | Filter the list of returned drivers by their Browser type (enum: [SeBrowsers]) 72 | 73 | ```yaml 74 | Type: Object 75 | Parameter Sets: ByBrowser 76 | Aliases: 77 | 78 | Required: False 79 | Position: Named 80 | Default value: None 81 | Accept pipeline input: False 82 | Accept wildcard characters: False 83 | ``` 84 | 85 | ### -Current 86 | Return the currently selected browser. Selected browser is the last one started, unless changed via Switch-SeDriver and is always the one that get used in all cmdlet that have an unspecified $Driver. 87 | 88 | ```yaml 89 | Type: SwitchParameter 90 | Parameter Sets: Current 91 | Aliases: 92 | 93 | Required: False 94 | Position: Named 95 | Default value: None 96 | Accept pipeline input: False 97 | Accept wildcard characters: False 98 | ``` 99 | 100 | ### -Name 101 | Filter driver returned by its name (SeFriendlyName). 102 | 103 | ```yaml 104 | Type: String 105 | Parameter Sets: ByName 106 | Aliases: 107 | 108 | Required: False 109 | Position: 0 110 | Default value: None 111 | Accept pipeline input: False 112 | Accept wildcard characters: False 113 | ``` 114 | 115 | ### CommonParameters 116 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 117 | 118 | ## INPUTS 119 | 120 | ### None 121 | 122 | ## OUTPUTS 123 | 124 | ### System.Object 125 | ## NOTES 126 | 127 | ## RELATED LINKS 128 | -------------------------------------------------------------------------------- /Help/Get-SeDriverTimeout.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-SeDriverTimeout 9 | 10 | ## SYNOPSIS 11 | Get the specified driver timeout value. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-SeDriverTimeout [[-TimeoutType] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Get the specified driver timeout value. 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> Get-SeDriverTimeout 27 | ``` 28 | 29 | Return the currently selected driver implicit wait timeout. 30 | 31 | ### Example 2 32 | ```powershell 33 | PS C:\> Get-SeDriverTimeout -TimeoutType PageLoad -Driver $Driver 34 | ``` 35 | 36 | Return the specified driver PageLoad timeout. 37 | 38 | ## PARAMETERS 39 | 40 | ### -TimeoutType 41 | Timeout type to be changed 42 | 43 | ```yaml 44 | Type: Object 45 | Parameter Sets: (All) 46 | Aliases: 47 | Accepted values: ImplicitWait, PageLoad, AsynchronousJavaScript 48 | 49 | Required: False 50 | Position: 0 51 | Default value: ImplicitWait 52 | Accept pipeline input: False 53 | Accept wildcard characters: False 54 | ``` 55 | 56 | ### CommonParameters 57 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 58 | 59 | ## INPUTS 60 | 61 | ### OpenQA.Selenium.IWebDriver 62 | 63 | ## OUTPUTS 64 | 65 | ### System.Object 66 | ## NOTES 67 | 68 | ## RELATED LINKS 69 | -------------------------------------------------------------------------------- /Help/Get-SeElementAttribute.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-SeElementAttribute 9 | 10 | ## SYNOPSIS 11 | Get the specified attribute from the specified element. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-SeElementAttribute [-Element] [-Name] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Get the specified attribute from the specified element. 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> $Element = Get-SeElement -By Name -Selection 'username' 27 | PS C:\> Get-SeElementAttribute -Element $Element -Attribute 'placeholder' 28 | ``` 29 | 30 | Get the placeholder attribue of the username element. 31 | 32 | ## PARAMETERS 33 | 34 | ### -Element 35 | Target IWebElement 36 | 37 | ```yaml 38 | Type: IWebElement 39 | Parameter Sets: (All) 40 | Aliases: 41 | 42 | Required: True 43 | Position: 0 44 | Default value: None 45 | Accept pipeline input: True (ByValue) 46 | Accept wildcard characters: False 47 | ``` 48 | 49 | ### -Name 50 | {{ Fill Name Description }} 51 | 52 | ```yaml 53 | Type: String[] 54 | Parameter Sets: (All) 55 | Aliases: 56 | 57 | Required: True 58 | Position: 1 59 | Default value: None 60 | Accept pipeline input: False 61 | Accept wildcard characters: False 62 | ``` 63 | 64 | ### CommonParameters 65 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 66 | 67 | ## INPUTS 68 | 69 | ### OpenQA.Selenium.IWebElement 70 | 71 | ## OUTPUTS 72 | 73 | ### System.Object 74 | ## NOTES 75 | 76 | ## RELATED LINKS 77 | -------------------------------------------------------------------------------- /Help/Get-SeElementCssValue.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-SeElementCssValue 9 | 10 | ## SYNOPSIS 11 | Get CSS value for the specified name of targeted element. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-SeElementCssValue [-Element] [-Name] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Get CSS value for the specified name of targeted element. 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> Get-SeElementCssValue -Element $Element -Name 'padding' 27 | ``` 28 | 29 | Get padding css value for the targeted element. 30 | 31 | ## PARAMETERS 32 | 33 | ### -Element 34 | Target IWebElement 35 | 36 | ```yaml 37 | Type: IWebElement 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: True 42 | Position: 0 43 | Default value: None 44 | Accept pipeline input: True (ByValue) 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -Name 49 | Name of the CSS attribute to query 50 | 51 | ```yaml 52 | Type: String[] 53 | Parameter Sets: (All) 54 | Aliases: 55 | 56 | Required: True 57 | Position: 1 58 | Default value: None 59 | Accept pipeline input: False 60 | Accept wildcard characters: False 61 | ``` 62 | 63 | ### CommonParameters 64 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 65 | 66 | ## INPUTS 67 | 68 | ### OpenQA.Selenium.IWebElement 69 | 70 | ## OUTPUTS 71 | 72 | ### System.Object 73 | ## NOTES 74 | 75 | ## RELATED LINKS 76 | -------------------------------------------------------------------------------- /Help/Get-SeFrame.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-SeFrame 9 | 10 | ## SYNOPSIS 11 | {{ Fill in the Synopsis }} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-SeFrame [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{ Fill in the Description }} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### CommonParameters 34 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 35 | 36 | ## INPUTS 37 | 38 | ### None 39 | 40 | ## OUTPUTS 41 | 42 | ### System.Object 43 | ## NOTES 44 | 45 | ## RELATED LINKS 46 | -------------------------------------------------------------------------------- /Help/Get-SeHtml.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-SeHtml 9 | 10 | ## SYNOPSIS 11 | Get outer html of the specified element or driver. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-SeHtml [[-Element] ] [-Inner] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Get outer html of the specified element or driver. 21 | Driver is used by default if no element is specified. 22 | 23 | ## EXAMPLES 24 | 25 | ### Example 1 26 | ```powershell 27 | PS C:\> $Element = Get-SeElement -By ClassName -Value 'homeitem' 28 | PS C:\> $Element | Get-SeHtml -Inner 29 | ``` 30 | 31 | Get inner html for all specified elements. 32 | 33 | ### Example 2 34 | ```powershell 35 | PS C:\> Get-SeHtml 36 | ``` 37 | 38 | Get html of the current page. Equivalent to $Driver.PageSource 39 | 40 | ## PARAMETERS 41 | 42 | ### -Element 43 | Target IWebElement. 44 | 45 | ```yaml 46 | Type: IWebElement 47 | Parameter Sets: (All) 48 | Aliases: 49 | 50 | Required: False 51 | Position: 0 52 | Default value: None 53 | Accept pipeline input: True (ByValue) 54 | Accept wildcard characters: False 55 | ``` 56 | 57 | ### -Inner 58 | Return inner html instead. 59 | 60 | ```yaml 61 | Type: SwitchParameter 62 | Parameter Sets: (All) 63 | Aliases: 64 | 65 | Required: False 66 | Position: Named 67 | Default value: None 68 | Accept pipeline input: False 69 | Accept wildcard characters: False 70 | ``` 71 | 72 | ### CommonParameters 73 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 74 | 75 | ## INPUTS 76 | 77 | ### None 78 | 79 | ## OUTPUTS 80 | 81 | ### System.Object 82 | ## NOTES 83 | 84 | ## RELATED LINKS 85 | -------------------------------------------------------------------------------- /Help/Get-SeInput.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-SeInput 9 | 10 | ## SYNOPSIS 11 | Get element with an input tagname matching the specified conditions. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-SeInput [[-Type] ] [-Single] [[-Text] ] [[-Timeout] ] [-All] 17 | [[-Attributes] ] [[-Value] ] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | Get SeElement with an input Tagname 22 | 23 | ## EXAMPLES 24 | 25 | ### Example 1 26 | ```powershell 27 | PS C:\> Get-SeInput -Attributes placeholder,title -All -Single -Value 'Type to search' 28 | ``` 29 | 30 | Get all the input (including hidden) present in the Dom and load the attributes placeholder and title. A single value is expected and it's attribute placeholder should be equals to : "Type to search" 31 | 32 | ## PARAMETERS 33 | 34 | ### -All 35 | Return matching hidden items in addition to displayed ones. 36 | 37 | ```yaml 38 | Type: SwitchParameter 39 | Parameter Sets: (All) 40 | Aliases: 41 | 42 | Required: False 43 | Position: Named 44 | Default value: None 45 | Accept pipeline input: False 46 | Accept wildcard characters: False 47 | ``` 48 | 49 | ### -Attributes 50 | Append a list of Attributes (case sensitive) to each element returned. Attributes will be available through a dictionary property of the same name. Is the wildcard `*` character is used, all attributes will be queried and appended. 51 | 52 | ```yaml 53 | Type: String[] 54 | Parameter Sets: (All) 55 | Aliases: 56 | 57 | Required: False 58 | Position: 3 59 | Default value: None 60 | Accept pipeline input: False 61 | Accept wildcard characters: False 62 | ``` 63 | 64 | ### -Single 65 | Expectation that only one element will be returned. An error will be returned if that parameter is set and more than one corresponding element is found. 66 | 67 | ```yaml 68 | Type: SwitchParameter 69 | Parameter Sets: (All) 70 | Aliases: 71 | 72 | Required: False 73 | Position: Named 74 | Default value: None 75 | Accept pipeline input: False 76 | Accept wildcard characters: False 77 | ``` 78 | 79 | ### -Text 80 | Text of the input to return 81 | 82 | ```yaml 83 | Type: String 84 | Parameter Sets: (All) 85 | Aliases: 86 | 87 | Required: False 88 | Position: 1 89 | Default value: None 90 | Accept pipeline input: False 91 | Accept wildcard characters: False 92 | ``` 93 | 94 | ### -Timeout 95 | Timeout (in seconds) 96 | 97 | ```yaml 98 | Type: Double 99 | Parameter Sets: (All) 100 | Aliases: 101 | 102 | Required: False 103 | Position: 2 104 | Default value: None 105 | Accept pipeline input: False 106 | Accept wildcard characters: False 107 | ``` 108 | 109 | ### -Type 110 | Type of the input 111 | 112 | ```yaml 113 | Type: String 114 | Parameter Sets: (All) 115 | Aliases: 116 | 117 | Required: False 118 | Position: 0 119 | Default value: None 120 | Accept pipeline input: False 121 | Accept wildcard characters: False 122 | ``` 123 | 124 | ### -Value 125 | Expected value of the first attribute present. 126 | 127 | ```yaml 128 | Type: String 129 | Parameter Sets: (All) 130 | Aliases: 131 | 132 | Required: False 133 | Position: 4 134 | Default value: None 135 | Accept pipeline input: False 136 | Accept wildcard characters: False 137 | ``` 138 | 139 | ### CommonParameters 140 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 141 | 142 | ## INPUTS 143 | 144 | ### None 145 | 146 | ## OUTPUTS 147 | 148 | ### System.Object 149 | ## NOTES 150 | 151 | ## RELATED LINKS 152 | -------------------------------------------------------------------------------- /Help/Get-SeKeys.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-SeKeys 9 | 10 | ## SYNOPSIS 11 | Return a list of the available special keys 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-SeKeys [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Return a list of the available special keys. 21 | These keys can be used with `Send-SeKeys` by using their name in the following format `{{SpecialKeyName}}` 22 | 23 | ## EXAMPLES 24 | 25 | ### Example 1 26 | ```powershell 27 | PS C:\> Get-SeKeys 28 | ``` 29 | 30 | ## PARAMETERS 31 | 32 | ### CommonParameters 33 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 34 | 35 | ## INPUTS 36 | 37 | ### None 38 | 39 | ## OUTPUTS 40 | 41 | ### System.Object 42 | ## NOTES 43 | 44 | ## RELATED LINKS 45 | -------------------------------------------------------------------------------- /Help/Get-SeSelectValue.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-SeSelectValue 9 | 10 | ## SYNOPSIS 11 | Get Select element selected value. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-SeSelectValue [-Element] [-All] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Get Select element selected value. 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> Get-SeSelectValue -Element $Select 27 | ``` 28 | 29 | Get the selected value for the specified element. 30 | 31 | ## PARAMETERS 32 | 33 | ### -All 34 | Get All selected values (only available when the Select element accept multiple values) 35 | 36 | ```yaml 37 | Type: SwitchParameter 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: False 42 | Position: Named 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -Element 49 | Target IWebElement. 50 | 51 | ```yaml 52 | Type: IWebElement 53 | Parameter Sets: (All) 54 | Aliases: 55 | 56 | Required: True 57 | Position: 1 58 | Default value: None 59 | Accept pipeline input: True (ByValue) 60 | Accept wildcard characters: False 61 | ``` 62 | 63 | ### CommonParameters 64 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 65 | 66 | ## INPUTS 67 | 68 | ### OpenQA.Selenium.IWebElement 69 | 70 | ## OUTPUTS 71 | 72 | ### System.Object 73 | ## NOTES 74 | 75 | ## RELATED LINKS 76 | -------------------------------------------------------------------------------- /Help/Get-SeUrl.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-SeUrl 9 | 10 | ## SYNOPSIS 11 | Retrieves the current URL of a target webdriver instance. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-SeUrl [-Stack] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Retrieves the current URL of a target webdriver instance, or the currently 21 | stored internal location stack. 22 | 23 | ## EXAMPLES 24 | 25 | ### EXAMPLE 1 26 | ``` 27 | Get-SeUrl 28 | ``` 29 | 30 | Retrieves the current URL of the default webdriver instance. 31 | 32 | ## PARAMETERS 33 | 34 | ### -Stack 35 | Optionally retrieve the stored URL stack for the target or default 36 | webdriver instance. 37 | 38 | ```yaml 39 | Type: SwitchParameter 40 | Parameter Sets: (All) 41 | Aliases: 42 | 43 | Required: False 44 | Position: Named 45 | Default value: False 46 | Accept pipeline input: False 47 | Accept wildcard characters: False 48 | ``` 49 | 50 | ### CommonParameters 51 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 52 | 53 | ## INPUTS 54 | 55 | ## OUTPUTS 56 | 57 | ## NOTES 58 | When using -Stack, the retrieved stack will not contain any of the driver's 59 | history (Back/Forward) data. 60 | It only handles locations added with 61 | Push-SeUrl. 62 | 63 | To utilise a driver's Back/Forward functionality, instead use Set-SeUrl. 64 | 65 | ## RELATED LINKS 66 | -------------------------------------------------------------------------------- /Help/Get-SeWindow.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-SeWindow 9 | 10 | ## SYNOPSIS 11 | Gets the window handles of open browser windows 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-SeWindow [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Gets the window handles of open browser windows 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> Get-SeWindow 27 | ``` 28 | 29 | Gets the window handles of open browser windows. 30 | 31 | ## PARAMETERS 32 | 33 | ### CommonParameters 34 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 35 | 36 | ## INPUTS 37 | 38 | ### OpenQA.Selenium.IWebDriver 39 | 40 | ## OUTPUTS 41 | 42 | ### System.Object 43 | ## NOTES 44 | 45 | ## RELATED LINKS 46 | -------------------------------------------------------------------------------- /Help/Invoke-SeClick.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Invoke-SeClick 9 | 10 | ## SYNOPSIS 11 | Perform a click in the browser window or specified element. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Invoke-SeClick [[-Action] ] [[-Element] ] [-Sleep ] [-PassThru] 17 | [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | Perform a click in the browser window or specified element. 22 | 23 | ## EXAMPLES 24 | 25 | ### Example 1 26 | ```powershell 27 | PS C:\> Invoke-SeClick 28 | ``` 29 | 30 | Perform a click in the browser at the current position 31 | 32 | ### Example 2 33 | ```powershell 34 | PS C:\> Invoke-SeClick -Action Click_JS -Element $Element 35 | ``` 36 | 37 | Perform a javascript click on the specified element. 38 | 39 | ## PARAMETERS 40 | 41 | ### -Action 42 | test 43 | 44 | ```yaml 45 | Type: Object 46 | Parameter Sets: (All) 47 | Aliases: 48 | 49 | Required: False 50 | Position: 0 51 | Default value: None 52 | Accept pipeline input: False 53 | Accept wildcard characters: False 54 | ``` 55 | 56 | ### -Element 57 | Target IWebElement. 58 | 59 | ```yaml 60 | Type: IWebElement 61 | Parameter Sets: (All) 62 | Aliases: 63 | 64 | Required: False 65 | Position: 1 66 | Default value: None 67 | Accept pipeline input: True (ByValue) 68 | Accept wildcard characters: False 69 | ``` 70 | 71 | ### -PassThru 72 | Return the IWebElement. 73 | 74 | ```yaml 75 | Type: SwitchParameter 76 | Parameter Sets: (All) 77 | Aliases: 78 | 79 | Required: False 80 | Position: Named 81 | Default value: None 82 | Accept pipeline input: False 83 | Accept wildcard characters: False 84 | ``` 85 | 86 | ### -Sleep 87 | Sleep time in second after performing the click action. 88 | 89 | ```yaml 90 | Type: Double 91 | Parameter Sets: (All) 92 | Aliases: 93 | 94 | Required: False 95 | Position: Named 96 | Default value: None 97 | Accept pipeline input: False 98 | Accept wildcard characters: False 99 | ``` 100 | 101 | ### CommonParameters 102 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 103 | 104 | ## INPUTS 105 | 106 | ### OpenQA.Selenium.IWebElement 107 | 108 | ## OUTPUTS 109 | 110 | ### System.Object 111 | ## NOTES 112 | 113 | ## RELATED LINKS 114 | -------------------------------------------------------------------------------- /Help/Invoke-SeJavascript.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Invoke-SeJavascript 9 | 10 | ## SYNOPSIS 11 | Invoke Javascript in the specified Driver. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Invoke-SeJavascript [[-Script] ] [[-ArgumentList] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Invoke Javascript in the specified Driver. arguments will be passed to the javascript as "argument[0]" (where 0 is the argument position) 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> Invoke-SeJavascript -Script 'arguments[0].click()' -ArgumentList $Element 27 | ``` 28 | 29 | Perform a javascript click on the specified element. 30 | 31 | ## PARAMETERS 32 | 33 | ### -ArgumentList 34 | Argument list to be passed down to the script. 35 | 36 | ```yaml 37 | Type: Object[] 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: False 42 | Position: 1 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -Script 49 | Javascript script to be executed. Arguments passed down can be used in the scripts through `arguments[0],arguments[1]`,etc... 50 | 51 | ```yaml 52 | Type: String 53 | Parameter Sets: (All) 54 | Aliases: 55 | 56 | Required: False 57 | Position: 0 58 | Default value: None 59 | Accept pipeline input: True (ByValue) 60 | Accept wildcard characters: False 61 | ``` 62 | 63 | ### CommonParameters 64 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 65 | 66 | ## INPUTS 67 | 68 | ### OpenQA.Selenium.IWebDriver 69 | 70 | ## OUTPUTS 71 | 72 | ### System.Object 73 | ## NOTES 74 | 75 | ## RELATED LINKS 76 | -------------------------------------------------------------------------------- /Help/Invoke-SeKeys.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Invoke-SeKeys 9 | 10 | ## SYNOPSIS 11 | Send the keys to the browser or specified element. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Invoke-SeKeys [[-Element] ] [-Keys] [-ClearFirst] [-Sleep ] [-Submit] [-PassThru] 17 | [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | The text to be typed may include special characters like arrow keys, backspaces, function keys, and so on. Valid special keys are defined in Keys. [OpenQA_Selelnium_Keys](https://www.selenium.dev/selenium/docs/api/dotnet/html/T_OpenQA_Selenium_Keys.htm) 22 | 23 | ## EXAMPLES 24 | 25 | ### Example 1 26 | ```powershell 27 | PS C:\> $Search = Get-SeElement -By TagName -Value input -Single 28 | PS C:\> Invoke-SeKeys -Element $Search -Keys 'Powershell-Selenium{{Enter}}' 29 | ``` 30 | 31 | Type the defined text and a special key - Enter - defined in the special keys. 32 | 33 | ## PARAMETERS 34 | 35 | ### -ClearFirst 36 | Clear the element existing text first 37 | 38 | ```yaml 39 | Type: SwitchParameter 40 | Parameter Sets: (All) 41 | Aliases: 42 | 43 | Required: False 44 | Position: Named 45 | Default value: None 46 | Accept pipeline input: False 47 | Accept wildcard characters: False 48 | ``` 49 | 50 | ### -Element 51 | Target IWebElement. 52 | 53 | ```yaml 54 | Type: IWebElement 55 | Parameter Sets: (All) 56 | Aliases: 57 | 58 | Required: False 59 | Position: 0 60 | Default value: None 61 | Accept pipeline input: True (ByValue) 62 | Accept wildcard characters: False 63 | ``` 64 | 65 | ### -Keys 66 | Text to be typed. Special keys (Enter, arrow down, etc...) can be typed using double brackets (eg: `{{Enter}}`). See cmdlet description for complete list of keys 67 | 68 | ```yaml 69 | Type: String 70 | Parameter Sets: (All) 71 | Aliases: 72 | 73 | Required: True 74 | Position: 1 75 | Default value: None 76 | Accept pipeline input: False 77 | Accept wildcard characters: False 78 | ``` 79 | 80 | ### -PassThru 81 | Return the IWebElement or webdriver 82 | 83 | ```yaml 84 | Type: SwitchParameter 85 | Parameter Sets: (All) 86 | Aliases: 87 | 88 | Required: False 89 | Position: Named 90 | Default value: None 91 | Accept pipeline input: False 92 | Accept wildcard characters: False 93 | ``` 94 | 95 | ### -Sleep 96 | Sleep time in second after performing the type action. 97 | 98 | ```yaml 99 | Type: Double 100 | Parameter Sets: (All) 101 | Aliases: 102 | 103 | Required: False 104 | Position: Named 105 | Default value: None 106 | Accept pipeline input: False 107 | Accept wildcard characters: False 108 | ``` 109 | 110 | ### -Submit 111 | Call submit on the specified element. 112 | 113 | ```yaml 114 | Type: SwitchParameter 115 | Parameter Sets: (All) 116 | Aliases: 117 | 118 | Required: False 119 | Position: Named 120 | Default value: None 121 | Accept pipeline input: False 122 | Accept wildcard characters: False 123 | ``` 124 | 125 | ### CommonParameters 126 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 127 | 128 | ## INPUTS 129 | 130 | ### OpenQA.Selenium.IWebElement 131 | 132 | ## OUTPUTS 133 | 134 | ### System.Object 135 | ## NOTES 136 | 137 | ## RELATED LINKS 138 | -------------------------------------------------------------------------------- /Help/Invoke-SeMouseAction.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Invoke-SeMouseAction 9 | 10 | ## SYNOPSIS 11 | Perform mouse move & drag actions. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Invoke-SeMouseAction [[-Action] ] [[-Value] ] [[-Element] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Perform mouse move & drag actions. 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> Invoke-SeMouseAction -Element $SourceElement -Action DragAndDrop -Value $DestinationElement 27 | ``` 28 | 29 | Perform a drag&drop operation from the source element to destination element. 30 | 31 | ## PARAMETERS 32 | 33 | ### -Action 34 | Action to be performed. Intellisense tooltip provide details regarding expected value. 35 | 36 | ```yaml 37 | Type: Object 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: False 42 | Position: 0 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -Element 49 | {{ Fill Element Description }} 50 | 51 | ```yaml 52 | Type: IWebElement 53 | Parameter Sets: (All) 54 | Aliases: 55 | 56 | Required: False 57 | Position: 2 58 | Default value: None 59 | Accept pipeline input: True (ByValue) 60 | Accept wildcard characters: False 61 | ``` 62 | 63 | ### -Value 64 | Value expected by the specified action. 65 | 66 | ```yaml 67 | Type: Object 68 | Parameter Sets: (All) 69 | Aliases: 70 | 71 | Required: False 72 | Position: 1 73 | Default value: None 74 | Accept pipeline input: False 75 | Accept wildcard characters: False 76 | ``` 77 | 78 | ### CommonParameters 79 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 80 | 81 | ## INPUTS 82 | 83 | ### None 84 | 85 | ## OUTPUTS 86 | 87 | ### System.Object 88 | ## NOTES 89 | 90 | ## RELATED LINKS 91 | -------------------------------------------------------------------------------- /Help/New-SeDriverService.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # New-SeDriverService 9 | 10 | ## SYNOPSIS 11 | Create an instance of WebDriver service to be used with Start-SeDriver 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | New-SeDriverService [-Browser ] [-WebDriverPath ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Create an instance of WebDriver service to be used with Start-SeDriver 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> $Service = New-SeDriverService -Browser Chrome 27 | PS C:\> $Service.PortServerAddress = 100 28 | PS C:\> $Options = New-SeDriverOptions -Browser Chrome -Position 1920x0 -Size 1920x1080 29 | PS C:\> Start-SeDriver -Service $Service -Options $Options 30 | PS C:\> $Service.ProcessId 31 | ``` 32 | 33 | Create a new instance of Chrome driver service, set a custom port and start the driver with the modified service instance. 34 | 35 | ## PARAMETERS 36 | 37 | ### -Browser 38 | Browser name 39 | 40 | ```yaml 41 | Type: Object 42 | Parameter Sets: (All) 43 | Aliases: 44 | 45 | Required: False 46 | Position: Named 47 | Default value: None 48 | Accept pipeline input: False 49 | Accept wildcard characters: False 50 | ``` 51 | 52 | ### -WebDriverPath 53 | Location of the web driver to be used. 54 | 55 | ```yaml 56 | Type: Object 57 | Parameter Sets: (All) 58 | Aliases: 59 | 60 | Required: False 61 | Position: Named 62 | Default value: None 63 | Accept pipeline input: False 64 | Accept wildcard characters: False 65 | ``` 66 | 67 | ### CommonParameters 68 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 69 | 70 | ## INPUTS 71 | 72 | ### None 73 | 74 | ## OUTPUTS 75 | 76 | ### OpenQA.Selenium.Chrome.ChromeDriverService 77 | 78 | ### OpenQA.Selenium.Firefox.FirefoxDriverService 79 | 80 | ### OpenQA.Selenium.IE.InternetExplorerDriverService 81 | 82 | ### OpenQA.Selenium.Edge.EdgeDriverService 83 | 84 | ## NOTES 85 | 86 | ## RELATED LINKS 87 | -------------------------------------------------------------------------------- /Help/New-SeScreenshot.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # New-SeScreenshot 9 | 10 | ## SYNOPSIS 11 | Take a screenshot of the current page 12 | 13 | ## SYNTAX 14 | 15 | ### Driver (Default) 16 | ``` 17 | New-SeScreenshot [-AsBase64EncodedString] [] 18 | ``` 19 | 20 | ### Pipeline 21 | ``` 22 | New-SeScreenshot [-InputObject ] [-AsBase64EncodedString] [] 23 | ``` 24 | 25 | ### Element 26 | ``` 27 | New-SeScreenshot [-AsBase64EncodedString] [-Element ] [] 28 | ``` 29 | 30 | ## DESCRIPTION 31 | Take a screenshot of the current page 32 | 33 | ## EXAMPLES 34 | 35 | ### Example 1 36 | ```powershell 37 | PS C:\> $Element | New-SeScreenshot 38 | ``` 39 | 40 | Take a screenshot of the specified element. 41 | 42 | ## PARAMETERS 43 | 44 | ### -AsBase64EncodedString 45 | Return image as base64 string 46 | 47 | ```yaml 48 | Type: SwitchParameter 49 | Parameter Sets: (All) 50 | Aliases: 51 | 52 | Required: False 53 | Position: Named 54 | Default value: None 55 | Accept pipeline input: False 56 | Accept wildcard characters: False 57 | ``` 58 | 59 | ### -Element 60 | Target IWebElement. 61 | 62 | ```yaml 63 | Type: IWebElement 64 | Parameter Sets: Element 65 | Aliases: 66 | 67 | Required: False 68 | Position: Named 69 | Default value: None 70 | Accept pipeline input: False 71 | Accept wildcard characters: False 72 | ``` 73 | 74 | ### -InputObject 75 | Target IWebElement. 76 | 77 | ```yaml 78 | Type: Object 79 | Parameter Sets: Pipeline 80 | Aliases: 81 | 82 | Required: False 83 | Position: Named 84 | Default value: None 85 | Accept pipeline input: True (ByValue) 86 | Accept wildcard characters: False 87 | ``` 88 | 89 | ### CommonParameters 90 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 91 | 92 | ## INPUTS 93 | 94 | ### System.Object 95 | 96 | ## OUTPUTS 97 | 98 | ### System.Object 99 | ## NOTES 100 | 101 | ## RELATED LINKS 102 | -------------------------------------------------------------------------------- /Help/New-SeWindow.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # New-SeWindow 9 | 10 | ## SYNOPSIS 11 | {{ Fill in the Synopsis }} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | New-SeWindow [[-Url] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{ Fill in the Description }} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### -Url 34 | {{ Fill Url Description }} 35 | 36 | ```yaml 37 | Type: Object 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: False 42 | Position: 0 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### CommonParameters 49 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 50 | 51 | ## INPUTS 52 | 53 | ### OpenQA.Selenium.IWebDriver 54 | 55 | ## OUTPUTS 56 | 57 | ### System.Object 58 | ## NOTES 59 | 60 | ## RELATED LINKS 61 | -------------------------------------------------------------------------------- /Help/Pop-SeUrl.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Pop-SeUrl 9 | 10 | ## SYNOPSIS 11 | Navigate back to the most recently pushed URL in the location stack. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Pop-SeUrl [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Retrieves the most recently pushed URL from the location stack and navigates 21 | to that URL with the specified or default driver. 22 | 23 | ## EXAMPLES 24 | 25 | ### EXAMPLE 1 26 | ``` 27 | Pop-SeUrl 28 | ``` 29 | 30 | Retrieves the most recently pushed URL and navigates back to that URL. 31 | 32 | ## PARAMETERS 33 | 34 | ### CommonParameters 35 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 36 | 37 | ## INPUTS 38 | 39 | ## OUTPUTS 40 | 41 | ## NOTES 42 | A separate internal location stack is maintained for each driver instance 43 | by the module. 44 | This stack is completely separate from the driver's internal 45 | Back/Forward history logic. 46 | 47 | To utilise a driver's Back/Forward functionality, instead use Set-SeUrl. 48 | 49 | ## RELATED LINKS 50 | -------------------------------------------------------------------------------- /Help/Push-SeUrl.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Push-SeUrl 9 | 10 | ## SYNOPSIS 11 | Stores the current URL in the driver's location stack and optionally 12 | navigate to a new URL. 13 | 14 | ## SYNTAX 15 | 16 | ``` 17 | Push-SeUrl [[-Url] ] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | The current driver URL is added to the stack, and if a URL is provided, the 22 | driver navigates to the new URL. 23 | 24 | ## EXAMPLES 25 | 26 | ### EXAMPLE 1 27 | ``` 28 | Push-SeUrl 29 | ``` 30 | 31 | The current driver URL is added to the location stack. 32 | 33 | ### EXAMPLE 2 34 | ``` 35 | Push-SeUrl 'https://google.com/' 36 | ``` 37 | 38 | The current driver URL is added to the location stack, and the driver then 39 | navigates to the provided target URL. 40 | 41 | ## PARAMETERS 42 | 43 | ### -Url 44 | The new URL to navigate to after storing the current location. 45 | 46 | ```yaml 47 | Type: String 48 | Parameter Sets: (All) 49 | Aliases: 50 | 51 | Required: False 52 | Position: 1 53 | Default value: None 54 | Accept pipeline input: False 55 | Accept wildcard characters: False 56 | ``` 57 | 58 | ### CommonParameters 59 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 60 | 61 | ## INPUTS 62 | 63 | ## OUTPUTS 64 | 65 | ## NOTES 66 | A separate internal location stack is maintained for each driver instance 67 | by the module. 68 | This stack is completely separate from the driver's internal 69 | Back/Forward history logic. 70 | 71 | To utilise a driver's Back/Forward functionality, instead use Set-SeUrl. 72 | 73 | ## RELATED LINKS 74 | -------------------------------------------------------------------------------- /Help/Remove-SeCookie.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Remove-SeCookie 9 | 10 | ## SYNOPSIS 11 | Delete the named cookie from the current domain 12 | 13 | ## SYNTAX 14 | 15 | ### All 16 | ``` 17 | Remove-SeCookie [-All] [] 18 | ``` 19 | 20 | ### NamedCookie 21 | ``` 22 | Remove-SeCookie -Name [] 23 | ``` 24 | 25 | ## DESCRIPTION 26 | Delete the named cookie from the current domain 27 | 28 | ## EXAMPLES 29 | 30 | ### Example 1 31 | ```powershell 32 | PS C:\> Remove-SeCookie -Name 'CookieName' 33 | ``` 34 | 35 | Remove cookie from targeted Driver 36 | 37 | ### Example 2 38 | ```powershell 39 | PS C:\> Remove-SeCookie -DeleteAllCookies 40 | ``` 41 | 42 | Remove all cookies from targeted Driver 43 | 44 | ## PARAMETERS 45 | 46 | ### -All 47 | Clear all cookies. 48 | 49 | ```yaml 50 | Type: SwitchParameter 51 | Parameter Sets: All 52 | Aliases: 53 | 54 | Required: True 55 | Position: Named 56 | Default value: None 57 | Accept pipeline input: False 58 | Accept wildcard characters: False 59 | ``` 60 | 61 | ### -Name 62 | Cookie name to remove 63 | 64 | ```yaml 65 | Type: String 66 | Parameter Sets: NamedCookie 67 | Aliases: 68 | 69 | Required: True 70 | Position: Named 71 | Default value: None 72 | Accept pipeline input: False 73 | Accept wildcard characters: False 74 | ``` 75 | 76 | ### CommonParameters 77 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 78 | 79 | ## INPUTS 80 | 81 | ### OpenQA.Selenium.IWebDriver 82 | 83 | ## OUTPUTS 84 | 85 | ### System.Object 86 | ## NOTES 87 | 88 | ## RELATED LINKS 89 | -------------------------------------------------------------------------------- /Help/Remove-SeWindow.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Remove-SeWindow 9 | 10 | ## SYNOPSIS 11 | {{ Fill in the Synopsis }} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Remove-SeWindow [[-SwitchToWindow] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{ Fill in the Description }} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### -SwitchToWindow 34 | {{ Fill SwitchToWindow Description }} 35 | 36 | ```yaml 37 | Type: String 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: False 42 | Position: 0 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### CommonParameters 49 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 50 | 51 | ## INPUTS 52 | 53 | ### OpenQA.Selenium.IWebDriver 54 | 55 | ## OUTPUTS 56 | 57 | ### System.Object 58 | ## NOTES 59 | 60 | ## RELATED LINKS 61 | -------------------------------------------------------------------------------- /Help/Save-SeScreenshot.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Save-SeScreenshot 9 | 10 | ## SYNOPSIS 11 | Save a screenshot on the disk. 12 | 13 | ## SYNTAX 14 | 15 | ### Driver (Default) 16 | ``` 17 | Save-SeScreenshot -Path [-ImageFormat ] [] 18 | ``` 19 | 20 | ### Pipeline 21 | ``` 22 | Save-SeScreenshot [-InputObject ] -Path [-ImageFormat ] 23 | [] 24 | ``` 25 | 26 | ### Screenshot 27 | ``` 28 | Save-SeScreenshot -Screenshot -Path [-ImageFormat ] 29 | [] 30 | ``` 31 | 32 | ### Element 33 | ``` 34 | Save-SeScreenshot -Path [-ImageFormat ] -Element 35 | [] 36 | ``` 37 | 38 | ## DESCRIPTION 39 | Save the screenshot at the specified location. 40 | 41 | ## EXAMPLES 42 | 43 | ### Example 1 44 | ```powershell 45 | PS C:\> $Screenshot = New-SeScreenshot 46 | PS C:\> Save-SeScreenshot -Screenshot $Screenshot -Path 'c:\temp\image.png' -ImageFormat Png 47 | ``` 48 | 49 | Create then save a screenshot to disk. 50 | 51 | ## PARAMETERS 52 | 53 | ### -Element 54 | {{ Fill Element Description }} 55 | 56 | ```yaml 57 | Type: IWebElement 58 | Parameter Sets: Element 59 | Aliases: 60 | 61 | Required: True 62 | Position: Named 63 | Default value: None 64 | Accept pipeline input: False 65 | Accept wildcard characters: False 66 | ``` 67 | 68 | ### -ImageFormat 69 | Image format for the file to be saved. 70 | 71 | ```yaml 72 | Type: ScreenshotImageFormat 73 | Parameter Sets: (All) 74 | Aliases: 75 | Accepted values: Png, Jpeg, Gif, Tiff, Bmp 76 | 77 | Required: False 78 | Position: Named 79 | Default value: None 80 | Accept pipeline input: False 81 | Accept wildcard characters: False 82 | ``` 83 | 84 | ### -InputObject 85 | {{ Fill InputObject Description }} 86 | 87 | ```yaml 88 | Type: Object 89 | Parameter Sets: Pipeline 90 | Aliases: 91 | 92 | Required: False 93 | Position: Named 94 | Default value: None 95 | Accept pipeline input: True (ByValue) 96 | Accept wildcard characters: False 97 | ``` 98 | 99 | ### -Path 100 | Filepath where the image will be saved. 101 | 102 | ```yaml 103 | Type: String 104 | Parameter Sets: (All) 105 | Aliases: 106 | 107 | Required: True 108 | Position: Named 109 | Default value: None 110 | Accept pipeline input: False 111 | Accept wildcard characters: False 112 | ``` 113 | 114 | ### -Screenshot 115 | Screenshot object. 116 | 117 | ```yaml 118 | Type: Screenshot 119 | Parameter Sets: Screenshot 120 | Aliases: 121 | 122 | Required: True 123 | Position: Named 124 | Default value: None 125 | Accept pipeline input: False 126 | Accept wildcard characters: False 127 | ``` 128 | 129 | ### CommonParameters 130 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 131 | 132 | ## INPUTS 133 | 134 | ### System.Object 135 | 136 | ### OpenQA.Selenium.Screenshot 137 | 138 | ## OUTPUTS 139 | 140 | ### System.Object 141 | ## NOTES 142 | 143 | ## RELATED LINKS 144 | -------------------------------------------------------------------------------- /Help/Set-SeCookie.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Set-SeCookie 9 | 10 | ## SYNOPSIS 11 | Add a cookie to the current browsing context 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Set-SeCookie [[-Name] ] [[-Value] ] [[-Path] ] [[-Domain] ] 17 | [[-ExpiryDate] ] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | Add a cookie to the current browsing context 22 | 23 | ## EXAMPLES 24 | 25 | ## PARAMETERS 26 | 27 | ### -Domain 28 | The domain of the cookie 29 | 30 | ```yaml 31 | Type: String 32 | Parameter Sets: (All) 33 | Aliases: 34 | 35 | Required: False 36 | Position: 3 37 | Default value: None 38 | Accept pipeline input: False 39 | Accept wildcard characters: False 40 | ``` 41 | 42 | ### -ExpiryDate 43 | The expiration date of the cookie 44 | 45 | ```yaml 46 | Type: DateTime 47 | Parameter Sets: (All) 48 | Aliases: 49 | 50 | Required: False 51 | Position: 4 52 | Default value: None 53 | Accept pipeline input: False 54 | Accept wildcard characters: False 55 | ``` 56 | 57 | ### -Name 58 | The name of the cookie 59 | 60 | ```yaml 61 | Type: String 62 | Parameter Sets: (All) 63 | Aliases: 64 | 65 | Required: False 66 | Position: 0 67 | Default value: None 68 | Accept pipeline input: False 69 | Accept wildcard characters: False 70 | ``` 71 | 72 | ### -Path 73 | The path of the cookie 74 | 75 | ```yaml 76 | Type: String 77 | Parameter Sets: (All) 78 | Aliases: 79 | 80 | Required: False 81 | Position: 2 82 | Default value: None 83 | Accept pipeline input: False 84 | Accept wildcard characters: False 85 | ``` 86 | 87 | ### -Value 88 | The value of the cookie 89 | 90 | ```yaml 91 | Type: String 92 | Parameter Sets: (All) 93 | Aliases: 94 | 95 | Required: False 96 | Position: 1 97 | Default value: None 98 | Accept pipeline input: False 99 | Accept wildcard characters: False 100 | ``` 101 | 102 | ### CommonParameters 103 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 104 | 105 | ## INPUTS 106 | 107 | ### System.Object 108 | 109 | ## OUTPUTS 110 | 111 | ### System.Object 112 | ## NOTES 113 | 114 | ## RELATED LINKS 115 | -------------------------------------------------------------------------------- /Help/Set-SeDriverTimeout.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Set-SeDriverTimeout 9 | 10 | ## SYNOPSIS 11 | Set the various driver timeouts default. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Set-SeDriverTimeout [[-TimeoutType] ] [[-Timeout] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Set the various driver timeouts default. 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> Set-SeDriverTimeout -TimeoutType ImplicitWait -Timeout 0 27 | ``` 28 | 29 | Set Implicit wait timeout to 0 30 | 31 | ## PARAMETERS 32 | 33 | ### -Timeout 34 | Value in seconds 35 | 36 | ```yaml 37 | Type: Double 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: False 42 | Position: 1 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -TimeoutType 49 | Type of timeout to change. 50 | 51 | ```yaml 52 | Type: Object 53 | Parameter Sets: (All) 54 | Aliases: 55 | Accepted values: ImplicitWait, PageLoad, AsynchronousJavaScript 56 | 57 | Required: False 58 | Position: 0 59 | Default value: None 60 | Accept pipeline input: False 61 | Accept wildcard characters: False 62 | ``` 63 | 64 | ### CommonParameters 65 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 66 | 67 | ## INPUTS 68 | 69 | ### OpenQA.Selenium.IWebDriver 70 | 71 | ## OUTPUTS 72 | 73 | ### System.Object 74 | ## NOTES 75 | 76 | ## RELATED LINKS 77 | -------------------------------------------------------------------------------- /Help/Set-SeSelectValue.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Set-SeSelectValue 9 | 10 | ## SYNOPSIS 11 | Set Select element selected value. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Set-SeSelectValue [-By ] [-Element] [-value ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Set Select element selected value. 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> Set-SeSelectValue -By Text -value 'Hello' -Element $Element 27 | ``` 28 | 29 | Set targeted Select element selected value to 'Hello' (by text) 30 | 31 | ## PARAMETERS 32 | 33 | ### -By 34 | Selector to be used to set the value. 35 | 36 | ```yaml 37 | Type: SeBySelect 38 | Parameter Sets: (All) 39 | Aliases: 40 | Accepted values: Index, Text, Value 41 | 42 | Required: False 43 | Position: Named 44 | Default value: None 45 | Accept pipeline input: False 46 | Accept wildcard characters: False 47 | ``` 48 | 49 | ### -Element 50 | Target IWebElement. 51 | 52 | ```yaml 53 | Type: IWebElement 54 | Parameter Sets: (All) 55 | Aliases: 56 | 57 | Required: True 58 | Position: 1 59 | Default value: None 60 | Accept pipeline input: True (ByValue) 61 | Accept wildcard characters: False 62 | ``` 63 | 64 | ### -value 65 | Value to which the specified element will be set. 66 | 67 | ```yaml 68 | Type: Object 69 | Parameter Sets: (All) 70 | Aliases: 71 | 72 | Required: False 73 | Position: Named 74 | Default value: None 75 | Accept pipeline input: False 76 | Accept wildcard characters: False 77 | ``` 78 | 79 | ### CommonParameters 80 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 81 | 82 | ## INPUTS 83 | 84 | ### OpenQA.Selenium.IWebElement 85 | 86 | ## OUTPUTS 87 | 88 | ### System.Object 89 | ## NOTES 90 | 91 | ## RELATED LINKS 92 | -------------------------------------------------------------------------------- /Help/Start-SeRemote.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Start-SeRemote 9 | 10 | ## SYNOPSIS 11 | Start a remote driver session. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Start-SeRemote [-RemoteAddress ] [-DesiredCapabilities ] [[-StartURL] ] 17 | [-ImplicitWait ] [-Size ] [-Position ] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | Start a remote driver session. 22 | you can a remote testing account with testing bot at https://testingbot.com/users/sign_up 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | ```powershell 28 | #Set $key and $secret and then ... 29 | #see also https://crossbrowsertesting.com/freetrial / https://help.crossbrowsertesting.com/selenium-testing/getting-started/c-sharp/ 30 | #and https://www.browserstack.com/automate/c-sharp 31 | $RemoteDriverURL = [uri]"http://$key`:$secret@hub.testingbot.com/wd/hub" 32 | #See https://testingbot.com/support/getting-started/csharp.html for values for different browsers/platforms 33 | $caps = @{ 34 | platform = 'HIGH-SIERRA' 35 | version = '11' 36 | browserName = 'safari' 37 | } 38 | Start-SeRemote -RemoteAddress $remoteDriverUrl -DesiredCapabilties $caps 39 | ``` 40 | 41 | ## PARAMETERS 42 | 43 | ### -DesiredCapabilities 44 | {{ Fill DesiredCapabilities Description }} 45 | 46 | ```yaml 47 | Type: Hashtable 48 | Parameter Sets: (All) 49 | Aliases: 50 | 51 | Required: False 52 | Position: Named 53 | Default value: None 54 | Accept pipeline input: False 55 | Accept wildcard characters: False 56 | ``` 57 | 58 | ### -ImplicitWait 59 | {{ Fill ImplicitWait Description }} 60 | 61 | ```yaml 62 | Type: Double 63 | Parameter Sets: (All) 64 | Aliases: 65 | 66 | Required: False 67 | Position: Named 68 | Default value: None 69 | Accept pipeline input: False 70 | Accept wildcard characters: False 71 | ``` 72 | 73 | ### -Position 74 | {{ Fill Position Description }} 75 | 76 | ```yaml 77 | Type: Point 78 | Parameter Sets: (All) 79 | Aliases: 80 | 81 | Required: False 82 | Position: Named 83 | Default value: None 84 | Accept pipeline input: False 85 | Accept wildcard characters: False 86 | ``` 87 | 88 | ### -RemoteAddress 89 | {{ Fill RemoteAddress Description }} 90 | 91 | ```yaml 92 | Type: String 93 | Parameter Sets: (All) 94 | Aliases: 95 | 96 | Required: False 97 | Position: Named 98 | Default value: None 99 | Accept pipeline input: False 100 | Accept wildcard characters: False 101 | ``` 102 | 103 | ### -Size 104 | {{ Fill Size Description }} 105 | 106 | ```yaml 107 | Type: Size 108 | Parameter Sets: (All) 109 | Aliases: 110 | 111 | Required: False 112 | Position: Named 113 | Default value: None 114 | Accept pipeline input: False 115 | Accept wildcard characters: False 116 | ``` 117 | 118 | ### -StartURL 119 | {{ Fill StartURL Description }} 120 | 121 | ```yaml 122 | Type: String 123 | Parameter Sets: (All) 124 | Aliases: 125 | 126 | Required: False 127 | Position: 0 128 | Default value: None 129 | Accept pipeline input: False 130 | Accept wildcard characters: False 131 | ``` 132 | 133 | ### CommonParameters 134 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 135 | 136 | ## INPUTS 137 | 138 | ### None 139 | 140 | ## OUTPUTS 141 | 142 | ### System.Object 143 | ## NOTES 144 | 145 | ## RELATED LINKS 146 | -------------------------------------------------------------------------------- /Help/Stop-SeDriver.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Stop-SeDriver 9 | 10 | ## SYNOPSIS 11 | Quits this driver, closing every associated window. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Stop-SeDriver [[-Driver] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Quits this driver, closing every associated window. 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> Stop-SeDriver -Target $Driver 27 | ``` 28 | 29 | Stop the specified driver 30 | 31 | ### Example 1 32 | ```powershell 33 | PS C:\> Start-SeChrome -AsDefaultDriver 34 | PS C:\> Stop-SeDriver 35 | ``` 36 | 37 | Stop the default driver, which was defined using the `-AsDefaultDriver` switch. 38 | 39 | ## PARAMETERS 40 | 41 | ### -Driver 42 | Target WebDriver 43 | 44 | ```yaml 45 | Type: IWebDriver 46 | Parameter Sets: (All) 47 | Aliases: 48 | 49 | Required: False 50 | Position: 0 51 | Default value: None 52 | Accept pipeline input: True (ByValue) 53 | Accept wildcard characters: False 54 | ``` 55 | 56 | ### CommonParameters 57 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 58 | 59 | ## INPUTS 60 | 61 | ### OpenQA.Selenium.IWebDriver 62 | 63 | ## OUTPUTS 64 | 65 | ### System.Object 66 | ## NOTES 67 | 68 | ## RELATED LINKS 69 | -------------------------------------------------------------------------------- /Help/Switch-SeDriver.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Switch-SeDriver 9 | 10 | ## SYNOPSIS 11 | Select a driver, making it the default to be used with any ulterior calls whenever the driver parameter is not specified. 12 | 13 | ## SYNTAX 14 | 15 | ### ByName (Default) 16 | ``` 17 | Switch-SeDriver [-Name] [] 18 | ``` 19 | 20 | ### ByDriver 21 | ``` 22 | Switch-SeDriver [-Driver] [] 23 | ``` 24 | 25 | ## DESCRIPTION 26 | Select a driver, making it the default to be used with any ulterior calls whenever the driver parameter is not specified. 27 | 28 | ## EXAMPLES 29 | 30 | ### Example 1 31 | ```powershell 32 | PS C:\> $Driver = Start-SeDriver -Browser Chrome 33 | # Chrome is the only and default driver 34 | PS C:\> Get-SeDriver -Current 35 | PS C:\> Start-SeDriver -Browser Firefox 36 | # Firefox is now the default browser 37 | PS C:\> Get-SeDriver -Current 38 | PS C:\> Switch-SeDriver -Driver $Driver 39 | # Chrome is the default browser again 40 | PS C:\> Get-SeDriver -Current 41 | ``` 42 | 43 | This examples show the default browser changing from Chrome to Firefox when the second instance is launched, then set back to Chrome through Switch-SeDriver 44 | 45 | ## PARAMETERS 46 | 47 | ### -Driver 48 | Target WebDriver 49 | 50 | ```yaml 51 | Type: IWebDriver 52 | Parameter Sets: ByDriver 53 | Aliases: 54 | 55 | Required: True 56 | Position: 0 57 | Default value: None 58 | Accept pipeline input: False 59 | Accept wildcard characters: False 60 | ``` 61 | 62 | ### -Name 63 | SeFriendlyName of the browser to select. 64 | 65 | ```yaml 66 | Type: String 67 | Parameter Sets: ByName 68 | Aliases: 69 | 70 | Required: True 71 | Position: 0 72 | Default value: None 73 | Accept pipeline input: False 74 | Accept wildcard characters: False 75 | ``` 76 | 77 | ### CommonParameters 78 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 79 | 80 | ## INPUTS 81 | 82 | ### None 83 | 84 | ## OUTPUTS 85 | 86 | ### System.Object 87 | ## NOTES 88 | 89 | ## RELATED LINKS 90 | -------------------------------------------------------------------------------- /Help/Switch-SeFrame.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Switch-SeFrame 9 | 10 | ## SYNOPSIS 11 | Instructs the driver to send future commands to a different frame 12 | 13 | ## SYNTAX 14 | 15 | ### Frame 16 | ``` 17 | Switch-SeFrame [-Frame] [] 18 | ``` 19 | 20 | ### Parent 21 | ``` 22 | Switch-SeFrame [-Parent] [] 23 | ``` 24 | 25 | ### Root 26 | ``` 27 | Switch-SeFrame [-Root] [] 28 | ``` 29 | 30 | ## DESCRIPTION 31 | Instructs the driver to send future commands to a different frame 32 | 33 | ## EXAMPLES 34 | 35 | ### Example 1 36 | 37 | ## PARAMETERS 38 | 39 | ### -Frame 40 | {{ Fill Frame Description }} 41 | 42 | ```yaml 43 | Type: Object 44 | Parameter Sets: Frame 45 | Aliases: 46 | 47 | Required: True 48 | Position: 0 49 | Default value: None 50 | Accept pipeline input: False 51 | Accept wildcard characters: False 52 | ``` 53 | 54 | ### -Parent 55 | {{ Fill Parent Description }} 56 | 57 | ```yaml 58 | Type: SwitchParameter 59 | Parameter Sets: Parent 60 | Aliases: 61 | 62 | Required: True 63 | Position: Named 64 | Default value: None 65 | Accept pipeline input: False 66 | Accept wildcard characters: False 67 | ``` 68 | 69 | ### -Root 70 | {{ Fill Root Description }} 71 | 72 | ```yaml 73 | Type: SwitchParameter 74 | Parameter Sets: Root 75 | Aliases: 76 | 77 | Required: True 78 | Position: Named 79 | Default value: None 80 | Accept pipeline input: False 81 | Accept wildcard characters: False 82 | ``` 83 | 84 | ### CommonParameters 85 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 86 | 87 | ## INPUTS 88 | 89 | ### System.Object 90 | 91 | ## OUTPUTS 92 | 93 | ### System.Object 94 | ## NOTES 95 | 96 | ## RELATED LINKS 97 | -------------------------------------------------------------------------------- /Help/Switch-SeWindow.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Switch-SeWindow 9 | 10 | ## SYNOPSIS 11 | Instructs the driver to send future commands to a different window 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Switch-SeWindow [-Window] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Instructs the driver to send future commands to a different window 21 | 22 | ## EXAMPLES 23 | 24 | ## PARAMETERS 25 | 26 | ### -Window 27 | {{ Fill Window Description }} 28 | 29 | ```yaml 30 | Type: Object 31 | Parameter Sets: (All) 32 | Aliases: 33 | 34 | Required: True 35 | Position: 0 36 | Default value: None 37 | Accept pipeline input: False 38 | Accept wildcard characters: False 39 | ``` 40 | 41 | ### CommonParameters 42 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 43 | 44 | ## INPUTS 45 | 46 | ### OpenQA.Selenium.IWebDriver 47 | 48 | ## OUTPUTS 49 | 50 | ### System.Object 51 | ## NOTES 52 | 53 | ## RELATED LINKS 54 | -------------------------------------------------------------------------------- /Help/Update-SeDriver.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Update-SeDriver 9 | 10 | ## SYNOPSIS 11 | {{ Fill in the Synopsis }} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Update-SeDriver [[-Browser] ] [[-OS] ] [[-Path] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{ Fill in the Description }} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### -Browser 34 | {{ Fill Browser Description }} 35 | 36 | ```yaml 37 | Type: Object 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: False 42 | Position: 0 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -OS 49 | {{ Fill OS Description }} 50 | 51 | ```yaml 52 | Type: Object 53 | Parameter Sets: (All) 54 | Aliases: 55 | Accepted values: Linux, Mac, Windows 56 | 57 | Required: False 58 | Position: 1 59 | Default value: None 60 | Accept pipeline input: False 61 | Accept wildcard characters: False 62 | ``` 63 | 64 | ### -Path 65 | {{ Fill Path Description }} 66 | 67 | ```yaml 68 | Type: Object 69 | Parameter Sets: (All) 70 | Aliases: 71 | 72 | Required: False 73 | Position: 2 74 | Default value: None 75 | Accept pipeline input: False 76 | Accept wildcard characters: False 77 | ``` 78 | 79 | ### CommonParameters 80 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 81 | 82 | ## INPUTS 83 | 84 | ### None 85 | 86 | ## OUTPUTS 87 | 88 | ### System.Object 89 | ## NOTES 90 | 91 | ## RELATED LINKS 92 | -------------------------------------------------------------------------------- /Help/Wait-SeDriver.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Wait-SeDriver 9 | 10 | ## SYNOPSIS 11 | Wait for the driver to be in the desired state. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Wait-SeDriver [-Condition] [-Value] [[-Timeout] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Wait for the driver to be in the desired state. 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> Wait-SeDriver -Condition UrlContains 'next-' -Timeout 5.5 27 | ``` 28 | 29 | Wait 5.5 seconds for the driver URL to contains text "next-" 30 | 31 | ## PARAMETERS 32 | 33 | ### -Condition 34 | Condition that is expected to be met. 35 | 36 | ```yaml 37 | Type: Object 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: True 42 | Position: 0 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -Timeout 49 | Time delimiter in second for which the operation should succeed. 50 | 51 | ```yaml 52 | Type: Double 53 | Parameter Sets: (All) 54 | Aliases: 55 | 56 | Required: False 57 | Position: 2 58 | Default value: None 59 | Accept pipeline input: False 60 | Accept wildcard characters: False 61 | ``` 62 | 63 | ### -Value 64 | Condition value expected to be met. 65 | 66 | ```yaml 67 | Type: Object 68 | Parameter Sets: (All) 69 | Aliases: 70 | 71 | Required: True 72 | Position: 1 73 | Default value: None 74 | Accept pipeline input: False 75 | Accept wildcard characters: False 76 | ``` 77 | 78 | ### CommonParameters 79 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 80 | 81 | ## INPUTS 82 | 83 | ### System.Object 84 | 85 | ## OUTPUTS 86 | 87 | ### System.Object 88 | ## NOTES 89 | 90 | ## RELATED LINKS 91 | -------------------------------------------------------------------------------- /Help/Wait-SeElement.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Selenium-help.xml 3 | Module Name: Selenium 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Wait-SeElement 9 | 10 | ## SYNOPSIS 11 | Wait for an element condition to be met. 12 | 13 | ## SYNTAX 14 | 15 | ### Element (Default) 16 | ``` 17 | Wait-SeElement -Element [-Condition ] [-ConditionValue ] [-Timeout ] 18 | [] 19 | ``` 20 | 21 | ### Locator 22 | ``` 23 | Wait-SeElement [[-By] ] [-Value] [-Condition ] [-ConditionValue ] 24 | [-Timeout ] [] 25 | ``` 26 | 27 | ## DESCRIPTION 28 | Wait for an element condition to be met. 29 | 30 | ## EXAMPLES 31 | 32 | ### Example 1 33 | ```powershell 34 | PS C:\> Wait-SeElement -Element $Element -Condition StalenessOf 35 | ``` 36 | 37 | Wait for the specified element to not exist anymore in the DOM for 3 seconds (default timeout) 38 | 39 | ## PARAMETERS 40 | 41 | ### -By 42 | Locator element. 43 | 44 | ```yaml 45 | Type: SeBySelector 46 | Parameter Sets: Locator 47 | Aliases: 48 | Accepted values: ClassName, CssSelector, Id, LinkText, PartialLinkText, Name, TagName, XPath 49 | 50 | Required: False 51 | Position: 0 52 | Default value: None 53 | Accept pipeline input: False 54 | Accept wildcard characters: False 55 | ``` 56 | 57 | ### -Condition 58 | Condition expected to be met. Some condition are only available with locator or element. 59 | 60 | ```yaml 61 | Type: Object 62 | Parameter Sets: (All) 63 | Aliases: 64 | 65 | Required: False 66 | Position: Named 67 | Default value: None 68 | Accept pipeline input: False 69 | Accept wildcard characters: False 70 | ``` 71 | 72 | ### -ConditionValue 73 | Value of the expected condition to be met. 74 | 75 | ```yaml 76 | Type: Object 77 | Parameter Sets: (All) 78 | Aliases: 79 | 80 | Required: False 81 | Position: Named 82 | Default value: None 83 | Accept pipeline input: False 84 | Accept wildcard characters: False 85 | ``` 86 | 87 | ### -Element 88 | Element that need to meet the condition. 89 | 90 | ```yaml 91 | Type: IWebElement 92 | Parameter Sets: Element 93 | Aliases: 94 | 95 | Required: True 96 | Position: Named 97 | Default value: None 98 | Accept pipeline input: False 99 | Accept wildcard characters: False 100 | ``` 101 | 102 | ### -Timeout 103 | Time delimiter in second for which the operation should succeed. 104 | 105 | ```yaml 106 | Type: Double 107 | Parameter Sets: (All) 108 | Aliases: 109 | 110 | Required: False 111 | Position: Named 112 | Default value: None 113 | Accept pipeline input: False 114 | Accept wildcard characters: False 115 | ``` 116 | 117 | ### -Value 118 | Value of the locator corresponding to the element that should match the Condition / ConditionValue. 119 | 120 | ```yaml 121 | Type: String 122 | Parameter Sets: Locator 123 | Aliases: 124 | 125 | Required: True 126 | Position: 1 127 | Default value: None 128 | Accept pipeline input: False 129 | Accept wildcard characters: False 130 | ``` 131 | 132 | ### CommonParameters 133 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 134 | 135 | ## INPUTS 136 | 137 | ### System.Object 138 | 139 | ## OUTPUTS 140 | 141 | ### System.Object 142 | ## NOTES 143 | 144 | ## RELATED LINKS 145 | -------------------------------------------------------------------------------- /Internal/Disable-SeDriverImplicitTimeout.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Disable Implicitt wait on the specidifed driver 4 | .DESCRIPTION 5 | This cmdlet is used alongside the corresponding Enable cmdlet to temporarily disable 6 | Implicit wait whenever explicit wait are used. 7 | .EXAMPLE 8 | PS C:\> $ImpTimeout = Disable-SeDriverImplicitTimeout -Driver $Driver 9 | Disable implicit wait on the specified driver and return the old timespan. 10 | .INPUTS 11 | Inputs (if any) 12 | .OUTPUTS 13 | Implicit wait Timespan obtained before setting it to 0 14 | .NOTES 15 | These cmdlet are used because mixing ImplicitWait and ExplicitWait can have unintended consequences. 16 | Thus, implicit wait should always temporarily be disabled when using explicit wait statements. 17 | #> 18 | function Disable-SeDriverImplicitTimeout { 19 | param( 20 | [Parameter(ValueFromPipeline = $true)] 21 | [OpenQA.Selenium.IWebDriver]$Driver 22 | ) 23 | $Output = $Driver.Manage().Timeouts().ImplicitWait 24 | $Driver.Manage().Timeouts().ImplicitWait = 0 25 | return $Output 26 | } 27 | 28 | -------------------------------------------------------------------------------- /Internal/Enable-SeDriverImplicitTimeout .ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Enable ImplicitWait on the specified driver. 4 | .DESCRIPTION 5 | Enable ImplicitWait on the specified driver. See the corresponding Disable cmdlet for more information. 6 | .EXAMPLE 7 | PS C:\> Enable-SeDriverImplicitTimeout -Driver $Driver -Timeout $ImpTimeout 8 | Explanation of what the example does 9 | .INPUTS 10 | Inputs (if any) 11 | .OUTPUTS 12 | Output (if any) 13 | .NOTES 14 | General notes 15 | #> 16 | function Enable-SeDriverImplicitTimeout { 17 | param( 18 | [Parameter(ValueFromPipeline = $true)] 19 | [OpenQA.Selenium.IWebDriver]$Driver, 20 | [timespan]$Timeout 21 | ) 22 | $Driver.Manage().Timeouts().ImplicitWait = $Timeout 23 | } 24 | 25 | -------------------------------------------------------------------------------- /Internal/Get-DriverProcessId.ps1: -------------------------------------------------------------------------------- 1 | function Get-DriverProcessId { 2 | [CmdletBinding()] 3 | param ( 4 | $ServiceProcessId 5 | ) 6 | 7 | $IsWindowsPowershell = $PSVersionTable.PSVersion.Major -lt 6 8 | 9 | if ($IsWindowsPowershell) { 10 | $Processes = Get-CimInstance -Class Win32_Process -Filter "ParentProcessId=$ServiceProcessId" 11 | $BrowserProcess = $Processes | Where-Object { $_.Name -ne 'conhost.exe' } | Select-Object -First 1 -ExpandProperty ProcessId 12 | } 13 | else { 14 | $BrowserProcess = (Get-Process).Where( { { $_.Parent.id -eq $ServiceProcessId -and $_.Name -ne 'conhost' } }, 'first').Id 15 | } 16 | return $BrowserProcess 17 | 18 | } -------------------------------------------------------------------------------- /Internal/Get-OptionsSwitchValue.ps1: -------------------------------------------------------------------------------- 1 |  2 | Function Get-OptionsSwitchValue($Switches, $Name) { 3 | if ($null -eq $Switches -or -not $Switches.Contains($Name)) { Return $false } 4 | return $True 5 | } -------------------------------------------------------------------------------- /Internal/Get-SeElementsConditionsValueType.ps1: -------------------------------------------------------------------------------- 1 | Function Get-SeElementsConditionsValueType($Text) { 2 | return $Script:SeElementsConditions.Where( { $_.Text -eq $Text }, 'first')[0].ValueType 3 | } -------------------------------------------------------------------------------- /Internal/Get-WildcardsIndices.ps1: -------------------------------------------------------------------------------- 1 | Function Get-WildcardsIndices($Value) { 2 | 3 | $Escape = 0 4 | $Index = -1 5 | $Value.ToCharArray() | ForEach-Object { 6 | $Index += 1 7 | $IsWildCard = $false 8 | switch ($_) { 9 | '`' { $Escape += 1; break } 10 | '*' { $IsWildCard = $Escape % 2 -eq 0; $Escape = 0 } 11 | Default { $Escape = 0 } 12 | } 13 | if ($IsWildCard) { return $Index } 14 | 15 | } 16 | } -------------------------------------------------------------------------------- /Internal/Init-SeDriver.ps1: -------------------------------------------------------------------------------- 1 | function Init-SeDriver { 2 | [CmdletBinding()] 3 | param ($Element) 4 | 5 | IF ($null -NE $Element) { 6 | $Driver = ($Element | Select-Object -First 1).WrappedDriver 7 | } 8 | $Driver = Get-SeDriver -Current -ErrorAction Stop 9 | 10 | if ($null -ne $Driver) { 11 | return $Driver 12 | } 13 | else { 14 | Throw [System.ArgumentNullException]::new("An available Driver could not be found.") 15 | } 16 | 17 | 18 | 19 | 20 | 21 | } 22 | 23 | 24 | -------------------------------------------------------------------------------- /Internal/Start-SeFirefoxDriver.ps1: -------------------------------------------------------------------------------- 1 | function Start-SeFirefoxDriver { 2 | [cmdletbinding(DefaultParameterSetName = 'default')] 3 | param( 4 | [string]$StartURL, 5 | [SeWindowState]$State, 6 | [System.IO.FileInfo]$DefaultDownloadPath, 7 | [switch]$PrivateBrowsing, 8 | [Double]$ImplicitWait, 9 | [System.Drawing.Size]$Size, 10 | [System.Drawing.Point]$Position, 11 | $WebDriverPath = $env:GeckoWebDriver, 12 | $BinaryPath, 13 | [OpenQA.Selenium.DriverService]$service, 14 | [OpenQA.Selenium.DriverOptions]$Options, 15 | [String[]]$Switches, 16 | [OpenQA.Selenium.LogLevel]$LogLevel, 17 | [String]$UserAgent, 18 | [Switch]$AcceptInsecureCertificates 19 | 20 | ) 21 | process { 22 | 23 | if ($State -eq [SeWindowState]::Headless) { 24 | $Options.AddArguments('-headless') 25 | } 26 | 27 | if ($DefaultDownloadPath) { 28 | Write-Verbose "Setting Default Download directory: $DefaultDownloadPath" 29 | $Options.setPreference("browser.download.folderList", 2); 30 | $Options.SetPreference("browser.download.dir", "$DefaultDownloadPath"); 31 | } 32 | 33 | if ($UserAgent) { 34 | Write-Verbose "Setting User Agent: $UserAgent" 35 | $Options.SetPreference("general.useragent.override", $UserAgent) 36 | } 37 | 38 | if ($AcceptInsecureCertificates) { 39 | Write-Verbose "AcceptInsecureCertificates capability set to: $($AcceptInsecureCertificates.IsPresent)" 40 | $Options.AddAdditionalCapability([OpenQA.Selenium.Remote.CapabilityType]::AcceptInsecureCertificates,$true,$true) 41 | } 42 | 43 | if ($PrivateBrowsing) { 44 | $Options.SetPreference("browser.privatebrowsing.autostart", $true) 45 | } 46 | 47 | if ($PSBoundParameters.ContainsKey('LogLevel')) { 48 | Write-Verbose "Setting Firefox LogLevel to $LogLevel" 49 | $Options.LogLevel = $LogLevel 50 | } 51 | 52 | if (-not $PSBoundParameters.ContainsKey('Service')) { 53 | $ServiceParams = @{} 54 | if ($WebDriverPath) { $ServiceParams.Add('WebDriverPath', $WebDriverPath) } 55 | $service = New-SeDriverService -Browser Firefox @ServiceParams 56 | } 57 | 58 | 59 | $Driver = [OpenQA.Selenium.Firefox.FirefoxDriver]::new($service, $Options) 60 | if (-not $Driver) { Write-Warning "Web driver was not created"; return } 61 | Add-Member -InputObject $Driver -MemberType NoteProperty -Name 'SeServiceProcessId' -Value $Service.ProcessID 62 | #region post creation options 63 | $Driver.Manage().Timeouts().ImplicitWait = [TimeSpan]::FromMilliseconds($ImplicitWait * 1000) 64 | 65 | if ($PSBoundParameters.ContainsKey('Size')) { $Driver.Manage().Window.Size = $Size } 66 | if ($PSBoundParameters.ContainsKey('Position')) { $Driver.Manage().Window.Position = $Position } 67 | 68 | # [SeWindowState] 69 | switch ($State) { 70 | { $_ -eq [SeWindowState]::Minimized } { $Driver.Manage().Window.Minimize(); break } 71 | { $_ -eq [SeWindowState]::Maximized } { $Driver.Manage().Window.Maximize() ; break } 72 | { $_ -eq [SeWindowState]::Fullscreen } { $Driver.Manage().Window.FullScreen() ; break } 73 | } 74 | 75 | if ($StartURL) { $Driver.Navigate().GoToUrl($StartURL) } 76 | #endregion 77 | 78 | Return $Driver 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /Internal/Start-SeInternetExplorerDriver.ps1: -------------------------------------------------------------------------------- 1 | function Start-SeInternetExplorerDriver { 2 | param( 3 | [string]$StartURL, 4 | [SeWindowState]$State, 5 | [System.IO.FileInfo]$DefaultDownloadPath, 6 | [switch]$PrivateBrowsing, 7 | [Double]$ImplicitWait, 8 | [System.Drawing.Size]$Size, 9 | [System.Drawing.Point]$Position, 10 | $WebDriverPath, 11 | $BinaryPath, 12 | [OpenQA.Selenium.DriverService]$service, 13 | [OpenQA.Selenium.DriverOptions]$Options, 14 | [String[]]$Switches, 15 | [OpenQA.Selenium.LogLevel]$LogLevel 16 | ) 17 | 18 | 19 | #region IE set-up options 20 | if ($state -eq [SeWindowState]::Headless -or $PrivateBrowsing) { Write-Warning 'The Internet explorer driver does not support headless or Inprivate operation; these switches are ignored' } 21 | 22 | $IgnoreProtectedModeSettings = Get-OptionsSwitchValue -Switches $Switches -Name 'IgnoreProtectedModeSettings' 23 | if ($IgnoreProtectedModeSettings) { 24 | $Options.IntroduceInstabilityByIgnoringProtectedModeSettings = $true 25 | } 26 | 27 | if ($StartURL) { $Options.InitialBrowserUrl = $StartURL } 28 | 29 | if (-not $PSBoundParameters.ContainsKey('Service')) { 30 | $ServiceParams = @{} 31 | if ($WebDriverPath) { $ServiceParams.Add('WebDriverPath', $WebDriverPath) } 32 | $service = New-SeDriverService -Browser InternetExplorer @ServiceParams 33 | } 34 | 35 | #endregion 36 | 37 | $Driver = [OpenQA.Selenium.IE.InternetExplorerDriver]::new($service, $Options) 38 | if (-not $Driver) { Write-Warning "Web driver was not created"; return } 39 | Add-Member -InputObject $Driver -MemberType NoteProperty -Name 'SeServiceProcessId' -Value $Service.ProcessID 40 | if ($PSBoundParameters.ContainsKey('LogLevel')) { 41 | Write-Warning "LogLevel parameter is not implemented for $($Options.SeParams.Browser)" 42 | } 43 | 44 | #region post creation options 45 | if ($PSBoundParameters.ContainsKey('Size')) { $Driver.Manage().Window.Size = $Size } 46 | if ($PSBoundParameters.ContainsKey('Position')) { $Driver.Manage().Window.Position = $Position } 47 | $Driver.Manage().Timeouts().ImplicitWait = [TimeSpan]::FromMilliseconds($ImplicitWait * 1000) 48 | 49 | 50 | switch ($State) { 51 | { $_ -eq [SeWindowState]::Minimized } { $Driver.Manage().Window.Minimize(); } 52 | { $_ -eq [SeWindowState]::Maximized } { $Driver.Manage().Window.Maximize() } 53 | { $_ -eq [SeWindowState]::Fullscreen } { $Driver.Manage().Window.FullScreen() } 54 | } 55 | 56 | #endregion 57 | 58 | return $Driver 59 | } -------------------------------------------------------------------------------- /Internal/Start-SeMSEdgeDriver.ps1: -------------------------------------------------------------------------------- 1 | function Start-SeMSEdgeDriver { 2 | param( 3 | [ValidateURIAttribute()] 4 | [Parameter(Position = 1)] 5 | [string]$StartURL, 6 | [SeWindowState]$State, 7 | [System.IO.FileInfo]$DefaultDownloadPath, 8 | [switch]$PrivateBrowsing, 9 | [Double]$ImplicitWait, 10 | [System.Drawing.Size]$Size, 11 | [System.Drawing.Point]$Position, 12 | $WebDriverPath, 13 | $BinaryPath, 14 | [OpenQA.Selenium.DriverService]$service, 15 | [OpenQA.Selenium.DriverOptions]$Options, 16 | [String[]]$Switches, 17 | [OpenQA.Selenium.LogLevel]$LogLevel 18 | ) 19 | #region Edge set-up options 20 | if ($state -eq [SeWindowState]::Headless) { Write-Warning 'Pre-Chromium Edge does not support headless operation; the Headless switch is ignored' } 21 | 22 | if (-not $PSBoundParameters.ContainsKey('Service')) { 23 | $ServiceParams = @{} 24 | #if ($WebDriverPath) { $ServiceParams.Add('WebDriverPath', $WebDriverPath) } 25 | $service = New-SeDriverService -Browser MSEdge @ServiceParams -ErrorAction Stop 26 | } 27 | 28 | if ($PrivateBrowsing) { $options.UseInPrivateBrowsing = $true } 29 | if ($StartURL) { $options.StartPage = $StartURL } 30 | #endregion 31 | 32 | if ($PSBoundParameters.ContainsKey('LogLevel')) { 33 | Write-Warning "LogLevel parameter is not implemented for $($Options.SeParams.Browser)" 34 | } 35 | 36 | try { 37 | $Driver = [OpenQA.Selenium.Edge.EdgeDriver]::new($service , $options) 38 | } 39 | catch { 40 | $driverversion = (Get-Item .\assemblies\MicrosoftWebDriver.exe).VersionInfo.ProductVersion 41 | $WindowsVersion = [System.Environment]::OSVersion.Version.ToString() 42 | Write-Warning -Message "Edge driver is $driverversion. Windows is $WindowsVersion. If the driver is out-of-date, update it as a Windows feature,`r`nand then delete $PSScriptRoot\assemblies\MicrosoftWebDriver.exe" 43 | throw $_ ; return 44 | } 45 | if (-not $Driver) { Write-Warning "Web driver was not created"; return } 46 | Add-Member -InputObject $Driver -MemberType NoteProperty -Name 'SeServiceProcessId' -Value $Service.ProcessID 47 | #region post creation options 48 | if ($PSBoundParameters.ContainsKey('Size')) { $Driver.Manage().Window.Size = $Size } 49 | if ($PSBoundParameters.ContainsKey('Position')) { $Driver.Manage().Window.Position = $Position } 50 | $Driver.Manage().Timeouts().ImplicitWait = [TimeSpan]::FromMilliseconds($ImplicitWait * 1000) 51 | 52 | switch ($State) { 53 | { $_ -eq [SeWindowState]::Minimized } { $Driver.Manage().Window.Minimize() } 54 | { $_ -eq [SeWindowState]::Maximized } { $Driver.Manage().Window.Maximize() } 55 | { $_ -eq [SeWindowState]::Fullscreen } { $Driver.Manage().Window.FullScreen() } 56 | } 57 | 58 | #endregion 59 | 60 | Return $Driver 61 | } -------------------------------------------------------------------------------- /Internal/Test-SeDriverAcceptInsecureCertificates.ps1: -------------------------------------------------------------------------------- 1 | function Test-SeDriverAcceptInsecureCertificates { 2 | [CmdletBinding()] 3 | param ( 4 | $Browser, [ref]$AcceptInsecureCertificates, 5 | $Boundparameters 6 | ) 7 | 8 | $SupportedBrowsers = @('Chrome','Edge','Firefox') 9 | if ($Browser -in $SupportedBrowsers) { 10 | return 11 | } 12 | else { 13 | Throw ([System.NotImplementedException]::new(@" 14 | AcceptInsecureCertificates parameter is only supported by the following browser: $($SupportedBrowsers -join ',') 15 | Selected browser: $Browser 16 | "@)) 17 | } 18 | } -------------------------------------------------------------------------------- /Internal/Test-SeDriverConditionsValueValidation.ps1: -------------------------------------------------------------------------------- 1 | function Test-SeDriverConditionsValueValidation { 2 | [CmdletBinding()] 3 | param ( 4 | $Condition, $Value 5 | ) 6 | 7 | if ($PSBoundParameters.ContainsKey('Condition')) { 8 | $ConditionValueType = $Script:SeDriverConditions.Where( { $_.Text -eq $Condition }, 'first')[0].ValueType 9 | 10 | if ($null -eq $ConditionValueType) { 11 | Throw "The condition $Condition do not accept value" 12 | } 13 | elseif ($Value -isnot $ConditionValueType) { 14 | Throw "The condition $Condition accept only value of type $ConditionValueType. The value provided was of type $($Value.GetType())" 15 | } 16 | else { 17 | return 18 | } 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /Internal/Test-SeDriverUserAgent.ps1: -------------------------------------------------------------------------------- 1 | function Test-SeDriverUserAgent { 2 | [CmdletBinding()] 3 | param ( 4 | $Browser, [ref]$UserAgent, 5 | $Boundparameters 6 | ) 7 | 8 | $SupportedBrowsers = @('Chrome', 'Firefox') 9 | if ($Browser -in $SupportedBrowsers) { 10 | return 11 | } 12 | else { 13 | Throw ([System.NotImplementedException]::new(@" 14 | UserAgent parameter is only supported by the following browser: $($SupportedBrowsers -join ',') 15 | Selected browser: $Browser 16 | "@)) 17 | } 18 | } -------------------------------------------------------------------------------- /Internal/Test-SeElementConditionsValueValidation.ps1: -------------------------------------------------------------------------------- 1 | function Test-SeElementConditionsValueValidation { 2 | Param( 3 | $Element, 4 | $By, 5 | $Condition, 6 | $ConditionValue, 7 | $ParameterSetName 8 | ) 9 | # 0: All; 10 | # 1: By 11 | # 2: Element 12 | 13 | $ConditionDetails = $Script:SeElementsConditions.Where( { $_.Text -eq $Condition }, 'first')[0] 14 | 15 | switch ($ParameterSetName) { 16 | 'Locator' { 17 | if ($ConditionDetails.By_Element -eq 2) { 18 | Throw "The condition $Condition can only be used with an element (`$Element)" 19 | } 20 | } 21 | 'Element' { 22 | if ($ConditionDetails.By_Element -eq 1) { 23 | Throw "The condition $Condition can only be used with a locator (`$By & `$Value)" 24 | } 25 | } 26 | } 27 | 28 | 29 | 30 | if ($null -ne $ConditionValue) { 31 | if ($null -eq $ConditionDetails.ValueType) { 32 | Throw "The condition $Condition do not accept value" 33 | } 34 | elseif ($ConditionValue -isnot $ConditionDetails.ValueType) { 35 | Throw "The condition $Condition accept only value of type $($ConditionDetails.ValueType). The value provided was of type $($ConditionValue.GetType())" 36 | } 37 | else { 38 | return 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Internal/Test-SeMouseActionValueValidation.ps1: -------------------------------------------------------------------------------- 1 | function Test-SeMouseActionValueValidation { 2 | [CmdletBinding()] 3 | Param( 4 | $Action, 5 | $ConditionValue 6 | ) 7 | 8 | $ConditionValueType = $Script:SeMouseAction.Where( { $_.Text -eq $Action }, 'first')[0].ValueType 9 | if ($null -eq $ConditionValueType) { 10 | Throw "The condition $Condition do not accept value" 11 | } 12 | elseif ($ConditionValue -isnot $ConditionValueType) { 13 | if ($ConditionValueType.FullName -eq 'System.Drawing.Point' -and $ConditionValue -is [String] -and ($ConditionValue -split '[,x]').Count -eq 2) { return $True } 14 | Throw "The condition $Condition accept only value of type $ConditionValueType. The value provided was of type $($ConditionValue.GetType())" 15 | } 16 | else { 17 | return $true 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Adam Driscoll 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Output/Selenium/Examples/_TestDependencies.ps1: -------------------------------------------------------------------------------- 1 | 2 | Function Get-DefaultParams() { 3 | if ($null -eq $Global:DefaultBrowser) { $Global:DefaultBrowser = 'Firefox' } 4 | if ($null -eq $env:SITE_URL) { $env:SITE_URL = 'http://tailspin-spacegame-web.azurewebsites.net' } 5 | if ($null -eq $Global:HeadlessOnly) { $Global:HeadlessOnly = $False } 6 | } 7 | Get-DefaultParams 8 | 9 | 10 | Function Get-TestCasesSettings() { 11 | $HeadlessState = if ($Global:HeadlessOnly) { 'Headless' } else { 'Maximized' } 12 | return @{ 13 | 'NewEdge' = @{ 14 | DefaultOptions = @{State = $HeadlessState } 15 | PrivateOptions = @{ 16 | PrivateBrowsing = $true 17 | State = $HeadlessState 18 | } 19 | # InPrivateLabel = 'InPrivate' 20 | } # broken after build 79 of web driver#> 21 | 'Chrome' = @{ 22 | PrivateOptions = @{ 23 | PrivateBrowsing = $true 24 | State = $HeadlessState 25 | } 26 | DefaultOptions = @{State = $HeadlessState } 27 | HeadlessOptions = @{State = 'Headless' } 28 | } 29 | 'Firefox' = @{ 30 | PrivateOptions = @{ 31 | PrivateBrowsing = $true 32 | State = $HeadlessState 33 | } 34 | DefaultOptions = @{State = $HeadlessState } 35 | HeadlessOptions = @{State = 'Headless' } 36 | } 37 | 'MSEdge' = @{ 38 | DefaultOptions = @{State = $HeadlessState } 39 | PrivateOptions = @{PrivateBrowsing = $true } 40 | } 41 | 'InternetExplorer' = @{ 42 | DefaultOptions = @{ImplicitWait = 30 } 43 | PrivateOptions = @{ImplicitWait = 30 } 44 | } 45 | } 46 | } 47 | 48 | function Build-StringFromHash { 49 | param ($Hash) 50 | $(foreach ($k in $Hash.Keys) { "$K`:$($hash[$K])" }) -join '; ' 51 | } 52 | 53 | 54 | 55 | function Get-ModalTestCases() { 56 | return @( 57 | @{Name = 'Download Page' 58 | linkXPath = '/html/body/div/div/section[2]/div[2]/a' 59 | modalXPath = '//*[@id="pretend-modal"]/div/div' 60 | }, 61 | @{Name = 'Screen Image' 62 | linkXPath = '/html/body/div/div/section[3]/div/ul/li[1]/a' 63 | modalXPath = '/html/body/div[1]/div/div[2]' 64 | }, 65 | @{Name = 'Top Player' 66 | linkXPath = '/html/body/div/div/section[4]/div/div/div[1]/div[2]/div[2]/div/a/div' 67 | modalXPath = '//*[@id="profile-modal-1"]/div/div' 68 | } 69 | ) 70 | } 71 | -------------------------------------------------------------------------------- /Output/Selenium/Examples/comparison.ps1: -------------------------------------------------------------------------------- 1 | 2 | <# 3 | public void testClass() throws Exception { 4 | driver.get("http://www.wikipedia.org/") ; 5 | Assert.assertequals("wikipedia", driver.getTitle()); 6 | Assert.assertequals("English", driver.findElement(By.cssselector("strong")).getText()) 7 | driver.findElement(By.cssSetector("strong")).click() ; 8 | Assert.assertEquals("Wikipedia. the free encyclopedia", driver.getTitle()); 9 | } 10 | #> 11 | Start-SeDriver -Browser Chrome -StartURL "https://www.wikipedia.org/" 12 | SeShouldHave -Title eq Wikipedia 13 | SeShouldHave 'strong' -By CssSelector -With Text eq 'English' -PassThru | Invoke-SeClick 14 | SeShouldHave -Title eq 'Wikipedia, the free encyclopedia' 15 | 16 | <# 17 | line 2 ## SeShouldHave -Title eq Wikipedia 18 | is actutally short for ## SeShouldHave -Title -Operator 'eq' -Value Wikipedia 19 | other values for -operator will translate to "eq", and parameters are defined so you can use -eq -contains, -match etc 20 | so you can use ## SeShouldHave -Title equalTo Wikipedia 21 | or ## SeShouldHave -Title -eq Wikipedia 22 | line 3 ## SeShouldHave 'strong' -By CssSelector Text eq 'English' 23 | This is short for ## SeShouldHave -Selection 'strong' -By CssSelector -With Text -operator "eq" -value 'English' 24 | if the selector is an xPath the -By parameter can be omitted; but if used -By must specified explicitly 25 | The first unnamed parameter will be treated as selection, the second as "with" , the third as operator and the fourth as value. 26 | SeShouldhave can take a -passthru parameter allowing the original lines 3 and 4 to be merged, 27 | 28 | The last line 5 is similar to line 2 but the parameter value has a sppace so must be wrapped in quotes 29 | #> 30 | 31 | <#https://www.guru99.com/first-webdriver-script.html had this 32 | public static void main(String[] args) { 33 | System.setProperty("webdriver.gecko.driver","C:\\geckodriver.exe"); 34 | WebDriver driver = new FirefoxDriver(); 35 | //comment the above 2 lines and uncomment below 2 lines to use Chrome 36 | //System.setProperty("webdriver.chrome.driver","G:\\chromedriver.exe"); 37 | //WebDriver driver = new ChromeDriver(); 38 | 39 | String baseUrl = "http://demo.guru99.com/test/newtours/"; 40 | driver.get(baseUrl); 41 | 42 | String expectedTitle = "Welcome: Mercury Tours"; 43 | String actualTitle = ""; 44 | actualTitle = driver.getTitle(); 45 | if (actualTitle.contentEquals(expectedTitle)){ 46 | System.out.println("Test Passed!"); 47 | } else { 48 | System.out.println("Test Failed"); 49 | } 50 | 51 | driver.close(); 52 | } 53 | #> 54 | 55 | Start-SeDriver -Browser Firefox -StartURL "http://demo.guru99.com/test/newtours/" 56 | SeShouldHave -Title eq "Welcome: Mercury Tours" 57 | 58 | #Stop opened drivers 59 | Get-SeDriver | Stop-SeDriver 60 | 61 | -------------------------------------------------------------------------------- /Output/Selenium/Selenium-Binary-Updater.ps1: -------------------------------------------------------------------------------- 1 | param( 2 | [Parameter(Mandatory=$true)][ValidateSet('Chrome','Firefox','Edge')]$Browser 3 | ) 4 | 5 | $TempDir = [System.IO.Path]::GetTempPath() 6 | 7 | switch ($Browser){ 8 | 'Chrome'{ 9 | $LatestChromeStableRelease = Invoke-WebRequest 'https://chromedriver.storage.googleapis.com/LATEST_RELEASE' | Select-Object -ExpandProperty Content 10 | $ChromeBuilds = @('chromedriver_linux64','chromedriver_mac64','chromedriver_win32') 11 | 12 | foreach ($Build in $ChromeBuilds){ 13 | switch($Build){ 14 | 'chromedriver_linux64'{ 15 | $AssembliesDir = "$PSScriptRoot/assemblies/linux" 16 | $BinaryFileName = 'chromedriver' 17 | } 18 | 'chromedriver_mac64'{ 19 | $AssembliesDir = "$PSScriptRoot/assemblies/macos" 20 | $BinaryFileName = 'chromedriver' 21 | } 22 | 'chromedriver_win32'{ 23 | $AssembliesDir = "$PSScriptRoot/assemblies" 24 | $BinaryFileName = 'chromedriver.exe' 25 | } 26 | default{throw 'Incorrect Build Type'} 27 | } 28 | 29 | $BuildFileName = "$Build.zip" 30 | Write-Verbose "Downloading: $BuildFileName" 31 | Invoke-WebRequest -OutFile "$($TempDir + $BuildFileName)" "https://chromedriver.storage.googleapis.com/$LatestChromeStableRelease/$BuildFileName" 32 | 33 | # Expand the ZIP Archive to the correct Assemblies Dir 34 | Write-Verbose "Explanding: $($TempDir + $BuildFileName) to $AssembliesDir" 35 | Expand-Archive -Path "$($TempDir + $BuildFileName)" -DestinationPath $AssembliesDir -Force 36 | 37 | # Generate Hash Files 38 | Write-Verbose "Generating SHA256 Hash File: $AssembliesDir/$BinaryFileName.sha256" 39 | Get-FileHash -Path "$AssembliesDir/$BinaryFileName" -Algorithm SHA256 | Select-Object -ExpandProperty Hash | Set-Content -Path "$AssembliesDir/$BinaryFileName.sha256" -Force 40 | 41 | } 42 | } 43 | 'Firefox'{ 44 | Write-Host 'Not Supported Yet' 45 | 46 | } 47 | 'Edge'{ 48 | Write-Host 'Not Supported Yet' 49 | } 50 | } -------------------------------------------------------------------------------- /Output/Selenium/Selenium.psm1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamdriscoll/selenium-powershell/50c5d39822f2ac341b6198502991b80dbb5786e0/Output/Selenium/Selenium.psm1 -------------------------------------------------------------------------------- /Output/Selenium/assemblies/IEDriverServer.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamdriscoll/selenium-powershell/50c5d39822f2ac341b6198502991b80dbb5786e0/Output/Selenium/assemblies/IEDriverServer.exe -------------------------------------------------------------------------------- /Output/Selenium/assemblies/IEDriverServer.exe.sha256: -------------------------------------------------------------------------------- 1 | 51053574E3BA3AB5D9F47E13EC0E9961AD6C9C9978DC851BE71C0F86A272C74B 2 | -------------------------------------------------------------------------------- /Output/Selenium/assemblies/WebDriver.Support.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamdriscoll/selenium-powershell/50c5d39822f2ac341b6198502991b80dbb5786e0/Output/Selenium/assemblies/WebDriver.Support.dll -------------------------------------------------------------------------------- /Output/Selenium/assemblies/WebDriver.Support.dll.sha256: -------------------------------------------------------------------------------- 1 | B59BA7D0CFFE43E722B13AD737CF596F030788B86B5B557CB479F0B6957CCE8A 2 | -------------------------------------------------------------------------------- /Output/Selenium/assemblies/WebDriver.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamdriscoll/selenium-powershell/50c5d39822f2ac341b6198502991b80dbb5786e0/Output/Selenium/assemblies/WebDriver.dll -------------------------------------------------------------------------------- /Output/Selenium/assemblies/WebDriver.dll.sha256: -------------------------------------------------------------------------------- 1 | 0EE619B1786CF5971C0F9C6EE1859497AECBA93A4953CF92FEA998E8EEFADF3C 2 | -------------------------------------------------------------------------------- /Output/Selenium/assemblies/chromedriver.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamdriscoll/selenium-powershell/50c5d39822f2ac341b6198502991b80dbb5786e0/Output/Selenium/assemblies/chromedriver.exe -------------------------------------------------------------------------------- /Output/Selenium/assemblies/chromedriver.exe.sha256: -------------------------------------------------------------------------------- 1 | C6131A3106A8956702459673BDCC7F37BDD8989A141D2CBE15DC0157F0D53C74 2 | -------------------------------------------------------------------------------- /Output/Selenium/assemblies/geckodriver.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamdriscoll/selenium-powershell/50c5d39822f2ac341b6198502991b80dbb5786e0/Output/Selenium/assemblies/geckodriver.exe -------------------------------------------------------------------------------- /Output/Selenium/assemblies/geckodriver.exe.sha256: -------------------------------------------------------------------------------- 1 | FAED02EC5B0D6246856843D10EE020CB5121B8261AC939BE761130F21A73D3EE 2 | -------------------------------------------------------------------------------- /Output/Selenium/assemblies/linux/chromedriver: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamdriscoll/selenium-powershell/50c5d39822f2ac341b6198502991b80dbb5786e0/Output/Selenium/assemblies/linux/chromedriver -------------------------------------------------------------------------------- /Output/Selenium/assemblies/linux/chromedriver.sha256: -------------------------------------------------------------------------------- 1 | 01112975217552167F101D7B549D31A12B3C45ABE411892F92228BF8CB2F0058 2 | -------------------------------------------------------------------------------- /Output/Selenium/assemblies/linux/geckodriver: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamdriscoll/selenium-powershell/50c5d39822f2ac341b6198502991b80dbb5786e0/Output/Selenium/assemblies/linux/geckodriver -------------------------------------------------------------------------------- /Output/Selenium/assemblies/linux/geckodriver.sha256: -------------------------------------------------------------------------------- 1 | 0B2C9B9791925DCEA2981CBDFAB8274FB4668BF65D6A57C2257E8B57757C394A 2 | -------------------------------------------------------------------------------- /Output/Selenium/assemblies/macos/chromedriver: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamdriscoll/selenium-powershell/50c5d39822f2ac341b6198502991b80dbb5786e0/Output/Selenium/assemblies/macos/chromedriver -------------------------------------------------------------------------------- /Output/Selenium/assemblies/macos/chromedriver.sha256: -------------------------------------------------------------------------------- 1 | 1DA3E0CBF79A92CF06B08812A39991A37B5C5458DEC2A7B4FFF34F6D87126281 2 | -------------------------------------------------------------------------------- /Output/Selenium/assemblies/macos/geckodriver: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamdriscoll/selenium-powershell/50c5d39822f2ac341b6198502991b80dbb5786e0/Output/Selenium/assemblies/macos/geckodriver -------------------------------------------------------------------------------- /Output/Selenium/assemblies/macos/geckodriver.sha256: -------------------------------------------------------------------------------- 1 | AA2FCE6B96183C9D8FD0AA125F87557FCCEC60301CF7ADD1578B0DA59355AD8B 2 | -------------------------------------------------------------------------------- /Output/Selenium/assemblies/msedgedriver.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamdriscoll/selenium-powershell/50c5d39822f2ac341b6198502991b80dbb5786e0/Output/Selenium/assemblies/msedgedriver.exe -------------------------------------------------------------------------------- /Output/Selenium/assemblies/msedgedriver.exe.sha256: -------------------------------------------------------------------------------- 1 | A6EB02FF3EF75079A647F20BD0B6B563648BC4C8563443229C65671AB0BBB6CD 2 | -------------------------------------------------------------------------------- /Output/Selenium/types/Selenium.types.ps1xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | OpenQA.Selenium.Remote.RemoteWebElement 6 | 7 | 8 | PSStandardMembers 9 | 10 | 11 | DefaultDisplayPropertySet 12 | 13 | Tagname 14 | Enabled 15 | Displayed 16 | Text 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | OpenQA.Selenium.Remote.RemoteWebDriver 25 | 26 | 27 | PSStandardMembers 28 | 29 | 30 | DefaultDisplayPropertySet 31 | 32 | SeFriendlyName 33 | SeBrowser 34 | SeTitle 35 | SeUrl 36 | 37 | 38 | 39 | 40 | 41 | SeUrl 42 | 43 | if ($null -ne $this.SessionId) { $this.Url } 44 | 45 | 46 | 47 | SeTitle 48 | 49 | if ($null -ne $this.SessionId) { $this.Title } 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /Public/Clear-SeAlert.ps1: -------------------------------------------------------------------------------- 1 | function Clear-SeAlert { 2 | [CmdletBinding()] 3 | param ( 4 | [ValidateSet('Accept', 'Dismiss')] 5 | $Action = 'Dismiss', 6 | [parameter(ParameterSetName = 'Alert', ValueFromPipeline = $true)] 7 | $Alert, 8 | [switch]$PassThru 9 | ) 10 | Begin { 11 | $Driver = Init-SeDriver -ErrorAction Stop 12 | $ImpTimeout = 0 13 | } 14 | Process { 15 | if ($Driver) { 16 | try { 17 | $ImpTimeout = Disable-SeDriverImplicitTimeout -Driver $Driver 18 | $WebDriverWait = [OpenQA.Selenium.Support.UI.WebDriverWait]::new($Driver, (New-TimeSpan -Seconds 10)) 19 | $Condition = [OpenQA.Selenium.Support.UI.ExpectedConditions]::AlertIsPresent() 20 | $WebDriverWait.Until($Condition) 21 | $Alert = $Driver.SwitchTo().alert() 22 | } 23 | catch { 24 | Write-Warning 'No alert was displayed' 25 | return 26 | } 27 | Finally { 28 | Enable-SeDriverImplicitTimeout -Driver $Driver -Timeout $ImpTimeout 29 | } 30 | } 31 | if ($Alert) { $alert.$action() } 32 | if ($PassThru) { $Alert } 33 | } 34 | End {} 35 | } 36 | 37 | -------------------------------------------------------------------------------- /Public/Clear-SeSelectValue.ps1: -------------------------------------------------------------------------------- 1 | function Clear-SeSelectValue { 2 | [Cmdletbinding()] 3 | param ( 4 | [Parameter(Mandatory = $true)] 5 | [OpenQA.Selenium.IWebElement]$Element 6 | ) 7 | [SeleniumSelection.Option]::DeselectAll($Element) 8 | 9 | } 10 | 11 | -------------------------------------------------------------------------------- /Public/Get-SeCookie.ps1: -------------------------------------------------------------------------------- 1 | function Get-SeCookie { 2 | [CmdletBinding()] 3 | param() 4 | $Driver = Init-SeDriver -ErrorAction Stop 5 | $Driver.Manage().Cookies.AllCookies.GetEnumerator() 6 | } -------------------------------------------------------------------------------- /Public/Get-SeDriver.ps1: -------------------------------------------------------------------------------- 1 | 2 | function Get-SeDriver { 3 | [cmdletbinding(DefaultParameterSetName = 'All')] 4 | param( 5 | [parameter(ParameterSetName = 'Current', Mandatory = $false)] 6 | [Switch]$Current, 7 | [parameter(Position = 0, ParameterSetName = 'ByName', Mandatory = $false)] 8 | [String]$Name, 9 | [parameter(ParameterSetName = 'ByBrowser', Mandatory = $false)] 10 | [ArgumentCompleter( { [Enum]::GetNames([SeBrowsers]) })] 11 | [ValidateScript( { $_ -in [Enum]::GetNames([SeBrowsers]) })] 12 | $Browser 13 | 14 | 15 | 16 | ) 17 | 18 | $Output = $null 19 | switch ($PSCmdlet.ParameterSetName) { 20 | 'All' { $Output = $Script:SeDrivers; break } 21 | 'Current' { $Output = $Script:SeDriversCurrent; break } 22 | 'ByName' { $Output = $Script:SeDrivers.Where( { $_.SeFriendlyName -eq $Name }, 'first' ); break } 23 | 'ByBrowser' { $Output = $Script:SeDrivers.Where( { $_.SeBrowser -like "$Browser*" }); break } 24 | } 25 | 26 | if ($null -eq $Output) { return } 27 | 28 | $DriversToClose = [System.Collections.Generic.List[PSObject]]::new() 29 | Foreach ($drv in $Output) { 30 | $Processes = (Get-Process -Id $Drv.SeProcessId, $Drv.SeServiceProcessId -ErrorAction SilentlyContinue ) 31 | if ($Processes.count -eq 2) { Continue } 32 | 33 | if ($Processes.count -eq 0) { 34 | Write-Warning -Message "The driver $($Drv.SeFriendlyName) $($Drv.SeBrowser) processes are not running anymore and have been removed automatically from the list of available drivers." 35 | } 36 | else { 37 | $ProcessType = if ($Processes.id -eq $Drv.SeServiceProcessId) { "driver service" } else { "browser" } 38 | Write-Warning -Message "The driver $($Drv.SeFriendlyName) $($Drv.SeBrowser) $ProcessType is not running anymore and will be removed from the active driver list." 39 | } 40 | $DriversToClose.Add($Drv) 41 | } 42 | 43 | if ($DriversToClose.Count -gt 0) { 44 | foreach ($drv in $DriversToClose) { 45 | $Output = $Output.Where( { $_.SeServiceProcessId -ne $drv.SeServiceProcessId }) 46 | Stop-SeDriver -Driver $drv 47 | } 48 | } 49 | return $Output 50 | } -------------------------------------------------------------------------------- /Public/Get-SeDriverTimeout.ps1: -------------------------------------------------------------------------------- 1 | function Get-SeDriverTimeout { 2 | [CmdletBinding()] 3 | param( 4 | [Parameter(Position = 0)] 5 | [ValidateSet('ImplicitWait', 'PageLoad', 'AsynchronousJavaScript')] 6 | $TimeoutType = 'ImplicitWait' 7 | ) 8 | begin { 9 | $Driver = Init-SeDriver -ErrorAction Stop 10 | } 11 | Process { 12 | return $Driver.Manage().Timeouts().$TimeoutType 13 | } 14 | End {} 15 | } 16 | 17 | -------------------------------------------------------------------------------- /Public/Get-SeElementAttribute.ps1: -------------------------------------------------------------------------------- 1 | function Get-SeElementAttribute { 2 | [CmdletBinding()] 3 | param( 4 | [Parameter(ValueFromPipeline = $true, Mandatory = $true)] 5 | [OpenQA.Selenium.IWebElement]$Element, 6 | [Parameter(Mandatory = $true)] 7 | [string[]]$Name 8 | ) 9 | Begin { 10 | $Script = 'var items = {}; for (index = 0; index < arguments[0].attributes.length; ++index) { items[arguments[0].attributes[index].name] = arguments[0].attributes[index].value }; return items;' 11 | } 12 | process { 13 | $AllAttributes = $Name.Count -eq 1 -and $Name[0] -eq '*' 14 | $ManyAttributes = $Name.Count -gt 1 15 | 16 | if ($AllAttributes) { 17 | $AllAttributes = $Element.WrappedDriver.ExecuteScript($Script, $Element) 18 | $Output = @{} 19 | 20 | Foreach ($Att in $AllAttributes.Keys) { 21 | $value = $Element.GetAttribute($Att) 22 | if ($value -ne "") { 23 | $Output.$Att = $value 24 | } 25 | } 26 | $Output 27 | } 28 | elseif ($ManyAttributes) { 29 | $Output = @{} 30 | Foreach ($Att in $Name) { 31 | $value = $Element.GetAttribute($Att) 32 | if ($value -ne "") { 33 | $Output.$Att = $value 34 | } 35 | } 36 | $Output 37 | } 38 | else { 39 | $Element.GetAttribute($Name) 40 | } 41 | 42 | 43 | } 44 | } -------------------------------------------------------------------------------- /Public/Get-SeElementCssValue.ps1: -------------------------------------------------------------------------------- 1 | function Get-SeElementCssValue { 2 | [CmdletBinding()] 3 | param( 4 | [Parameter(ValueFromPipeline = $true, Mandatory = $true)] 5 | [OpenQA.Selenium.IWebElement]$Element, 6 | [Parameter(Mandatory = $true)] 7 | [string[]]$Name 8 | ) 9 | Begin { 10 | $ScriptAllValues = @' 11 | var items = {}; 12 | var o = getComputedStyle(arguments[0]); 13 | for(var i = 0; i < o.length; i++){ 14 | items[o[i]] = o.getPropertyValue(o[i]) 15 | } 16 | return items; 17 | '@ 18 | } 19 | Process { 20 | $AllValues = $Name.Count -eq 1 -and $Name[0] -eq '*' 21 | $ManyValues = $Name.Count -gt 1 22 | 23 | 24 | if ($AllValues) { 25 | 26 | $AllCSSNames = $Element.WrappedDriver.ExecuteScript($ScriptAllValues, $Element) 27 | $Output = @{} 28 | 29 | Foreach ($Att in $AllCSSNames.Keys) { 30 | $value = $Element.GetCssValue($Att) 31 | if ($value -ne "") { 32 | $Output.$Att = $value 33 | } 34 | } 35 | [PSCustomObject]$Output 36 | } 37 | elseif ($ManyValues) { 38 | $Output = @{} 39 | Foreach ($Item in $Name) { 40 | $Value = $Element.GetCssValue($Item) 41 | if ($Value -ne "") { 42 | $Output.$Item = $Value 43 | } 44 | } 45 | [PSCustomObject]$Output 46 | } 47 | else { 48 | $Element.GetCssValue($Name) 49 | } 50 | 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Public/Get-SeFrame.ps1: -------------------------------------------------------------------------------- 1 | function Get-SeFrame { 2 | [cmdletbinding()] 3 | param() 4 | 5 | $Driver = Init-SeDriver -ErrorAction Stop 6 | 7 | Get-SeElement -By TagName -Value iframe -Attributes name, id -ErrorAction SilentlyContinue | 8 | ForEach-Object { 9 | $_.Psobject.TypeNames.Insert(0, 'selenium-powershell/SeFrame') 10 | $_ 11 | } 12 | 13 | } 14 | 15 | -------------------------------------------------------------------------------- /Public/Get-SeHtml.ps1: -------------------------------------------------------------------------------- 1 | function Get-SeHtml { 2 | [CmdletBinding()] 3 | param( 4 | [Parameter(ValueFromPipeline = $true)] 5 | [OpenQA.Selenium.IWebElement]$Element, 6 | [switch]$Inner 7 | ) 8 | Begin { 9 | $Driver = Init-SeDriver -ErrorAction Stop 10 | } 11 | Process { 12 | if ($PSBoundParameters.ContainsKey('Element')) { 13 | if ($Inner) { return $Element.GetAttribute('innerHTML') } 14 | return $Element.GetAttribute('outerHTML') 15 | } 16 | else { 17 | $Driver.PageSource 18 | } 19 | 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /Public/Get-SeInput.ps1: -------------------------------------------------------------------------------- 1 | function Get-SeInput { 2 | [CmdletBinding()] 3 | param( 4 | [ArgumentCompleter( { @('button', 'checkbox', 'color', 'date', 'datetime-local', 'email', 'file', 'hidden', 'image', 'month', 'number', 'password', 'radio', 'range', 'reset', 'search', 'submit', 'tel', 'text', 'time', 'url', 'week') })] 5 | [String]$Type, 6 | [Switch]$Single, 7 | [String]$Text, 8 | [Double]$Timeout, 9 | [Switch]$All, 10 | [String[]]$Attributes, 11 | [String]$Value 12 | 13 | 14 | ) 15 | Begin { 16 | $Driver = Init-SeDriver -ErrorAction Stop 17 | } 18 | Process { 19 | $MyAttributes = @{Attributes = [System.Collections.Generic.List[String]]::new()} 20 | $SelectedAttribute = "" 21 | $LoadAllAttributes = $false 22 | 23 | if ($PSBoundParameters.Remove('Attributes')) { 24 | $MyAttributes = @{Attributes = [System.Collections.Generic.List[String]]$Attributes } 25 | $LoadAllAttributes = $Attributes.Count -eq 1 -and $Attributes[0] -eq '*' 26 | if ($Attributes[0] -ne '*') { $SelectedAttribute = $MyAttributes.Attributes[0] } 27 | } 28 | 29 | if (!$LoadAllAttributes){ 30 | if ($PSBoundParameters.Remove('Type')) { 31 | if (-not $MyAttributes.Attributes.Contains('type')) { $MyAttributes.Attributes.add('type') } 32 | } 33 | if (-not $MyAttributes.Attributes.Contains('placeholder')) { $MyAttributes.Attributes.add('placeholder') } 34 | if (-not $MyAttributes.Attributes.Contains('value')) { $MyAttributes.Attributes.add('value') } 35 | } 36 | 37 | 38 | [void]($PSBoundParameters.Remove('Value')) 39 | 40 | $Filter = [scriptblock]::Create(@" 41 | if ("" -ne "$Type") { if (`$_.Attributes.type -ne "$type") { return } } 42 | if ("" -ne "$Text") { if (`$_.Text -ne "$Text" ) { return } } 43 | if ("" -ne "$Value" -and "" -ne "$SelectedAttribute") { if (`$_.Attributes."$SelectedAttribute" -ne "$Value" ) { return } } 44 | `$_ 45 | "@) 46 | 47 | Get-SeElement -By TagName -Value input @PSBoundParameters @MyAttributes -Filter $Filter | ForEach-Object { 48 | $_.Psobject.TypeNames.Insert(0, 'selenium-powershell/SeInput') 49 | $_ 50 | } 51 | 52 | } 53 | } 54 | 55 | -------------------------------------------------------------------------------- /Public/Get-SeKeys.ps1: -------------------------------------------------------------------------------- 1 | function Get-SeKeys { 2 | [OpenQA.Selenium.Keys] | 3 | Get-Member -MemberType Property -Static | 4 | Select-Object -Property Name, @{N = "ObjectString"; E = { "[OpenQA.Selenium.Keys]::$($_.Name)" } } 5 | } -------------------------------------------------------------------------------- /Public/Get-SeSelectValue.ps1: -------------------------------------------------------------------------------- 1 | function Get-SeSelectValue { 2 | [CmdletBinding()] 3 | [cmdletbinding(DefaultParameterSetName = 'default')] 4 | param ( 5 | [Parameter( ValueFromPipeline = $true, Mandatory = $true, Position = 1)] 6 | [OpenQA.Selenium.IWebElement]$Element, 7 | [Switch]$All 8 | ) 9 | try { 10 | $IsMultiSelectResult = [SeleniumSelection.Option]::IsMultiSelect($Element) 11 | 12 | 13 | $SelectStatement = if ($IsMultiSelectResult) { 'GetAllSelectedOptions' } else { 'GetSelectedOption' } 14 | $Selected = [SeleniumSelection.Option]::$SelectStatement($Element) 15 | $Items = @(foreach ($item in $Selected) { 16 | [PSCustomObject]@{ 17 | Text = $Item.text 18 | Value = Get-SeElementAttribute -Element $Item -Name value 19 | } 20 | }) 21 | 22 | if (-not $All) { 23 | return $Items 24 | } 25 | else { 26 | 27 | $Index = 0 28 | $Options = Get-SeElement -Element $Element -By Tagname -Value option -Attributes value 29 | $Values = foreach ($Opt in $Options) { 30 | [PSCustomObject]@{ 31 | Index = $Index 32 | Text = $Opt.text 33 | Value = $opt.Attributes.value 34 | Selected = $Null -ne $Items.Value -and $Items.Value.Contains($opt.Attributes.value) 35 | } 36 | $Index += 1 37 | } 38 | return [PSCustomObject]@{ 39 | PSTypeName = 'selenium-powershell/SeSelectValueInfo' 40 | IsMultiSelect = [SeleniumSelection.Option]::IsMultiSelect($Element) 41 | Items = $Values 42 | } 43 | } 44 | 45 | 46 | 47 | } 48 | catch { 49 | throw "An error occured checking the selection box, the message was:`r`n $($_.exception.message)" 50 | } 51 | } -------------------------------------------------------------------------------- /Public/Get-SeUrl.ps1: -------------------------------------------------------------------------------- 1 | function Get-SeUrl { 2 | <# 3 | .SYNOPSIS 4 | Retrieves the current URL of a target webdriver instance. 5 | 6 | .DESCRIPTION 7 | Retrieves the current URL of a target webdriver instance, or the currently 8 | stored internal location stack. 9 | 10 | .EXAMPLE 11 | Get-SeUrl 12 | 13 | Retrieves the current URL of the default webdriver instance. 14 | 15 | .NOTES 16 | When using -Stack, the retrieved stack will not contain any of the driver's 17 | history (Back/Forward) data. It only handles locations added with 18 | Push-SeUrl. 19 | 20 | To utilise a driver's Back/Forward functionality, instead use Set-SeUrl. 21 | #> 22 | [CmdletBinding()] 23 | param( 24 | # Optionally retrieve the stored URL stack for the target or default 25 | # webdriver instance. 26 | [Parameter()] 27 | [switch] 28 | $Stack 29 | ) 30 | $Driver = Init-SeDriver -ErrorAction Stop 31 | 32 | if ($Stack) { 33 | if ($Script:SeLocationMap[$Driver].Count -gt 0) { 34 | $Script:SeLocationMap[$Driver].ToArray() 35 | } 36 | } 37 | else { 38 | $Driver.Url 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Public/Get-SeWindow.ps1: -------------------------------------------------------------------------------- 1 | function Get-SeWindow { 2 | [CmdletBinding()] 3 | param() 4 | begin { 5 | $Driver = Init-SeDriver -ErrorAction Stop 6 | } 7 | process { 8 | $Driver.WindowHandles 9 | } 10 | } -------------------------------------------------------------------------------- /Public/Invoke-SeClick.ps1: -------------------------------------------------------------------------------- 1 | function Invoke-SeClick { 2 | [CmdletBinding()] 3 | param( 4 | [parameter(Position = 0, HelpMessage = 'test')] 5 | [ArgumentCompleter([SeMouseClickActionCompleter])] 6 | [ValidateScript( { $_ -in $Script:SeMouseClickAction.Text })] 7 | $Action = 'Click', 8 | [Parameter( ValueFromPipeline = $true, Position = 1)] 9 | [ValidateNotNull()] 10 | [OpenQA.Selenium.IWebElement]$Element, 11 | [Double]$Sleep = 0 , 12 | [switch]$PassThru 13 | ) 14 | 15 | begin { 16 | $Driver = Init-SeDriver -ErrorAction Stop 17 | $HasElement = $PSBoundParameters.ContainsKey('Element') -or $PSCmdlet.MyInvocation.ExpectingInput 18 | if ($Action -eq 'Click_JS' -and -not $HasElement) { 19 | Write-Error 'Click_JS can only be performed if an $Element is specified' 20 | return $null 21 | } 22 | } 23 | Process { 24 | Write-Verbose "Performing $Action" 25 | switch ($Action) { 26 | 'Click_Js' { 27 | try { $Driver.ExecuteScript("arguments[0].click()", $Element) } 28 | catch { $PSCmdlet.ThrowTerminatingError($_) } 29 | } 30 | Default { 31 | $Interaction = [OpenQA.Selenium.Interactions.Actions]::new($Driver) 32 | if ($PSBoundParameters.ContainsKey('Element')) { 33 | Write-Verbose "On Element: $($Element.Tagname)" 34 | if ($Action -eq 'Click') { 35 | $Element.Click() #Mitigating IE driver issue with statement below. 36 | } 37 | else { 38 | try { $Interaction.$Action($Element).Perform() } 39 | catch { $PSCmdlet.ThrowTerminatingError($_) } 40 | } 41 | } 42 | else { 43 | Write-Verbose "On Driver currently located at: $($Driver.Url)" 44 | try { $Interaction.$Action().Perform() } 45 | catch { $PSCmdlet.ThrowTerminatingError($_) } 46 | } 47 | } 48 | } 49 | 50 | if ($Sleep -gt 0) { Start-Sleep -Milliseconds ($Sleep * 1000) } 51 | if ($PassThru) { if ($HasElement) { return $Element } else { return $Driver } } 52 | 53 | } 54 | } -------------------------------------------------------------------------------- /Public/Invoke-SeJavascript.ps1: -------------------------------------------------------------------------------- 1 | function Invoke-SeJavascript { 2 | [CmdletBinding()] 3 | param( 4 | [Parameter(ValueFromPipeline = $true, Position = 0)] 5 | [String]$Script, 6 | [Parameter(Position = 1)] 7 | [Object[]]$ArgumentList 8 | ) 9 | begin { 10 | $Driver = Init-SeDriver -ErrorAction Stop 11 | } 12 | Process { 13 | #Fix #165 14 | $MYargumentList = Foreach ($item in $ArgumentList) { 15 | $Item -as $Item.GetType() 16 | } 17 | $Driver.ExecuteScript($Script, $MyArgumentList) 18 | } 19 | End {} 20 | } 21 | 22 | -------------------------------------------------------------------------------- /Public/Invoke-SeKeys.ps1: -------------------------------------------------------------------------------- 1 | $Script:ModifierKeys = @( 2 | 'Control', 3 | 'LeftControl' 4 | 'Alt', 5 | 'LeftAlt' 6 | 'Shift', 7 | 'LeftShift' 8 | ) 9 | function Invoke-SeKeys { 10 | [CmdletBinding(DefaultParameterSetName = 'Default')] 11 | param( 12 | [Parameter( Position = 0, ValueFromPipeline = $true)] 13 | [ValidateNotNull()] 14 | [OpenQA.Selenium.IWebElement]$Element , 15 | [Parameter(Mandatory = $true, Position = 1)] 16 | [AllowEmptyString()] 17 | [string]$Keys, 18 | [switch]$ClearFirst, 19 | [Double]$Sleep = 0 , 20 | [switch]$Submit, 21 | [switch]$PassThru 22 | ) 23 | begin { 24 | $Driver = Init-SeDriver -ErrorAction Stop 25 | 26 | $Regexstr = '(?{{(?.*?)}})' 27 | $MyMatches = [Regex]::Matches($Keys, $Regexstr) 28 | #Treat modifier keys as key down . 29 | $Sequence = [System.Collections.Generic.List[String]]::new() 30 | $UseSequence = $Keys.StartsWith('{{') 31 | 32 | Foreach ($m in $MyMatches) { 33 | $key = $m.Groups.Item('value').value 34 | $Found = $Script:SeKeys.Name.Contains($value) 35 | if ($null -ne $Found) { 36 | if ($UseSequence -and $Key -in $Script:ModifierKeys) { 37 | $Sequence.Add([OpenQA.Selenium.Keys]::$key) 38 | $Keys = $Keys -replace "{{$key}}", '' 39 | } 40 | else { 41 | $Keys = $Keys -replace "{{$key}}", [OpenQA.Selenium.Keys]::$key 42 | } 43 | 44 | } 45 | } 46 | $UseSequence = $UseSequence -and $Sequence.Count -gt 0 47 | 48 | } 49 | process { 50 | $Action = [OpenQA.Selenium.Interactions.Actions]::new($Driver) 51 | 52 | switch ($PSBoundParameters.ContainsKey('Element')) { 53 | $true { 54 | if ($ClearFirst) { $Element.Clear() } 55 | 56 | if ($UseSequence) { 57 | Foreach ($k in $Sequence) { $Action.KeyDown($Element, $k) } 58 | $Action.SendKeys($Element, $Keys) 59 | Foreach ($k in $Sequence) { $Action.KeyUp($Element, $k) } 60 | $Action.Build().Perform() 61 | } 62 | else { 63 | $Action.SendKeys($Element, $Keys).Perform() 64 | } 65 | 66 | if ($Submit) { $Element.Submit() } 67 | } 68 | $false { 69 | if ($UseSequence) { 70 | Foreach ($k in $Sequence) { $Action.KeyDown($k) } 71 | $Action.SendKeys($Keys) 72 | Foreach ($k in $Sequence) { $Action.KeyUp($k) } 73 | $Action.Build().Perform() 74 | } 75 | else { 76 | $Action.SendKeys($Keys).Perform() 77 | } 78 | } 79 | } 80 | 81 | if ($Sleep) { Start-Sleep -Milliseconds ($Sleep * 1000) } 82 | if ($PassThru) { $Element } 83 | } 84 | } -------------------------------------------------------------------------------- /Public/Invoke-seMouseAction.ps1: -------------------------------------------------------------------------------- 1 | function Invoke-SeMouseAction { 2 | [CmdletBinding()] 3 | param ( 4 | [ArgumentCompleter([SeMouseActionCompleter])] 5 | [ValidateScript( { $_ -in $Script:SeMouseAction.Text })] 6 | $Action, 7 | $Value, 8 | [Parameter(ValueFromPipeline = $true)] 9 | [OpenQA.Selenium.IWebElement]$Element 10 | ) 11 | $Driver = Init-SeDriver -ErrorAction Stop 12 | Test-SeMouseActionValueValidation -Action $Action -ConditionValue $Value -ErrorAction Stop 13 | 14 | 15 | $Value2 = $null 16 | if ($Action -in @('DragAndDropToOffset', 'MoveByOffset', 'MoveToElement') -and $Value -is [String]) { 17 | $Value2 = $Value -split '[,x]' 18 | } 19 | 20 | 21 | $Interaction = [OpenQA.Selenium.Interactions.Actions]::new($Driver) 22 | 23 | $HasElement = $PSBoundParameters.ContainsKey('Element') 24 | $HasValue = $PSBoundParameters.ContainsKey('Value') 25 | 26 | if ($HasElement) { 27 | if ($HasValue) { 28 | if ($null -ne $value2) { 29 | try { $Interaction.$Action($Element, $Value2[0], $value2[1]).Perform() }catch { $PSCmdlet.ThrowTerminatingError($_) } 30 | } 31 | else { 32 | try { $Interaction.$Action($Element, $Value).Perform() }catch { $PSCmdlet.ThrowTerminatingError($_) } 33 | } 34 | } 35 | else { 36 | try { $Interaction.$Action($Element).Perform() }catch { $PSCmdlet.ThrowTerminatingError($_) } 37 | } 38 | } 39 | else { 40 | if ($HasValue) { 41 | if ($null -ne $value2) { 42 | try { $Interaction.$Action($Value2[0], $Value2[1]).Perform() }catch { $PSCmdlet.ThrowTerminatingError($_) } 43 | } 44 | else { 45 | try { $Interaction.$Action($Value).Perform() }catch { $PSCmdlet.ThrowTerminatingError($_) } 46 | } 47 | 48 | 49 | } 50 | else { 51 | try { $Interaction.$Action().Perform() }catch { $PSCmdlet.ThrowTerminatingError($_) } 52 | } 53 | } 54 | 55 | 56 | 57 | 58 | 59 | } -------------------------------------------------------------------------------- /Public/New-SeDriverOptions.ps1: -------------------------------------------------------------------------------- 1 | function New-SeDriverOptions { 2 | [cmdletbinding()] 3 | [OutputType( 4 | [OpenQA.Selenium.Chrome.ChromeOptions], 5 | [OpenQA.Selenium.Edge.EdgeOptions], 6 | [OpenQA.Selenium.Firefox.FirefoxOptions], 7 | [OpenQA.Selenium.IE.InternetExplorerOptions] 8 | )] 9 | param( 10 | [ArgumentCompleter( { [Enum]::GetNames([SeBrowsers]) })] 11 | [ValidateScript( { $_ -in [Enum]::GetNames([SeBrowsers]) })] 12 | [Parameter(ParameterSetName = 'Default')] 13 | $Browser, 14 | [StringUrlTransformAttribute()] 15 | [ValidateURIAttribute()] 16 | [Parameter(Position = 1)] 17 | [string]$StartURL, 18 | [ArgumentCompleter( { [Enum]::GetNames([SeWindowState]) })] 19 | [ValidateScript( { $_ -in [Enum]::GetNames([SeWindowState]) })] 20 | $State, 21 | [System.IO.FileInfo]$DefaultDownloadPath, 22 | [switch]$PrivateBrowsing, 23 | [Double]$ImplicitWait = 0.3, 24 | [System.Drawing.Size][SizeTransformAttribute()]$Size, 25 | [System.Drawing.Point][PointTransformAttribute()]$Position, 26 | $WebDriverPath, 27 | $BinaryPath, 28 | [String[]]$Switches, 29 | [String[]]$Arguments, 30 | $ProfilePath, 31 | [OpenQA.Selenium.LogLevel]$LogLevel, 32 | [SeDriverUserAgentTransformAttribute()] 33 | [ValidateNotNull()] 34 | [ArgumentCompleter( [SeDriverUserAgentCompleter])] 35 | [String]$UserAgent, 36 | [Switch]$AcceptInsecureCertificates 37 | ) 38 | if ($PSBoundParameters.ContainsKey('UserAgent')) { Test-SeDriverUserAgent -Browser $Browser -ErrorAction Stop } 39 | if ($PSBoundParameters.ContainsKey('AcceptInsecureCertificates')) { Test-SeDriverAcceptInsecureCertificates -Browser $Browser -ErrorAction Stop } 40 | 41 | # [Enum]::GetNames([sebrowsers]) 42 | $output = $null 43 | switch ($Browser) { 44 | Chrome { $Output = [OpenQA.Selenium.Chrome.ChromeOptions]::new() } 45 | Edge { $Output = New-Object -TypeName OpenQA.Selenium.Chrome.ChromeOptions -Property @{ browserName = '' } } 46 | Firefox { $Output = [OpenQA.Selenium.Firefox.FirefoxOptions]::new() } 47 | InternetExplorer { 48 | $Output = [OpenQA.Selenium.IE.InternetExplorerOptions]::new() 49 | $Output.IgnoreZoomLevel = $true 50 | } 51 | MSEdge { $Output = [OpenQA.Selenium.Edge.EdgeOptions]::new() } 52 | } 53 | 54 | #Add members to be treated by Internal Start cmdlet since Start-SeDriver won't allow their use with Options parameter set. 55 | Add-Member -InputObject $output -MemberType NoteProperty -Name 'SeParams' -Value $PSBoundParameters 56 | 57 | 58 | return $output 59 | } -------------------------------------------------------------------------------- /Public/New-SeDriverService.ps1: -------------------------------------------------------------------------------- 1 | function New-SeDriverService { 2 | [cmdletbinding()] 3 | [OutputType( 4 | [OpenQA.Selenium.Chrome.ChromeDriverService], 5 | [OpenQA.Selenium.Firefox.FirefoxDriverService], 6 | [OpenQA.Selenium.IE.InternetExplorerDriverService], 7 | [OpenQA.Selenium.Edge.EdgeDriverService] 8 | )] 9 | param( 10 | [ArgumentCompleter( { [Enum]::GetNames([SeBrowsers]) })] 11 | [ValidateScript( { $_ -in [Enum]::GetNames([SeBrowsers]) })] 12 | [Parameter(ParameterSetName = 'Default')] 13 | $Browser, 14 | $WebDriverPath 15 | ) 16 | 17 | #$AssembliesPath defined in init.ps1 18 | $service = $null 19 | $ServicePath = $null 20 | 21 | if ($WebDriverPath) { $ServicePath = $WebDriverPath } elseif ($AssembliesPath) { $ServicePath = $AssembliesPath } 22 | 23 | switch ($Browser) { 24 | 25 | Chrome { 26 | if ($ServicePath) { $service = [OpenQA.Selenium.Chrome.ChromeDriverService]::CreateDefaultService($ServicePath) } 27 | else { $service = [OpenQA.Selenium.Chrome.ChromeDriverService]::CreateDefaultService() } 28 | } 29 | Edge { 30 | $service = [OpenQA.Selenium.Chrome.ChromeDriverService]::CreateDefaultService($ServicePath, 'msedgedriver.exe') 31 | } 32 | Firefox { 33 | if ($ServicePath) { $service = [OpenQA.Selenium.Firefox.FirefoxDriverService]::CreateDefaultService($ServicePath) } 34 | else { $service = [OpenQA.Selenium.Firefox.FirefoxDriverService]::CreateDefaultService() } 35 | $service.Host = '::1' 36 | } 37 | InternetExplorer { 38 | if ($WebDriverPath) { $Service = [OpenQA.Selenium.IE.InternetExplorerDriverService]::CreateDefaultService($WebDriverPath) } 39 | else { $Service = [OpenQA.Selenium.IE.InternetExplorerDriverService]::CreateDefaultService() } 40 | 41 | } 42 | MSEdge { 43 | $service = [OpenQA.Selenium.Edge.EdgeDriverService]::CreateDefaultService() 44 | } 45 | } 46 | 47 | #Set to $true by default; removing it will cause problems in jobs and create a second source of Verbose in the console. 48 | $Service.HideCommandPromptWindow = $true 49 | 50 | return $service 51 | } 52 | 53 | -------------------------------------------------------------------------------- /Public/New-SeScreenshot.ps1: -------------------------------------------------------------------------------- 1 | function New-SeScreenshot { 2 | 3 | [cmdletbinding(DefaultParameterSetName = 'Driver')] 4 | param( 5 | [Parameter(DontShow, ValueFromPipeline = $true, ParameterSetName = 'Pipeline')] 6 | [ValidateScript( { 7 | $Types = @([OpenQA.Selenium.IWebDriver], [OpenQA.Selenium.IWebElement]) 8 | $Found = $false 9 | Foreach ($t in $Types) { if ($_ -is $t) { $Found = $true; break } } 10 | if ($found) { return $true } else { Throw "Input must be of one of the following types $($Types -join ',')" } 11 | })] 12 | $InputObject, 13 | [Switch]$AsBase64EncodedString, 14 | [Parameter(ParameterSetName = 'Element')] 15 | [ValidateNotNull()] 16 | [OpenQA.Selenium.IWebElement]$Element 17 | ) 18 | Begin { 19 | $Driver = Init-SeDriver -ErrorAction Stop 20 | } 21 | Process { 22 | switch ($PSCmdlet.ParameterSetName) { 23 | 'Pipeline' { 24 | switch ($InputObject) { 25 | { $_ -is [OpenQA.Selenium.IWebElement] } { $Screenshot = $InputObject.GetScreenshot() } 26 | { $_ -is [OpenQA.Selenium.IWebDriver] } { $Screenshot = [OpenQA.Selenium.Support.Extensions.WebDriverExtensions]::TakeScreenshot($InputObject) } 27 | } 28 | } 29 | 'Element' { $Screenshot = $Element.GetScreenshot() } 30 | 'Driver' { $Screenshot = [OpenQA.Selenium.Support.Extensions.WebDriverExtensions]::TakeScreenshot($Driver) } 31 | } 32 | 33 | if ($AsBase64EncodedString) { 34 | return $Screenshot.AsBase64EncodedString 35 | } 36 | else { 37 | return $Screenshot 38 | } 39 | } 40 | End {} 41 | 42 | 43 | } -------------------------------------------------------------------------------- /Public/New-SeWindow.ps1: -------------------------------------------------------------------------------- 1 | function New-SeWindow { 2 | [CmdletBinding()] 3 | param( 4 | [ValidateURIAttribute()] 5 | [StringUrlTransformAttribute()] 6 | $Url 7 | ) 8 | begin { 9 | $Driver = Init-SeDriver -ErrorAction Stop 10 | } 11 | process { 12 | $Windows = Get-SeWindow 13 | $Driver.ExecuteScript('window.open()') 14 | $WindowsNewSet = Get-SeWindow 15 | $NewWindowHandle = (Compare-Object -ReferenceObject $Windows -DifferenceObject $WindowsNewSet).Inputobject 16 | Switch-SeWindow -Window $NewWindowHandle 17 | if ($PSBoundParameters.ContainsKey('Url')) { Set-SeUrl -Url $Url } 18 | } 19 | } -------------------------------------------------------------------------------- /Public/Pop-SeUrl.ps1: -------------------------------------------------------------------------------- 1 | function Pop-SeUrl { 2 | <# 3 | .SYNOPSIS 4 | Navigate back to the most recently pushed URL in the location stack. 5 | 6 | .DESCRIPTION 7 | Retrieves the most recently pushed URL from the location stack and navigates 8 | to that URL with the specified or default driver. 9 | 10 | .EXAMPLE 11 | Pop-SeUrl 12 | 13 | Retrieves the most recently pushed URL and navigates back to that URL. 14 | 15 | .NOTES 16 | A separate internal location stack is maintained for each driver instance 17 | by the module. This stack is completely separate from the driver's internal 18 | Back/Forward history logic. 19 | 20 | To utilise a driver's Back/Forward functionality, instead use Set-SeUrl. 21 | #> 22 | [CmdletBinding()] 23 | param() 24 | begin { 25 | $Driver = Init-SeDriver -ErrorAction Stop 26 | } 27 | process { 28 | if ($Script:SeLocationMap[$Driver].Count -gt 0) { 29 | Set-SeUrl -Url $Script:SeLocationMap[$Driver].Pop() -Driver $Driver 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Public/Push-SeUrl.ps1: -------------------------------------------------------------------------------- 1 | function Push-SeUrl { 2 | <# 3 | .SYNOPSIS 4 | Stores the current URL in the driver's location stack and optionally 5 | navigate to a new URL. 6 | 7 | .DESCRIPTION 8 | The current driver URL is added to the stack, and if a URL is provided, the 9 | driver navigates to the new URL. 10 | 11 | .EXAMPLE 12 | Push-SeUrl 13 | 14 | The current driver URL is added to the location stack. 15 | 16 | .EXAMPLE 17 | Push-SeUrl 'https://google.com/' 18 | 19 | The current driver URL is added to the location stack, and the driver then 20 | navigates to the provided target URL. 21 | 22 | .NOTES 23 | A separate internal location stack is maintained for each driver instance 24 | by the module. This stack is completely separate from the driver's internal 25 | Back/Forward history logic. 26 | 27 | To utilise a driver's Back/Forward functionality, instead use Set-SeUrl. 28 | #> 29 | [CmdletBinding()] 30 | param( 31 | # The new URL to navigate to after storing the current location. 32 | [Parameter(Position = 0, ParameterSetName = 'url')] 33 | [ValidateURIAttribute()] 34 | [string] 35 | $Url 36 | ) 37 | $Driver = Init-SeDriver -ErrorAction Stop 38 | if (-not $Script:SeLocationMap.ContainsKey($Driver)) { 39 | $script:SeLocationMap[$Driver] = [System.Collections.Generic.Stack[string]]@() 40 | } 41 | 42 | # Push the current location to the stack 43 | $script:SeLocationMap[$Driver].Push($Driver.Url) 44 | 45 | if ($Url) { 46 | # Change the driver current URL to provided URL 47 | Set-SeUrl -Url $Url -Driver $Driver 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Public/Remove-SeCookie.ps1: -------------------------------------------------------------------------------- 1 | function Remove-SeCookie { 2 | [CmdletBinding()] 3 | param( 4 | [Parameter(Mandatory = $true, ParameterSetName = 'All')] 5 | [switch]$All, 6 | 7 | [Parameter(Mandatory = $true, ParameterSetName = 'NamedCookie')] 8 | [string]$Name 9 | ) 10 | $Driver = Init-SeDriver -ErrorAction Stop 11 | if ($All) { 12 | $Driver.Manage().Cookies.DeleteAllCookies() 13 | } 14 | else { 15 | $Driver.Manage().Cookies.DeleteCookieNamed($Name) 16 | } 17 | } -------------------------------------------------------------------------------- /Public/Remove-SeWindow.ps1: -------------------------------------------------------------------------------- 1 | function Remove-SeWindow { 2 | [CmdletBinding()] 3 | param( 4 | [String]$SwitchToWindow 5 | ) 6 | begin { 7 | $Driver = Init-SeDriver -ErrorAction Stop 8 | } 9 | process { 10 | try { 11 | $Windows = @(Get-SeWindow) 12 | if ($Windows.Count -eq 1) { Write-Warning -Message 'The driver has only one window left. Operation aborted. Use Stop-Driver instead.' } 13 | 14 | $Driver.Close() 15 | if ($PSBoundParameters.ContainsKey('SwitchTo')) { 16 | Switch-SeWindow -Window $SwitchToWindow 17 | } 18 | else { 19 | $Windows = @(Get-SeWindow) 20 | if ($Windows.count -gt 0) { 21 | Switch-SeWindow -Window $Windows[0] 22 | } 23 | } 24 | } 25 | catch { 26 | Write-Error $_ 27 | } 28 | 29 | 30 | } 31 | } -------------------------------------------------------------------------------- /Public/Save-SeScreenshot.ps1: -------------------------------------------------------------------------------- 1 | function Save-SeScreenshot { 2 | [CmdletBinding(DefaultParameterSetName = 'Driver')] 3 | param( 4 | [Parameter(DontShow, ValueFromPipeline = $true, ParameterSetName = 'Pipeline')] 5 | [ValidateScript( { 6 | $Types = @([OpenQA.Selenium.IWebDriver], [OpenQA.Selenium.IWebElement], [OpenQA.Selenium.Screenshot]) 7 | $Found = $false 8 | Foreach ($t in $Types) { if ($_ -is $t) { $Found = $true; break } } 9 | if ($found) { return $true } else { Throw "Input must be of one of the following types $($Types -join ',')" } 10 | })] 11 | $InputObject, 12 | [Parameter( Mandatory = $true, ParameterSetName = 'Screenshot')] 13 | [OpenQA.Selenium.Screenshot]$Screenshot, 14 | [Parameter(Mandatory = $true)] 15 | [string]$Path, 16 | [OpenQA.Selenium.ScreenshotImageFormat]$ImageFormat = [OpenQA.Selenium.ScreenshotImageFormat]::Png, 17 | [Parameter(Mandatory = $true, ParameterSetName = 'Element')] 18 | [ValidateNotNull()] 19 | [OpenQA.Selenium.IWebElement]$Element 20 | ) 21 | 22 | begin { 23 | if ($PSCmdlet.ParameterSetName -eq 'Driver') { 24 | $Driver = Init-SeDriver -ErrorAction Stop 25 | } 26 | } 27 | process { 28 | 29 | switch ($PSCmdlet.ParameterSetName) { 30 | 'Pipeline' { 31 | switch ($InputObject) { 32 | { $_ -is [OpenQA.Selenium.IWebElement] } { $Screenshot = $InputObject.GetScreenshot() } 33 | { $_ -is [OpenQA.Selenium.IWebDriver] } { $Screenshot = [OpenQA.Selenium.Support.Extensions.WebDriverExtensions]::TakeScreenshot($InputObject) } 34 | { $_ -is [OpenQA.Selenium.Screenshot] } { $Screenshot = $InputObject } 35 | } 36 | } 37 | 'Driver' { $Screenshot = New-SeScreenshot } 38 | 'Element' { $Screenshot = New-SeScreenshot -Element $Element } 39 | } 40 | 41 | $Screenshot.SaveAsFile($Path, $ImageFormat) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Public/Set-SeCookie.ps1: -------------------------------------------------------------------------------- 1 | function Set-SeCookie { 2 | [cmdletbinding()] 3 | param( 4 | [string]$Name, 5 | [string]$Value, 6 | [string]$Path, 7 | [string]$Domain, 8 | [DateTime]$ExpiryDate 9 | ) 10 | begin { 11 | $Driver = Init-SeDriver -ErrorAction Stop 12 | } 13 | 14 | process { 15 | if ($Name -and $Value -and (!$Path -and !$Domain -and !$ExpiryDate)) { 16 | $cookie = [OpenQA.Selenium.Cookie]::new($Name, $Value) 17 | } 18 | Elseif ($Name -and $Value -and $Path -and (!$Domain -and !$ExpiryDate)) { 19 | $cookie = [OpenQA.Selenium.Cookie]::new($Name, $Value, $Path) 20 | } 21 | Elseif ($Name -and $Value -and $Path -and $ExpiryDate -and !$Domain) { 22 | $cookie = [OpenQA.Selenium.Cookie]::new($Name, $Value, $Path, $ExpiryDate) 23 | } 24 | Elseif ($Name -and $Value -and $Path -and $Domain -and (!$ExpiryDate -or $ExpiryDate)) { 25 | if ($Driver.Url -match $Domain) { 26 | $cookie = [OpenQA.Selenium.Cookie]::new($Name, $Value, $Domain, $Path, $ExpiryDate) 27 | } 28 | else { 29 | Throw 'In order to set the cookie the browser needs to be on the cookie domain URL' 30 | } 31 | } 32 | else { 33 | Throw "Incorrect Cookie Layout: 34 | Cookie(String, String) 35 | Initializes a new instance of the Cookie class with a specific name and value. 36 | Cookie(String, String, String) 37 | Initializes a new instance of the Cookie class with a specific name, value, and path. 38 | Cookie(String, String, String, Nullable) 39 | Initializes a new instance of the Cookie class with a specific name, value, path and expiration date. 40 | Cookie(String, String, String, String, Nullable) 41 | Initializes a new instance of the Cookie class with a specific name, value, domain, path and expiration date." 42 | } 43 | 44 | $Driver.Manage().Cookies.AddCookie($cookie) 45 | } 46 | } -------------------------------------------------------------------------------- /Public/Set-SeDriverTimeout.ps1: -------------------------------------------------------------------------------- 1 | function Set-SeDriverTimeout { 2 | [CmdletBinding()] 3 | param( 4 | [Parameter(Position = 0)] 5 | [ValidateSet('ImplicitWait', 'PageLoad', 'AsynchronousJavaScript')] 6 | $TimeoutType = 'ImplicitWait', 7 | [Parameter(Position = 1)] 8 | [Double]$Timeout = 0 9 | ) 10 | begin { 11 | $Driver = Init-SeDriver -ErrorAction Stop 12 | } 13 | Process { 14 | $Driver.Manage().Timeouts().$TimeoutType = [timespan]::FromMilliseconds($Timeout * 1000) 15 | } 16 | End {} 17 | } 18 | 19 | -------------------------------------------------------------------------------- /Public/Set-SeSelectValue.ps1: -------------------------------------------------------------------------------- 1 | function Set-SeSelectValue { 2 | [CmdletBinding()] 3 | param ( 4 | [ArgumentCompleter( { [Enum]::GetNames([SeBySelect]) })] 5 | [ValidateScript( { $_ -in [Enum]::GetNames([SeBySelect]) })] 6 | [SeBySelect]$By = [SeBySelect]::Text, 7 | [Parameter( ValueFromPipeline = $true, Position = 1, Mandatory = $true)] 8 | [OpenQA.Selenium.IWebElement]$Element, 9 | [Object]$value 10 | 11 | ) 12 | try { 13 | $IsMultiSelect = [SeleniumSelection.Option]::IsMultiSelect($Element) 14 | 15 | if (-not $IsMultiSelect -and $Value.Count -gt 1) { 16 | Write-Error 'This select control do not accept multiple values' 17 | return $null 18 | } 19 | 20 | #byindex can be 0, but ByText and ByValue can't be empty strings 21 | switch ($By) { 22 | { $_ -eq [SeBySelect]::Text } { 23 | $HaveWildcards = $null -ne (Get-WildcardsIndices -Value $value) 24 | 25 | if ($HaveWildcards) { 26 | $ValuesToSelect = Get-SeSelectValue -Element $Element -All 27 | $ValuesToSelect = $ValuesToSelect.Items | Where-Object { $_.Text -like $Value } 28 | if (! $IsMultiSelect) { $ValuesToSelect = $ValuesToSelect | Select -first 1 } 29 | Foreach ($v in $ValuesToSelect) { 30 | [SeleniumSelection.Option]::SelectByText($Element, $v.Text, $false) 31 | } 32 | } 33 | else { 34 | [SeleniumSelection.Option]::SelectByText($Element, $value, $false) 35 | } 36 | 37 | } 38 | 39 | { $_ -eq [SeBySelect]::Value } { [SeleniumSelection.Option]::SelectByValue($Element, $value) } 40 | { $_ -eq [SeBySelect]::Index } { [SeleniumSelection.Option]::SelectByIndex($Element, $value) } 41 | } 42 | } 43 | catch { 44 | throw "An error occured checking the selection box, the message was:`r`n $($_.exception.message)" 45 | } 46 | } -------------------------------------------------------------------------------- /Public/Set-SeUrl.ps1: -------------------------------------------------------------------------------- 1 | function Set-SeUrl { 2 | <# 3 | .SYNOPSIS 4 | Navigates to the targeted URL with the selected or default driver. 5 | 6 | .DESCRIPTION 7 | Used for webdriver navigation commands, either to specific target URLs or 8 | for history (Back/Forward) navigation or refreshing the current page. 9 | 10 | .EXAMPLE 11 | Set-SeUrl 'https://www.google.com/' 12 | 13 | Directs the default driver to navigate to www.google.com. 14 | 15 | .EXAMPLE 16 | Set-SeUrl -Refresh 17 | 18 | Reloads the current page for the default driver. 19 | 20 | .EXAMPLE 21 | Set-SeUrl -Target $Driver -Back 22 | 23 | Directs the targeted webdriver instance to navigate Back in its history. 24 | 25 | .EXAMPLE 26 | Set-SeUrl -Forward 27 | 28 | Directs the default webdriver to navigate Forward in its history. 29 | 30 | .NOTES 31 | The Back/Forward/Refresh logic is handled by the webdriver itself. If you 32 | need a more granular approach to handling which locations are saved or 33 | retrieved, use Push-SeUrl or Pop-SeUrl to utilise a separately managed 34 | location stack. 35 | #> 36 | [CmdletBinding(DefaultParameterSetName = 'default')] 37 | param( 38 | # The target URL for the webdriver to navigate to. 39 | [Parameter(Mandatory = $true, position = 0, ParameterSetName = 'url')] 40 | [StringUrlTransformAttribute()] 41 | [ValidateURIAttribute()] 42 | [string]$Url, 43 | 44 | # Trigger the Back history navigation action in the webdriver. 45 | [Parameter(Mandatory = $true, ParameterSetName = 'back')] 46 | [switch]$Back, 47 | 48 | # Trigger the Forward history navigation action in the webdriver. 49 | [Parameter(Mandatory = $true, ParameterSetName = 'forward')] 50 | [switch]$Forward, 51 | 52 | # Refresh the current page in the webdriver. 53 | [Parameter(Mandatory = $true, ParameterSetName = 'refresh')] 54 | [switch]$Refresh, 55 | 56 | [Parameter(ParameterSetName = 'back')] 57 | [Parameter(ParameterSetName = 'forward', Position = 1)] 58 | [ValidateScript( { $_ -ge 1 })] 59 | [Int]$Depth = 1 60 | ) 61 | $Driver = Init-SeDriver -ErrorAction Stop 62 | for ($i = 0; $i -lt $Depth; $i++) { 63 | switch ($PSCmdlet.ParameterSetName) { 64 | 'url' { $Driver.Navigate().GoToUrl($Url); break } 65 | 'back' { $Driver.Navigate().Back(); break } 66 | 'forward' { $Driver.Navigate().Forward(); break } 67 | 'refresh' { $Driver.Navigate().Refresh(); break } 68 | default { throw 'Unexpected ParameterSet' } 69 | } 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /Public/Start-SeRemote.ps1: -------------------------------------------------------------------------------- 1 | function Start-SeRemote { 2 | [cmdletbinding(DefaultParameterSetName = 'default')] 3 | param( 4 | [string]$RemoteAddress, 5 | [hashtable]$DesiredCapabilities, 6 | [ValidateURIAttribute()] 7 | [Parameter(Position = 0)] 8 | [string]$StartURL, 9 | [Double]$ImplicitWait = 0.3, 10 | [System.Drawing.Size][SizeTransformAttribute()]$Size, 11 | [System.Drawing.Point][PointTransformAttribute()]$Position 12 | ) 13 | 14 | $desired = [OpenQA.Selenium.Remote.DesiredCapabilities]::new() 15 | if (-not $DesiredCapabilities.Name) { 16 | $desired.SetCapability('name', [datetime]::now.tostring("yyyyMMdd-hhmmss")) 17 | } 18 | foreach ($k in $DesiredCapabilities.keys) { $desired.SetCapability($k, $DesiredCapabilities[$k]) } 19 | $Driver = [OpenQA.Selenium.Remote.RemoteWebDriver]::new($RemoteAddress, $desired) 20 | 21 | if (-not $Driver) { Write-Warning "Web driver was not created"; return } 22 | 23 | if ($PSBoundParameters.ContainsKey('Size')) { $Driver.Manage().Window.Size = $Size } 24 | if ($PSBoundParameters.ContainsKey('Position')) { $Driver.Manage().Window.Position = $Position } 25 | $Driver.Manage().Timeouts().ImplicitWait = [TimeSpan]::FromMilliseconds($ImplicitWait * 1000) 26 | if ($StartURL) { $Driver.Navigate().GotoUrl($StartURL) } 27 | 28 | return $Driver 29 | } -------------------------------------------------------------------------------- /Public/Stop-SeDriver.ps1: -------------------------------------------------------------------------------- 1 | function Stop-SeDriver { 2 | [CmdletBinding()] 3 | param( 4 | [Parameter(Mandatory = $false, ValueFromPipeline = $true)] 5 | [OpenQA.Selenium.IWebDriver] 6 | $Driver 7 | ) 8 | Begin { 9 | $ElementsToRemove = [System.Collections.Generic.List[PSObject]]::new() 10 | } 11 | Process { 12 | if (! $PSBoundParameters.ContainsKey('Driver')) { 13 | $Driver = Get-SeDriver -Current 14 | } 15 | 16 | 17 | if ($null -ne $Driver) { 18 | $Processes = (Get-Process -Id $Driver.SeProcessId, $Driver.SeServiceProcessId -ErrorAction SilentlyContinue ) 19 | 20 | switch ($Processes.Count) { 21 | 2 { 22 | Write-Verbose -Message "Closing $BrowserName $($Driver.SeFriendlyName )..." 23 | $Driver.Close() 24 | $Driver.Dispose() 25 | break 26 | } 27 | 1 { Stop-Process -Id $Processes.Id -ErrorAction SilentlyContinue } 28 | } 29 | $ElementsToRemove.Add($Driver) 30 | } 31 | 32 | } 33 | End { 34 | $ElementsToRemove | ForEach-Object { [void]($script:SeDrivers.Remove($_)) } 35 | if ($script:SeDriversCurrent -notin $script:SeDrivers) { 36 | $script:SeDriversCurrent = $null 37 | } 38 | 39 | } 40 | 41 | 42 | 43 | } -------------------------------------------------------------------------------- /Public/Switch-SeDriver.ps1: -------------------------------------------------------------------------------- 1 | function Switch-SeDriver { 2 | [cmdletbinding(DefaultParameterSetName = 'ByName')] 3 | param( 4 | [parameter(Position = 0, ParameterSetName = 'ByDriver', Mandatory = $True)] 5 | [OpenQA.Selenium.IWebDriver]$Driver, 6 | [parameter(Position = 0, ParameterSetName = 'ByName', Mandatory = $True)] 7 | [String]$Name 8 | ) 9 | 10 | # Remove Selected visual indicator 11 | if ($null -ne $Script:SeDriversCurrent) { 12 | $Script:SeDriversCurrent.SeBrowser = $Script:SeDriversCurrent.SeBrowser -replace ' \*$', '' 13 | } 14 | 15 | switch ($PSCmdlet.ParameterSetName) { 16 | 'ByDriver' { $Script:SeDriversCurrent = $Driver } 17 | 'ByName' { 18 | $Driver = Get-SeDriver -Name $Name 19 | if ($null -eq $Driver) { 20 | $PSCmdlet.ThrowTerminatingError("Driver with Name: $Name not found ") 21 | } 22 | else { 23 | $Script:SeDriversCurrent = $Driver 24 | } 25 | } 26 | } 27 | 28 | $Driver.SeBrowser = "$($Driver.SeBrowser) *" 29 | 30 | return $Driver 31 | } 32 | 33 | -------------------------------------------------------------------------------- /Public/Switch-SeFrame.ps1: -------------------------------------------------------------------------------- 1 | function Switch-SeFrame { 2 | [CmdletBinding()] 3 | param ( 4 | [Parameter(Mandatory = $true, ParameterSetName = 'Frame', Position = 0)] 5 | $Frame, 6 | 7 | [Parameter(Mandatory = $true, ParameterSetName = 'Parent')] 8 | [switch]$Parent, 9 | 10 | [Parameter(Mandatory = $true, ParameterSetName = 'Root')] 11 | [switch]$Root 12 | ) 13 | $Driver = Init-SeDriver -ErrorAction Stop 14 | #TODO Frame validation... Do not try to switch if element does not exist ? 15 | #TODO Review ... Maybe Parent / Root should be a unique parameter : -Level Parent/Root ) 16 | if ($PSBoundParameters.ContainsKey('Frame')) { [void]$Driver.SwitchTo().Frame($Frame) } 17 | elseif ($Parent) { [void]$Driver.SwitchTo().ParentFrame() } 18 | elseif ($Root) { [void]$Driver.SwitchTo().defaultContent() } 19 | } -------------------------------------------------------------------------------- /Public/Switch-SeWindow.ps1: -------------------------------------------------------------------------------- 1 | function Switch-SeWindow { 2 | [CmdletBinding()] 3 | param( 4 | [Parameter(Mandatory = $true)]$Window 5 | ) 6 | begin { 7 | $Driver = Init-SeDriver -ErrorAction Stop 8 | } 9 | process { 10 | $Driver.SwitchTo().Window($Window) | Out-Null 11 | } 12 | } -------------------------------------------------------------------------------- /Public/Update-SeDriver.ps1: -------------------------------------------------------------------------------- 1 | function Update-SeDriver { 2 | [CmdletBinding()] 3 | param ( 4 | [ArgumentCompleter( { [Enum]::GetNames([SeBrowsers]) })] 5 | [ValidateScript( { $_ -in [Enum]::GetNames([SeBrowsers]) })] 6 | $Browser, 7 | [ValidateSet('Linux', 'Mac', 'Windows')] 8 | $OS, 9 | [ValidateScript( { (Test-Path -Path $_) -and ((Get-Item -Path $_) -is [System.IO.DirectoryInfo]) })] 10 | $Path 11 | ) 12 | 13 | if (! $PSBoundParameters.ContainsKey('OS')) { 14 | if ($IsMacOS) { $OS = 'Mac' } elseif ($IsLinux) { $OS = 'Linux' } else { $OS = 'Windows' } 15 | } 16 | 17 | if (! $PSBoundParameters.ContainsKey('Path')) { 18 | $Path = $PSScriptRoot 19 | if ($Path.EndsWith('Public')) { $Path = Split-Path -Path $Path } #Debugging 20 | switch ($OS) { 21 | 'Linux' { $AssembliesDir = Join-Path -Path $Path -ChildPath '/assemblies/linux' } 22 | 'Mac' { $AssembliesDir = Join-Path -Path $Path -ChildPath '/assemblies/macos' } 23 | 'Windows' { $AssembliesDir = Join-Path -Path $Path -ChildPath '/assemblies' } 24 | } 25 | 26 | } 27 | 28 | $TempDir = [System.IO.Path]::GetTempPath() 29 | 30 | switch ($Browser) { 31 | 'Chrome' { 32 | $LatestChromeStableRelease = Invoke-WebRequest 'https://chromedriver.storage.googleapis.com/LATEST_RELEASE' | Select-Object -ExpandProperty Content 33 | $ChromeBuilds = @{ 34 | Linux = 'chromedriver_linux64' 35 | Mac = 'chromedriver_mac64' 36 | Windows = 'chromedriver_win32' 37 | } 38 | 39 | $Build = $ChromeBuilds.$OS 40 | 41 | 42 | $BuildFileName = "$Build.zip" 43 | Write-Verbose "Downloading: $BuildFileName" 44 | Invoke-WebRequest -OutFile "$($TempDir + $BuildFileName)" "https://chromedriver.storage.googleapis.com/$LatestChromeStableRelease/$BuildFileName" 45 | 46 | # Expand the ZIP Archive to the correct Assemblies Dir 47 | Write-Verbose "Explanding: $($TempDir + $BuildFileName) to $AssembliesDir" 48 | Expand-Archive -Path "$($TempDir + $BuildFileName)" -DestinationPath $AssembliesDir -Force 49 | 50 | } 51 | 'Firefox' { 52 | Write-Warning 'Not Supported Yet' 53 | 54 | } 55 | 'Edge' { 56 | Write-Warning 'Not Supported Yet' 57 | } 58 | Default { 59 | Write-Warning 'Not Supported Yet' 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Public/Wait-SeDriver.ps1: -------------------------------------------------------------------------------- 1 | function Wait-SeDriver { 2 | [Cmdletbinding()] 3 | param( 4 | [ArgumentCompleter([SeDriverConditionsCompleter])] 5 | [ValidateScript( { $_ -in $Script:SeDriverConditions.Text })] 6 | [Parameter(Position = 0, Mandatory = $true)] 7 | $Condition, 8 | [Parameter(Position = 1, Mandatory = $true)] 9 | [ValidateNotNull()] 10 | $Value, 11 | #Specifies a time out 12 | [Parameter(Position = 2)] 13 | [Double]$Timeout = 3 14 | ) 15 | Begin { 16 | $Driver = Init-SeDriver -ErrorAction Stop 17 | $ImpTimeout = -1 18 | Test-SeDriverConditionsValueValidation -Condition $Condition -Value $Value -Erroraction Stop 19 | } 20 | process { 21 | $ImpTimeout = Disable-SeDriverImplicitTimeout -Driver $Driver 22 | if ($Condition -eq 'ScriptBlock') { 23 | $SeCondition = [System.Func[OpenQA.Selenium.IWebDriver, Bool]]$Value 24 | } 25 | else { 26 | $SeCondition = [OpenQA.Selenium.Support.UI.ExpectedConditions]::$Condition($Value) 27 | } 28 | $WebDriverWait = [OpenQA.Selenium.Support.UI.WebDriverWait]::new($Driver, ([timespan]::FromMilliseconds($Timeout * 1000))) 29 | 30 | try { 31 | [void]($WebDriverWait.Until($SeCondition)) 32 | return $true 33 | } 34 | catch { 35 | Write-Error $_ 36 | return $false 37 | } 38 | Finally { 39 | Enable-SeDriverImplicitTimeout -Driver $Driver -Timeout $ImpTimeout 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Public/Wait-SeElement.ps1: -------------------------------------------------------------------------------- 1 | function Wait-SeElement { 2 | [Cmdletbinding(DefaultParameterSetName = 'Element')] 3 | param( 4 | [ArgumentCompleter( { [Enum]::GetNames([SeBySelector]) })] 5 | [ValidateScript( { $_ -in [Enum]::GetNames([SeBySelector]) })] 6 | [Parameter(ParameterSetName = 'Locator', Position = 0)] 7 | [SeBySelector]$By = [SeBySelector]::XPath, 8 | [Parameter(Position = 1, Mandatory = $true, ParameterSetName = 'Locator')] 9 | [string]$Value, 10 | 11 | [Parameter(ParameterSetName = 'Element', Mandatory = $true)] 12 | [OpenQA.Selenium.IWebElement]$Element, 13 | [ArgumentCompleter([SeElementsConditionsCompleter])] 14 | [ValidateScript( { $_ -in $Script:SeElementsConditions.Text })] 15 | $Condition, 16 | [ValidateNotNull()] 17 | $ConditionValue, 18 | #Specifies a time out 19 | [Double]$Timeout = 3 20 | 21 | ) 22 | begin { 23 | $Driver = Init-SeDriver -ErrorAction Stop 24 | Test-SeElementConditionsValueValidation -By $By -Element $Element -Condition $Condition -ConditionValue $ConditionValue -ParameterSetName $PSCmdlet.ParameterSetName @Stop 25 | $ImpTimeout = -1 26 | 27 | $ExpectedValueType = Get-SeElementsConditionsValueType -text $Condition 28 | 29 | } 30 | process { 31 | $ImpTimeout = Disable-SeDriverImplicitTimeout -Driver $Driver 32 | 33 | $WebDriverWait = [OpenQA.Selenium.Support.UI.WebDriverWait]::new($Driver, ([timespan]::FromMilliseconds($Timeout * 1000))) 34 | $NoExtraArg = $null -eq $ExpectedValueType 35 | 36 | if ($PSBoundParameters.ContainsKey('Element')) { 37 | if ($NoExtraArg) { 38 | $SeCondition = [OpenQA.Selenium.Support.UI.ExpectedConditions]::$Condition($Element) 39 | } 40 | else { 41 | $SeCondition = [OpenQA.Selenium.Support.UI.ExpectedConditions]::$Condition($Element, $ConditionValue) 42 | } 43 | } 44 | else { 45 | if ($NoExtraArg) { 46 | $SeCondition = [OpenQA.Selenium.Support.UI.ExpectedConditions]::$Condition([OpenQA.Selenium.By]::$By($Value)) 47 | } 48 | else { 49 | $SeCondition = [OpenQA.Selenium.Support.UI.ExpectedConditions]::$Condition([OpenQA.Selenium.By]::$By($Value), $ConditionValue) 50 | } 51 | } 52 | 53 | try { 54 | [void]($WebDriverWait.Until($SeCondition)) 55 | return $true 56 | } 57 | catch { 58 | Write-Error $_ 59 | return $false 60 | } 61 | Finally { 62 | Enable-SeDriverImplicitTimeout -Driver $Driver -Timeout $ImpTimeout 63 | } 64 | } 65 | } 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /Selenium-Binary-Updater.ps1: -------------------------------------------------------------------------------- 1 | param( 2 | [Parameter(Mandatory=$true)][ValidateSet('Chrome','Firefox','Edge')]$Browser 3 | ) 4 | 5 | $TempDir = [System.IO.Path]::GetTempPath() 6 | 7 | switch ($Browser){ 8 | 'Chrome'{ 9 | $LatestChromeStableRelease = Invoke-WebRequest 'https://chromedriver.storage.googleapis.com/LATEST_RELEASE' | Select-Object -ExpandProperty Content 10 | $ChromeBuilds = @('chromedriver_linux64','chromedriver_mac64','chromedriver_win32') 11 | 12 | foreach ($Build in $ChromeBuilds){ 13 | switch($Build){ 14 | 'chromedriver_linux64'{ 15 | $AssembliesDir = "$PSScriptRoot/assemblies/linux" 16 | $BinaryFileName = 'chromedriver' 17 | } 18 | 'chromedriver_mac64'{ 19 | $AssembliesDir = "$PSScriptRoot/assemblies/macos" 20 | $BinaryFileName = 'chromedriver' 21 | } 22 | 'chromedriver_win32'{ 23 | $AssembliesDir = "$PSScriptRoot/assemblies" 24 | $BinaryFileName = 'chromedriver.exe' 25 | } 26 | default{throw 'Incorrect Build Type'} 27 | } 28 | 29 | $BuildFileName = "$Build.zip" 30 | Write-Verbose "Downloading: $BuildFileName" 31 | Invoke-WebRequest -OutFile "$($TempDir + $BuildFileName)" "https://chromedriver.storage.googleapis.com/$LatestChromeStableRelease/$BuildFileName" 32 | 33 | # Expand the ZIP Archive to the correct Assemblies Dir 34 | Write-Verbose "Explanding: $($TempDir + $BuildFileName) to $AssembliesDir" 35 | Expand-Archive -Path "$($TempDir + $BuildFileName)" -DestinationPath $AssembliesDir -Force 36 | 37 | # Generate Hash Files 38 | Write-Verbose "Generating SHA256 Hash File: $AssembliesDir/$BinaryFileName.sha256" 39 | Get-FileHash -Path "$AssembliesDir/$BinaryFileName" -Algorithm SHA256 | Select-Object -ExpandProperty Hash | Set-Content -Path "$AssembliesDir/$BinaryFileName.sha256" -Force 40 | 41 | } 42 | } 43 | 'Firefox'{ 44 | Write-Host 'Not Supported Yet' 45 | 46 | } 47 | 'Edge'{ 48 | Write-Host 'Not Supported Yet' 49 | } 50 | } -------------------------------------------------------------------------------- /Selenium.EzFormat.ps1: -------------------------------------------------------------------------------- 1 | #requires -Module EZOut 2 | # Install-Module EZOut or https://github.com/StartAutomating/EZOut 3 | $myFile = $MyInvocation.MyCommand.ScriptBlock.File 4 | $myModuleName = $($myFile | Split-Path -Leaf) -replace '\.ezformat\.ps1', '' -replace '\.ezout\.ps1', '' 5 | $myRoot = $myFile | Split-Path 6 | Push-Location $myRoot 7 | $Type = @{TypeName = 'OpenQA.Selenium.Remote.RemoteWebElement' } 8 | $Typed = @{TypeName = 'OpenQA.Selenium.Remote.RemoteWebDriver' } 9 | $formatting = @( 10 | Write-FormatView @type -Property Tagname, Enabled, Displayed, Text -Width 7, 7, 9, 80 -AlignProperty @{Text = 'Left' } 11 | Write-FormatView @type -AsList -Property Tagname, Text, Enabled, Selected, Location, Size, Displayed 12 | 13 | Write-FormatView -TypeName 'selenium-powershell/SeFrame' -Property 'TagName', 'Enabled', 'Name', 'Id' -VirtualProperty @{ 14 | Name = { $_.Attributes.name } 15 | Id = { $_.Attributes.id } 16 | } 17 | 18 | Write-FormatView -TypeName 'selenium-powershell/SeInput' -Property 'Tagname','Type*','Enabled','Displayed','Text','Placeholder*','Value*' -VirtualProperty @{ 19 | 'Type*' = {$_.Attributes.type} 20 | 'Placeholder*' = {$_.Attributes.placeholder} 21 | 'Value*' = {$_.Attributes.value} 22 | } 23 | 24 | 25 | # Add your own Write-FormatView here, 26 | # or put them in a Formatting or Views directory 27 | foreach ($potentialDirectory in 'Formatting', 'Views') { 28 | Join-Path $myRoot $potentialDirectory | 29 | Get-ChildItem -ea ignore | 30 | Import-FormatView -FilePath { $_.Fullname } 31 | } 32 | ) 33 | 34 | $destinationRoot = $myRoot 35 | 36 | if ($formatting) { 37 | $myFormatFile = Join-Path $destinationRoot "formats/$myModuleName.format.ps1xml" 38 | $formatting | Out-FormatData -Module $MyModuleName | Set-Content $myFormatFile -Encoding UTF8 39 | } 40 | 41 | $types = @( 42 | Write-TypeView @Type -DefaultDisplay 'Tagname', 'Enabled', 'Displayed', 'Text' 43 | Write-TypeView @Typed -ScriptProperty @{ 44 | SeTitle = { if ($null -ne $this.SessionId) { $this.Title } } 45 | SeUrl = { if ($null -ne $this.SessionId) { $this.Url } } 46 | } -DefaultDisplay 'SeFriendlyName', 'SeBrowser', 'SeTitle', 'SeUrl' 47 | 48 | # Add your own Write-T 49 | #TypeView statements here 50 | # or declare them in the 'Types' directory 51 | Join-Path $myRoot Types | 52 | Get-Item -ea ignore | 53 | Import-TypeView 54 | 55 | ) 56 | 57 | if ($types) { 58 | $myTypesFile = Join-Path $destinationRoot "types/$myModuleName.types.ps1xml" 59 | $types | Out-TypeData | Set-Content $myTypesFile -Encoding UTF8 60 | } 61 | Pop-Location 62 | 63 | $Content = Get-Content -Path $myFormatFile | Select -SkipLast 2 64 | 65 | $SeSelectViewPath = Join-Path -Path $PSScriptRoot -ChildPath 'views/SeSelectValueInfo.ps1xml' 66 | $EndOfFile = @' 67 | 68 | 69 | 70 | '@ 71 | ($Content | Out-String) + (Get-Content -Path $SeSelectViewPath -raw) + $EndOfFile | Out-File -Encoding utf8 $myFormatFile 72 | -------------------------------------------------------------------------------- /Selenium.psd1: -------------------------------------------------------------------------------- 1 | # 2 | # Module manifest for module 'Selenium' 3 | # 4 | # Generated by: Adam Driscoll 5 | # 6 | # Generated on: 8/31/2018 7 | # 8 | # Modified James O'Neill 30 Nov 2019 9 | 10 | @{ 11 | ModuleVersion = '4.0.0' 12 | GUID = 'a3bdb8c3-c150-48a8-b56d-cd4d43f46a26' 13 | Author = 'Adam Driscoll' 14 | CompanyName = 'Unknown' 15 | Copyright = '(c) 2020 Adam Driscoll. All rights reserved.' 16 | Description = 'Web automation using the Selenium Web Driver' 17 | ScriptsToProcess = @('SeleniumClasses.ps1') 18 | RootModule = 'Selenium.psm1' 19 | RequiredAssemblies = @('./assemblies/WebDriver.dll', './assemblies/WebDriver.Support.dll') 20 | FunctionsToExport = '*' 21 | AliasesToExport = @() 22 | CmdletsToExport = @() 23 | VariablesToExport = @() 24 | DscResourcesToExport = @() 25 | FileList = @('.\assemblies', 26 | '.\Examples', 27 | '.\ChangeLog.md', 28 | '.\README.md', 29 | '.\Selenium.psm1' 30 | '.\Selenium.tests.ps1' 31 | '.\Selenium-Binary-Updater.ps1') 32 | 33 | PrivateData = @{ 34 | PSData = @{ 35 | Tags = @('selenium', 'automation', 'web') 36 | LicenseUri = 'https://github.com/adamdriscoll/selenium-powershell/blob/master/LICENSE' 37 | ProjectUri = 'https://github.com/adamdriscoll/selenium-powershell' 38 | ReleaseNotes = 'Updating WebDrivers for Selenium' 39 | 40 | # A URL to an icon representing this module. 41 | # IconUri = '' 42 | Prerelease = 'preview3' 43 | } # End of PSData hashtable 44 | 45 | } # End of PrivateData hashtable 46 | 47 | # Supported PSEditions 48 | # CompatiblePSEditions = @() 49 | 50 | # Minimum version of the Windows PowerShell engine required by this module 51 | # PowerShellVersion = '' 52 | 53 | # Name of the Windows PowerShell host required by this module 54 | # PowerShellHostName = '' 55 | 56 | # Minimum version of the Windows PowerShell host required by this module 57 | # PowerShellHostVersion = '' 58 | 59 | # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. 60 | # DotNetFrameworkVersion = '' 61 | 62 | # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. 63 | # CLRVersion = '' 64 | 65 | # Processor architecture (None, X86, Amd64) required by this module 66 | # ProcessorArchitecture = '' 67 | 68 | # Modules that must be imported into the global environment prior to importing this module 69 | # RequiredModules = @() 70 | 71 | #Type files (.ps1xml) to be loaded when importing this module 72 | TypesToProcess = @('types/Selenium.types.ps1xml') 73 | 74 | # Format files (.ps1xml) to be loaded when importing this module 75 | FormatsToProcess = @('formats/Selenium.format.ps1xml') 76 | 77 | # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess 78 | # NestedModules = @() 79 | 80 | # List of all modules packaged with this module 81 | # ModuleList = @() 82 | 83 | 84 | # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. 85 | 86 | # HelpInfo URI of this module 87 | # HelpInfoURI = '' 88 | 89 | # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. 90 | # DefaultCommandPrefix = '' 91 | 92 | } 93 | -------------------------------------------------------------------------------- /Selenium.psm1: -------------------------------------------------------------------------------- 1 | $functionFolders = @('Classes', 'Public', 'Internal') 2 | . (Join-Path -Path $PSScriptRoot -ChildPath 'Internal/init.ps1') 3 | ForEach ($folder in $functionFolders) { 4 | $folderPath = Join-Path -Path $PSScriptRoot -ChildPath $folder 5 | 6 | If (Test-Path -Path $folderPath) { 7 | 8 | Write-Verbose -Message "Importing from $folder" 9 | $functions = Get-ChildItem -Path $folderPath -Filter '*.ps1' 10 | ForEach ($function in $functions) { 11 | Write-Verbose -Message " Importing $($function.BaseName)" 12 | . $($function.FullName) 13 | } 14 | } 15 | } 16 | 17 | $MyInvocation.MyCommand.ScriptBlock.Module.OnRemove = { 18 | Get-SeDriver | Stop-SeDriver 19 | } 20 | 21 | $publicFunctions = (Get-ChildItem -Path "$PSScriptRoot\Public" -Filter '*.ps1').BaseName 22 | Export-ModuleMember -Function $publicFunctions 23 | -------------------------------------------------------------------------------- /Tests/selenium-powershell.tests.ps1: -------------------------------------------------------------------------------- 1 | $moduleRoot = Resolve-Path "$PSScriptRoot\.." 2 | $moduleName = Split-Path $moduleRoot -Leaf 3 | 4 | Describe "General project validation: $moduleName" { 5 | 6 | $scripts = Get-ChildItem $moduleRoot -Include *.ps1, *.psm1, *.psd1 -Recurse 7 | 8 | # TestCases are splatted to the script so we need hashtables 9 | $testCase = $scripts | Foreach-Object {@{file = $_}} 10 | It "Script should be valid powershell" -TestCases $testCase { 11 | param($file) 12 | 13 | $file.fullname | Should Exist 14 | 15 | $contents = Get-Content -Path $file.fullname -ErrorAction Stop 16 | $errors = $null 17 | $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) 18 | $errors.Count | Should Be 0 19 | } 20 | } -------------------------------------------------------------------------------- /Views/SeSelectValueInfo.ps1xml: -------------------------------------------------------------------------------- 1 |  2 | SeSelectValueInfo 3 | 4 | selenium-powershell/SeSelectValueInfo 5 | 6 | 7 | 8 | 9 | 10 | 11 | IsMultiSelect 12 | 13 | 14 | 15 | 16 | 17 | 18 | ($_.Items.Count -ne 0) 19 | 20 | 21 | 22 | $output = [System.Text.StringBuilder]::new(); 23 | $TextMax = ($_.Items.Text | Measure-Object -Maximum).Maximum.length 24 | $ValueMax = ($_.Items.Value | Measure-Object -Maximum).Maximum.length 25 | [void]($Output.AppendFormat("Index {0} {1} Selected`n", 'Text'.PadRight($TextMax, ' '), 'Value'.PadRight($ValueMax, ' '))) 26 | [void]($Output.AppendFormat("----- {0} {1} --------`n", '----'.PadRight($TextMax, ' '), '-----'.PadRight($ValueMax, ' '))) 27 | foreach ($I in $_.Items) { 28 | $IsSelected = if ($I.Selected) {" *"} else {''} 29 | [Void]($output.AppendFormat("{0} {1} {2} {3}`n", "$($I.Index)".PadLeft(5, ' '), "$($I.Text)".PadRight($TextMax, ' '), "$($I.Value)".PadRight($ValueMax, ' '), $IsSelected)) 30 | }; 31 | $output.ToString().Trim("`n"); 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /assemblies/IEDriverServer.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamdriscoll/selenium-powershell/50c5d39822f2ac341b6198502991b80dbb5786e0/assemblies/IEDriverServer.exe -------------------------------------------------------------------------------- /assemblies/IEDriverServer.exe.sha256: -------------------------------------------------------------------------------- 1 | 51053574E3BA3AB5D9F47E13EC0E9961AD6C9C9978DC851BE71C0F86A272C74B 2 | -------------------------------------------------------------------------------- /assemblies/WebDriver.Support.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamdriscoll/selenium-powershell/50c5d39822f2ac341b6198502991b80dbb5786e0/assemblies/WebDriver.Support.dll -------------------------------------------------------------------------------- /assemblies/WebDriver.Support.dll.sha256: -------------------------------------------------------------------------------- 1 | B59BA7D0CFFE43E722B13AD737CF596F030788B86B5B557CB479F0B6957CCE8A 2 | -------------------------------------------------------------------------------- /assemblies/WebDriver.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamdriscoll/selenium-powershell/50c5d39822f2ac341b6198502991b80dbb5786e0/assemblies/WebDriver.dll -------------------------------------------------------------------------------- /assemblies/WebDriver.dll.sha256: -------------------------------------------------------------------------------- 1 | 0EE619B1786CF5971C0F9C6EE1859497AECBA93A4953CF92FEA998E8EEFADF3C 2 | -------------------------------------------------------------------------------- /assemblies/chromedriver.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamdriscoll/selenium-powershell/50c5d39822f2ac341b6198502991b80dbb5786e0/assemblies/chromedriver.exe -------------------------------------------------------------------------------- /assemblies/chromedriver.exe.sha256: -------------------------------------------------------------------------------- 1 | C6131A3106A8956702459673BDCC7F37BDD8989A141D2CBE15DC0157F0D53C74 2 | -------------------------------------------------------------------------------- /assemblies/geckodriver.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamdriscoll/selenium-powershell/50c5d39822f2ac341b6198502991b80dbb5786e0/assemblies/geckodriver.exe -------------------------------------------------------------------------------- /assemblies/geckodriver.exe.sha256: -------------------------------------------------------------------------------- 1 | FAED02EC5B0D6246856843D10EE020CB5121B8261AC939BE761130F21A73D3EE 2 | -------------------------------------------------------------------------------- /assemblies/linux/chromedriver: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamdriscoll/selenium-powershell/50c5d39822f2ac341b6198502991b80dbb5786e0/assemblies/linux/chromedriver -------------------------------------------------------------------------------- /assemblies/linux/chromedriver.sha256: -------------------------------------------------------------------------------- 1 | 01112975217552167F101D7B549D31A12B3C45ABE411892F92228BF8CB2F0058 2 | -------------------------------------------------------------------------------- /assemblies/linux/geckodriver: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamdriscoll/selenium-powershell/50c5d39822f2ac341b6198502991b80dbb5786e0/assemblies/linux/geckodriver -------------------------------------------------------------------------------- /assemblies/linux/geckodriver.sha256: -------------------------------------------------------------------------------- 1 | 0B2C9B9791925DCEA2981CBDFAB8274FB4668BF65D6A57C2257E8B57757C394A 2 | -------------------------------------------------------------------------------- /assemblies/macos/chromedriver: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamdriscoll/selenium-powershell/50c5d39822f2ac341b6198502991b80dbb5786e0/assemblies/macos/chromedriver -------------------------------------------------------------------------------- /assemblies/macos/chromedriver.sha256: -------------------------------------------------------------------------------- 1 | 1DA3E0CBF79A92CF06B08812A39991A37B5C5458DEC2A7B4FFF34F6D87126281 2 | -------------------------------------------------------------------------------- /assemblies/macos/geckodriver: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamdriscoll/selenium-powershell/50c5d39822f2ac341b6198502991b80dbb5786e0/assemblies/macos/geckodriver -------------------------------------------------------------------------------- /assemblies/macos/geckodriver.sha256: -------------------------------------------------------------------------------- 1 | AA2FCE6B96183C9D8FD0AA125F87557FCCEC60301CF7ADD1578B0DA59355AD8B 2 | -------------------------------------------------------------------------------- /assemblies/msedgedriver.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamdriscoll/selenium-powershell/50c5d39822f2ac341b6198502991b80dbb5786e0/assemblies/msedgedriver.exe -------------------------------------------------------------------------------- /assemblies/msedgedriver.exe.sha256: -------------------------------------------------------------------------------- 1 | A6EB02FF3EF75079A647F20BD0B6B563648BC4C8563443229C65671AB0BBB6CD 2 | -------------------------------------------------------------------------------- /types/Selenium.Types.ps1xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | OpenQA.Selenium.Remote.RemoteWebElement 6 | 7 | 8 | PSStandardMembers 9 | 10 | 11 | DefaultDisplayPropertySet 12 | 13 | Tagname 14 | Enabled 15 | Displayed 16 | Text 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | OpenQA.Selenium.Remote.RemoteWebDriver 25 | 26 | 27 | PSStandardMembers 28 | 29 | 30 | DefaultDisplayPropertySet 31 | 32 | SeFriendlyName 33 | SeBrowser 34 | SeTitle 35 | SeUrl 36 | 37 | 38 | 39 | 40 | 41 | SeUrl 42 | 43 | if ($null -ne $this.SessionId) { $this.Url } 44 | 45 | 46 | 47 | SeTitle 48 | 49 | if ($null -ne $this.SessionId) { $this.Title } 50 | 51 | 52 | 53 | 54 | 55 | --------------------------------------------------------------------------------