public void GetCheckBoxByTitleTimeout3000Delay500() { string name = "CheckBox222"; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, System.Windows.Automation.ControlType.CheckBox, name, "btn", TimeoutsAndDelays.Control_Timeout3000Delay500_Delay); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaCheckBox -Name " + name + " -timeout 3000 | " + "Read-UiaControlName", name); }
public void ControlType_Existing() { const string expectedName = "btnName"; const string expectedAutomationId = "btnAuId"; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, ControlType.Button, expectedName, expectedAutomationId, 0); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual1( @"if ((Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " -au " + MiddleLevelCode.TestFormNameEmpty + " | Wait-UiaControlState -SearchCriteria @{controlType=\"button\"})) { 1; } else { 0; }"); }
public void GetRadioButtonByAutomationIDTimeout3000Delay500() { string auId = "RadioButton111"; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, System.Windows.Automation.ControlType.RadioButton, "aaa", auId, TimeoutsAndDelays.Control_Timeout3000Delay500_Delay); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaRadioButton -AutomationId " + auId + " -timeout 3000 | " + "Read-UiaControlAutomationId", auId); }
public void GetListBoxByAutomationIDTimeout2000() { string auId = "List111"; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, System.Windows.Automation.ControlType.List, "aaa", auId, 0); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaList -AutomationId " + auId + " -timeout 2000 | " + "Read-UiaControlAutomationId", auId); }
public void GetControlAncestors() { string auId = "Button111"; string formName = MiddleLevelCode.TestFormNameEmpty; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, System.Windows.Automation.ControlType.Button, "aaa", auId, 0); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaControl -AutomationId " + auId + " | Get-UiaControlAncestors -ControlType Window | Read-UiaControlName;", formName); }
public void GetMenuBarByAutomationIDTimeoutDefault() { string auId = "MenuBar111"; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, System.Windows.Automation.ControlType.MenuBar, "aaa", auId, 0); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaMenuBar -AutomationId " + auId + " | " + "Read-UiaControlAutomationId", auId); }
public void GetTableByTitleTimeout2000Delay4000() { //string name = "Table222"; string name = "Properties Window"; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, System.Windows.Automation.ControlType.Table, "\"" + name + "\"", "btn", TimeoutsAndDelays.Control_Timeout2000Delay4000_Delay); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaTable -Name '" + name + "' -timeout 2000 | " + "Read-UiaControlName", name); }
// the same as InvokeSelectItem_RadioButton() public void InvokeSelectionItemState_RadioButton() { string name1 = "RadioButton1"; string auId1 = "rb111"; string name2 = "RadioButton2"; string auId2 = "rb222"; string expectedResult = "True"; ControlToForm ctf = new ControlToForm( System.Windows.Automation.ControlType.RadioButton, name1, auId1, TimeoutsAndDelays.Control_Delay0); System.Collections.ArrayList arrList = new System.Collections.ArrayList(); arrList.Add(ctf); ctf = new ControlToForm( System.Windows.Automation.ControlType.RadioButton, name2, auId2, TimeoutsAndDelays.Control_Delay0); arrList.Add(ctf); MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, (ControlToForm[])arrList.ToArray(typeof(ControlToForm))); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"$null = Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaRadioButton -AutomationId '" + auId1 + "' | Invoke-UiaRadioButtonSelectItem -ItemName '" + name1 + @"';" + @"Get-UiaRadioButton -AutomationId '" + auId1 + "' | Get-UiaRadioButtonSelectionItemState;", expectedResult); }
public void InvokeToggleStateGet_CheckBox_Off() { string name = "check_box"; string automationId = "chbx"; string expectedResult = "False"; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, System.Windows.Automation.ControlType.CheckBox, name, automationId, 0); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaCheckBox -Name '" + name + "' | Get-UiaCheckBoxToggleState;", expectedResult); }
public void ConvertToHashtable_AutomationId() { string auId = "Button111"; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, System.Windows.Automation.ControlType.Button, "aaa", auId, 0); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"$hashtable = Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaControl -AutomationId " + auId + " | ConvertTo-UiaHashtable; " + // 20120831 // ?? "$hashtable['AutomationId'];", //"$hashtable[4].Value;", auId); }
public void GetTableByAutomationIDTimeout2000() { string auId = "Table111"; string name = "Properties Window"; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, System.Windows.Automation.ControlType.Table, "aaa", auId, 0); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaPane -AutomationId " + auId + " -timeout 2000 | Get-UiaTable -Name '" + name + "' | " + "Read-UiaControlName", name); }
public void Preferences_TimeoutAfterFail_Control() { string name = "Button333"; string timeoutInterval = "4000"; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, TimeoutsAndDelays.Form_Delay0, System.Windows.Automation.ControlType.Button, name, "btn", TimeoutsAndDelays.Control_Delay0); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"[UIAutomation.Preferences]::Timeout = " + timeoutInterval + "; " + @"try{ $null = Get-UiaWindow -n '" + UIAutomationTestForms.Forms.WinFormsEmpty + "' | Get-UiaButton -n '111' -IsCritical;} catch {} " + @"[UIAutomation.Preferences]::Timeout;", UIAutomation.Preferences.AfterFailTurboTimeout.ToString()); }
public void ConvertToSearchCriteria_Default_AutomationId() { string auId = "Button111"; string result = "True"; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, System.Windows.Automation.ControlType.Button, "aaa", auId, 0); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"$hashtable = Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaControl -AutomationId " + auId + " | ConvertTo-UiaSearchCriteria; " + @"$hashtable.Contains('AutomationId=""" + auId + @"""');", result); }
public void GetControlPreviousSibling() { string name1 = "Button111"; string auId1 = "btn111"; string name2 = "Button222"; string auId2 = "btn22"; System.Collections.ArrayList arrList = new System.Collections.ArrayList(); arrList.Add( new ControlToForm( System.Windows.Automation.ControlType.Button, name1, auId1, TimeoutsAndDelays.Control_Delay0)); arrList.Add( new ControlToForm( System.Windows.Automation.ControlType.Button, name2, auId2, TimeoutsAndDelays.Control_Delay0)); ControlToForm[] ctf = (ControlToForm[])arrList.ToArray(typeof(ControlToForm)); string formName = MiddleLevelCode.TestFormNameEmpty; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, ctf); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + @" | Get-UiaButton -Name '" + name2 + "' | Get-UiaControlPreviousSibling | " + "Read-UiaControlAutomationId;", auId1); }
public void NameAutomationId_NonExisting_Delay() { const string expectedName = "btnName"; const string expectedAutomationId = "btnAuId"; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, ControlType.Button, expectedName, expectedAutomationId, TimeoutsAndDelays.Control_Delay4000); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual1( @"if ((Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " -au " + MiddleLevelCode.TestFormNameEmpty + " | Wait-UiaControlState -SearchCriteria @{name=\"" + expectedName + "\";automationid=\"" + expectedAutomationId + "\"})) { 1; } else { 0; }"); }