Skip to content

Commit

Permalink
#177 Get-SeInput view (initial commit)
Browse files Browse the repository at this point in the history
  • Loading branch information
itfranck committed Dec 6, 2020
1 parent 15fcb42 commit aeef551
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 13 deletions.
28 changes: 16 additions & 12 deletions Public/Get-SeInput.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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(@"
Expand All @@ -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')
$_
}

}
}
Expand Down
7 changes: 6 additions & 1 deletion Selenium.EzFormat.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@ 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 @{
Name = { $_.Attributes.name }
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,
Expand Down
54 changes: 54 additions & 0 deletions formats/Selenium.format.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,60 @@
</TableRowEntries>
</TableControl>
</View>
<View>
<Name>selenium-powershell/SeInput</Name>
<ViewSelectedBy>
<TypeName>selenium-powershell/SeInput</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
</TableColumnHeader>
<TableColumnHeader>
<Label>Type*</Label>
</TableColumnHeader>
<TableColumnHeader>
</TableColumnHeader>
<TableColumnHeader>
</TableColumnHeader>
<TableColumnHeader>
</TableColumnHeader>
<TableColumnHeader>
<Label>Placeholder*</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>Value*</Label>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>Tagname</PropertyName>
</TableColumnItem>
<TableColumnItem>
<ScriptBlock>$_.Attributes.type</ScriptBlock>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Enabled</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Displayed</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Text</PropertyName>
</TableColumnItem>
<TableColumnItem>
<ScriptBlock>$_.Attributes.placeholder</ScriptBlock>
</TableColumnItem>
<TableColumnItem>
<ScriptBlock>$_.Attributes.value</ScriptBlock>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
<View>
<Name>SeSelectValueInfo</Name>
<ViewSelectedBy>
Expand Down

0 comments on commit aeef551

Please sign in to comment.