From aeef551c1dbe256eb0e8ac3ade15ded0473a070d Mon Sep 17 00:00:00 2001 From: Francis Mercier Date: Sun, 6 Dec 2020 05:57:31 -0500 Subject: [PATCH] #177 Get-SeInput view (initial commit) --- Public/Get-SeInput.ps1 | 28 ++++++++++-------- Selenium.EzFormat.ps1 | 7 ++++- formats/Selenium.format.ps1xml | 54 ++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 13 deletions(-) diff --git a/Public/Get-SeInput.ps1 b/Public/Get-SeInput.ps1 index 60a83cc..1a861ea 100644 --- a/Public/Get-SeInput.ps1 +++ b/Public/Get-SeInput.ps1 @@ -16,25 +16,25 @@ function Get-SeInput { $Driver = Init-SeDriver -ErrorAction Stop } Process { - $MyAttributes = @{} + $MyAttributes = @{Attributes = [System.Collections.Generic.List[String]]::new()} $SelectedAttribute = "" + $LoadAllAttributes = $false if ($PSBoundParameters.Remove('Attributes')) { $MyAttributes = @{Attributes = [System.Collections.Generic.List[String]]$Attributes } + $LoadAllAttributes = $Attributes.Count -eq 1 -and $Attributes[0] -eq '*' if ($Attributes[0] -ne '*') { $SelectedAttribute = $MyAttributes.Attributes[0] } } - if ($PSBoundParameters.Remove('Type')) { - if ($null -eq $Attributes) { - $MyAttributes = @{Attributes = 'type' } - } - else { - if (-not $Attributes.contains('type') -and -not $Attributes.contains('*')) { - $MyAttributes.Attributes.add('type') - } - } - + if (!$LoadAllAttributes){ + if ($PSBoundParameters.Remove('Type')) { + if (-not $MyAttributes.Attributes.Contains('type')) { $MyAttributes.Attributes.add('type') } + } + if (-not $MyAttributes.Attributes.Contains('placeholder')) { $MyAttributes.Attributes.add('placeholder') } + if (-not $MyAttributes.Attributes.Contains('value')) { $MyAttributes.Attributes.add('value') } } + + [void]($PSBoundParameters.Remove('Value')) $Filter = [scriptblock]::Create(@" @@ -43,7 +43,11 @@ function Get-SeInput { if ("" -ne "$Value" -and "" -ne "$SelectedAttribute") { if (`$_.Attributes."$SelectedAttribute" -ne "$Value" ) { return } } `$_ "@) - Get-SeElement -By TagName -Value input @PSBoundParameters @MyAttributes -Filter $Filter + + Get-SeElement -By TagName -Value input @PSBoundParameters @MyAttributes -Filter $Filter | ForEach-Object { + $_.Psobject.TypeNames.Insert(0, 'selenium-powershell/SeInput') + $_ + } } } diff --git a/Selenium.EzFormat.ps1 b/Selenium.EzFormat.ps1 index 7a614fe..442e3c8 100644 --- a/Selenium.EzFormat.ps1 +++ b/Selenium.EzFormat.ps1 @@ -7,7 +7,7 @@ Push-Location $myRoot $Type = @{TypeName = 'OpenQA.Selenium.Remote.RemoteWebElement' } $Typed = @{TypeName = 'OpenQA.Selenium.Remote.RemoteWebDriver' } $formatting = @( - Write-FormatView @type -Property Tagname, Enabled, Displayed, Text -Width 7, 7, 9, 80 -AlignProperty @{Text = 'Left' } -VirtualProperty @{'Hello' = { 'World' } } + Write-FormatView @type -Property Tagname, Enabled, Displayed, Text -Width 7, 7, 9, 80 -AlignProperty @{Text = 'Left' } Write-FormatView @type -AsList -Property Tagname, Text, Enabled, Selected, Location, Size, Displayed Write-FormatView -TypeName 'selenium-powershell/SeFrame' -Property 'TagName', 'Enabled', 'Name', 'Id' -VirtualProperty @{ @@ -15,6 +15,11 @@ $formatting = @( Id = { $_.Attributes.id } } + Write-FormatView -TypeName 'selenium-powershell/SeInput' -Property 'Tagname','Type*','Enabled','Displayed','Text','Placeholder*','Value*' -VirtualProperty @{ + 'Type*' = {$_.Attributes.type} + 'Placeholder*' = {$_.Attributes.placeholder} + 'Value*' = {$_.Attributes.value} + } # Add your own Write-FormatView here, diff --git a/formats/Selenium.format.ps1xml b/formats/Selenium.format.ps1xml index 0fb5aed..4521c8d 100644 --- a/formats/Selenium.format.ps1xml +++ b/formats/Selenium.format.ps1xml @@ -119,6 +119,60 @@ + + selenium-powershell/SeInput + + selenium-powershell/SeInput + + + + + + + + + + + + + + + + + + + + + + + + + + Tagname + + + $_.Attributes.type + + + Enabled + + + Displayed + + + Text + + + $_.Attributes.placeholder + + + $_.Attributes.value + + + + + + SeSelectValueInfo