adamdriscoll/selenium-powershell

Get-SeElement -Filter

Closed this issue · 1 comments

This is equivalent to using

Get-SeElement -By TagName -Value Input -Attributes type  | Where {$_.attributes.type -eq 'email'} 
Get-SeElement -By TagName -Value input -Filter {$_.Attributes.type -eq 'email'} -Single -Timeout 4

with the exception that error handling is left to Get-SeElement, meaning that if no element is returned after the filter is applied, an error will be thrown. If the -Single switch is used and multiple elements are found, an error will be thrown.

Any attributes mentionned in the filter will be loaded even if not specified.
For instance, in the following statement, the type attribute will be loaded even though the -Attributes switch was not loaded.

Get-SeElement -By TagName -Value input -Filter {$_.Attributes.type -eq 'email'} -Single -Timeout 4

It is also not implicitely used by Get-SeInput

        $Filter = [scriptblock]::Create(@"
            if ("" -ne "$Type") { if (`$_.Attributes.type -ne "$type") { return } }
            if ("" -ne "$Text") { if (`$_.Text -ne "$Text" ) { return } }
            if ("" -ne "$Value" -and "" -ne "$Attribute") { if (`$_.Attributes."$Attribute" -ne "$Value" ) { return } }
            `$_
"@)
        Get-SeElement -By TagName -Value input @PSBoundParameters @MyAttributes -Filter $Filter