# Verifies that a control(s) meet(s) provided conditions. Conditions is an array of Hashtables @{AutomationElement.propertyname=value}

ipmo C:\tests\UIAutomation.dll;

Write-Host "start the services.msc snap-in";

Stop-Process -Name mmc;

Start-Process services.msc -PassThru | Get-UIAWindow -p mmc | Get-UIADataItem -Name BranchCache | Invoke-UIAControlContextMenu | Get-UIAMenuItem -Name Properties | Invoke-UIAMenuItemClick;

 

Write-Host "checking the OK button (right)";

Get-UIAWindow -p mmc | Test-UIAControlState -SearchCriteria @{Name='OK'} -ver

 

Write-Host "checking the Cancel button (right)";

Get-UIAWindow -p mmc | Test-UIAControlState -SearchCriteria @{Name='Cancel'} #-ver

 

Write-Host "checking IsEnabled (wrong IsEnabled because until any changes have been applied to the window, the Appy button is disabled)";

Get-UIAWindow -p mmc | Test-UIAControlState -SearchCriteria @{Name='Apply';IsEnabled=$true} #-ver

 

Write-Host "checking the OK and Cancel buttons (right)";

Get-UIAWindow -p mmc | Test-UIAControlState -SearchCriteria @{Name='OK'},@{Name='Cancel';IsEnabled=$true;IsOffscreen=$false} #-ver

 

Write-Host "checking the OK and Cancel buttons (wrong IsOffscreen)";

Get-UIAWindow -p mmc | Test-UIAControlState -SearchCriteria @{Name='OK'},@{Name='Cancel';IsEnabled=$false;IsOffscreen=$false} #-ver

 

Write-Host "checking the OK and Cancel buttons (wrong AutomationId)";

Get-UIAWindow -p mmc | Test-UIAControlState -SearchCriteria @{Name='OK';AutomationId='uuu'},@{Name='Cancel';IsEnabled=$true;IsOffscreen=$false} -ver

 

Write-Host "checking the OK and Cancel buttons (wrong parameter name, Exception will be raised)";

Get-UIAWindow -p mmc | Test-UIAControlState -SearchCriteria @{Name='OK'},@{Name='Cancel';IsEnabled=$true;IsOffscreen=$false;LocalizedConrolName='sss'} -ver

 

Write-Host "checking the OK and Cancel buttons (wrong LocalizedControlType)";

Get-UIAWindow -p mmc | Test-UIAControlState -SearchCriteria @{Name='OK'},@{Name='Cancel';IsEnabled=$true;IsOffscreen=$false;LocalizedControlType='sss'} -ver

Last edited Apr 5, 2012 at 3:36 PM by xinliu, version 8

Comments

No comments yet.