Пример #1
0
 public void GetWindowByProcessNameTimeout5000()
 {
     MiddleLevelCode.StartProcessWithForm(UIAutomationTestForms.Forms.WinFormsEmpty, 0);
     CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual1(@"if ((Get-UiaWindow -pn " +
                                                         MiddleLevelCode.TestFormProcess +
                                                         " -timeout 5000)) { 1; } else { 0; }");
 }
Пример #2
0
        public void RegisterMenuClosedEvent()
        {
            //string name = "FileDropDown";
            string text      = "File";
            string eventType =
                "AutomationElementIdentifiers.MenuClosedEvent";

            MiddleLevelCode.StartProcessWithForm(
                UIAutomationTestForms.Forms.WinFormsFull,
                0);
            CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual(
                @"$null = Get-UiaWindow -pn " +
                MiddleLevelCode.TestFormProcess +
                @" | Register-UiaMenuClosedEvent " +
                @"-EventAction {$i = 1;}; " +
                @"$null = Get-UiaMenuItem -Name '" +
                text +
                @"' | Invoke-UiaMenuItemClick -PassThru | Invoke-UiaMenuItemClick; " +
                @"$null = Get-UiaWindow -pn " +
                MiddleLevelCode.TestFormProcess +
                @" | Invoke-UiaControlClick; " +
                @"$null = Get-UiaWindow -n " +
                MiddleLevelCode.TestFormNameFull +
                @" | Get-UiaButton -Name b*; " +
                @"[UIAutomation.CurrentData]::LastEventType",
                eventType);
        }
Пример #3
0
        public void InvokeScrollItem_ListBox()
        {
            //string name1 = "listBox1";
            string auId1 = "listBox1";
            string name2 = "h8";
            //string auId2 = "rb222";
            string expectedResult = "False";

            MiddleLevelCode.StartProcessWithForm(
                UIAutomationTestForms.Forms.WinFormsFull,
                0);
            CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual(
                @"if ((Get-UiaWindow -pn " +
                MiddleLevelCode.TestFormProcess +
                " | Get-UiaList -AutomationId '" +
                auId1 +
                "' | Get-UiaListItem -Name '" +
                name2 +
                "' | Read-UiaControlIsOffscreen)) {" +
                "$null = Get-UiaWindow -pn " +
                MiddleLevelCode.TestFormProcess +
                " | Get-UiaList -AutomationId '" +
                auId1 +
                "' | Get-UiaListItem -Name '" +
                name2 +
                "' | Invoke-UiaListItemScrollItem; " +
                @"Get-UiaWindow -pn " +
                MiddleLevelCode.TestFormProcess +
                " | Get-UiaList -AutomationId '" +
                auId1 +
                "' | Get-UiaListItem -Name '" +
                name2 +
                "' | Read-UiaControlIsOffscreen;}",
                expectedResult);
        }
 private void checkIsVisible(
     string name,
     string controlType,
     string propertyName,
     string expectedResult)
 {
     MiddleLevelCode.StartProcessWithForm(
         UIAutomationTestForms.Forms.WinFormsFull,
         0);
     CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual(
         @"if (-not (Get-UiaWindow -pn " +
         MiddleLevelCode.TestFormProcess +
         @" | Get-Uia" +
         controlType +
         " -" + propertyName + " '" +
         name +
         @"').IsVisible) { " +
         @"$null = Get-UiaWindow -pn " +
         MiddleLevelCode.TestFormProcess +
         @" | Get-UiaButton -Name Button2 | Invoke-UiaButtonClick; " +
         @"(-not (Get-UiaWindow -pn " +
         MiddleLevelCode.TestFormProcess +
         @" | Get-Uia" +
         controlType +
         " -" + propertyName + " '" +
         name +
         @"' | Wait-UIA" +
         controlType +
         @"IsVisible | Read-UiaControlIsOffscreen)); } ",
         expectedResult);
 }
Пример #5
0
        public void GetWindowAsGlobalVariableNotEmpty()
        {
            MiddleLevelCode.StartProcessWithForm(UIAutomationTestForms.Forms.WinFormsEmpty, 0);
//            CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual(
//                @"Get-UiaWindow -Name " +
//                MiddleLevelCode.TestFormNameEmpty +
//                "; " +
//                @"if (([uiautomation.currentdata]::currentwindow.current.name" +
//                ")) { 0; } else { 1; }",
//                //"System.Windows.Automation.AutomationElement");
//                // 20131218
//                // "UIAutomation.UiElement");
//                // "Castle.Proxies.UiElementProxy");
//                "Castle.Proxies.UiElementProxy_1");

//            CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual(
//                @"Get-UiaWindow -Name " +
//                MiddleLevelCode.TestFormNameEmpty +
//                "; " +
//                @"if (([uiautomation.currentdata]::currentwindow.current.name" +
//                ")) { 0; } else { 1; }".Substring(0, 30),
//                "Castle.Proxies.UiElementProxy_1".Substring(0, 30));
            // 20140314
            CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual(
                @"Get-UiaWindow -Name " +
                MiddleLevelCode.TestFormNameEmpty +
                "; " +
                @"if (([uiautomation.currentdata]::currentwindow.current.name" +
                ")) { 0; } else { 1; }",
                "Castle.Proxies.UiElementProxy_2");
        }
        public void Invoke_ComboBox_Collapse()
        {
            string expectedResult = "b02";

//            string expectedResult1 = "CmdletInvocationException";
//            //string expectedResult2 = "Get-UiaListItem: timeout expired for class: ' + , control type: ListItem, title: b2";
//            string expectedResult2 = "The target element corresponds to UI that is no longer available (for example, the parent";
            MiddleLevelCode.StartProcessWithForm(
                UIAutomationTestForms.Forms.WinFormsFull,
                0);
            CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual(
                @"Get-UiaWindow -pn " +
                MiddleLevelCode.TestFormProcess +
                " | Get-UiaComboBox -AutomationId comboBox4 | Invoke-UiaComboBoxExpand " +
                " | Get-UiaListItem -Name b02 | Read-UiaControlName;",
                expectedResult);
//            CmdletUnitTest.TestRunspace.RunAndGetTheException(
//                @"$null = Get-UiaWindow -pn " +
//                MiddleLevelCode.TestFormProcess +
//                " | Get-UiaListItem -Name b2;",
//                expectedResult1,
//                expectedResult2);
            CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual(
                @"$null = Get-UiaComboBox -AutomationId comboBox4 | Invoke-UiaComboBoxCollapse; " +
                @"try {" +
                " Get-UiaListItem -Name b02 | Read-UiaControlIsOffscreen; } catch { \"1\"; };",
                "True");
        }
Пример #7
0
 public void MoveUiaCursor_TestParameterInputAutomationElement()
 {
     MiddleLevelCode.StartProcessWithForm(UIAutomationTestForms.Forms.WinFormsEmpty, 0);
     CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual1(@"if ((Get-UiaWindow -pn " +
                                                         MiddleLevelCode.TestFormProcess +
                                                         " | Move-UiaCursor -X 1 -Y 1)) { 1; } else { 0; }");
 }
Пример #8
0
 public void GetWindowByClassName_WildCard_TimeoutDefault()
 {
     MiddleLevelCode.StartProcessWithForm(UIAutomationTestForms.Forms.WinFormsEmpty, 0);
     CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual1(@"if ((Get-UiaWindow -Class '" +
                                                         @"*WindowsForms10.Window.8.app*'" +
                                                         ")) { 1; } else { 0; }");
 }
Пример #9
0
 public void GetWindowByAutomationId_WildCard_TimeoutDefault()
 {
     MiddleLevelCode.StartProcessWithForm(UIAutomationTestForms.Forms.WinFormsEmpty, 0);
     CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual1(@"if ((Get-UiaWindow -AutomationId '*Empty*'" +
                                                         //MiddleLevelCode.TestFormNameEmpty +
                                                         ")) { 1; } else { 0; }");
 }
Пример #10
0
        private void checkIsEnabled(
            string name,
            string controlType,
            string propertyName,
            string expectedResult)
        {
            MiddleLevelCode.StartProcessWithForm(
                UIAutomationTestForms.Forms.WinFormsFull,
                0);

            CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual(
                @"$null = Get-UiaWindow -pn " +
                MiddleLevelCode.TestFormProcess +
                "; " +
                @"if (Test-UiaControlState -searchCriteria @{" +
                propertyName +
                @"=""" +
                name +
                @""";IsEnabled=$false}){ $null = Get-UiaButton -Name Button2 | Invoke-UiaButtonClick; " +
                @"Get-Uia" +
                controlType +
                " -" + propertyName + " '" +
                name +
                @"' | Wait-UIA" +
                controlType +
                @"IsEnabled | Read-UiaControlIsEnabled; }",
                expectedResult);
        }
Пример #11
0
 public void GetWindowByName_Wildcard3_TimeoutDefault()
 {
     MiddleLevelCode.StartProcessWithForm(UIAutomationTestForms.Forms.WinFormsEmpty, 0);
     CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual1(@"if ((Get-UiaWindow -Name ?" +
                                                         MiddleLevelCode.TestFormNameEmpty.Substring(1, MiddleLevelCode.TestFormNameEmpty.Length - 2) +
                                                         "?" +
                                                         ")) { 1; } else { 0; }");
 }
Пример #12
0
        public void WaitWindow_ByProcessId_Wrong_Timeout2000()
        {
            MiddleLevelCode.StartProcessWithForm(UIAutomationTestForms.Forms.WinFormsEmpty, 0);

            CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual(
                @"Wait-UiaWindow -pid 0 -Seconds 2;",
                "False");
        }
Пример #13
0
 public void GetWindowByProcessFoundTimeoutDefault()
 {
     MiddleLevelCode.StartProcessWithForm(UIAutomationTestForms.Forms.WinFormsEmpty, 0);
     CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual1(@"if ((Get-Process -Name " +
                                                         MiddleLevelCode.TestFormProcess +
                                                         " | Get-UiaWindow" +
                                                         ")) { 1; } else { 0; }");
 }
Пример #14
0
 public void GetWindowByNameDelay1000()
 {
     MiddleLevelCode.StartProcessWithForm(
         UIAutomationTestForms.Forms.WinFormsEmpty,
         TimeoutsAndDelays.Form_Delay1000);
     CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual1(@"if ((Get-UiaWindow -Name " +
                                                         MiddleLevelCode.TestFormNameEmpty +
                                                         ")) { 1; } else { 0; }");
 }
Пример #15
0
 public void GetWindowByClass_Win32_Delay2000_NoTaskBar()
 {
     MiddleLevelCode.StartProcessWithForm(
         UIAutomationTestForms.Forms.WinFormsNoTaskBar,
         TimeoutsAndDelays.Form_Delay2000);
     CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual1(@"if ((Get-UiaWindow -Win32 -class " +
                                                         @"*WindowsForms10.Window.8.app.0*" +
                                                         ")) { 1; } else { 0; }");
 }
Пример #16
0
 public void GetWindowByAutomationId_Win32_Delay2000_NoTaskBar()
 {
     MiddleLevelCode.StartProcessWithForm(
         UIAutomationTestForms.Forms.WinFormsNoTaskBar,
         TimeoutsAndDelays.Form_Delay2000);
     CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual1(@"if ((Get-UiaWindow -Win32 -au " +
                                                         MiddleLevelCode.TestFormNameNoTaskBar +
                                                         ")) { 1; } else { 0; }");
 }
Пример #17
0
 public void GetWindowAsGlobalVariableSetNull()
 {
     MiddleLevelCode.StartProcessWithForm(UIAutomationTestForms.Forms.WinFormsEmpty, 0);
     CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual1(
         @"$ErrorActionPreference = [system.management.automation.actionpreference]::SilentlyContinue; " +
         @"try{ Get-UiaWindow -pn 'no such process' -seconds 2; } catch {} " +
         @"if (([uiautomation.currentdata]::currentwindow.current.name" +
         ")) { 0; } else { 1; }");
 }
Пример #18
0
        public void Preferences_AfterFailTurboTimeout_DefaultValue()
        {
            string timeoutInterval = "2000";

            MiddleLevelCode.StartProcessWithForm(UIAutomationTestForms.Forms.WinFormsEmpty, 0);
            CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual(
                @"[UIAutomation.Mode]::Profile = [UIAutomation.Modes]::Presentation; " +
                @"[UIAutomation.Preferences]::AfterFailTurboTimeout;",
                timeoutInterval);
        }
Пример #19
0
 public void GetWindowByProcess_Recurse_TimeoutDefault()
 {
     MiddleLevelCode.StartProcessWithForm(UIAutomationTestForms.Forms.WinFormsThreeSet, 0);
     prepareThreeForms();
     CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual(
         @"(Get-UiaWindow -InputObject (Get-Process " +
         MiddleLevelCode.TestFormProcess +
         ") -Recurse).Count",
         "3");
 }
Пример #20
0
        public void WaitWindow_ByProcessName_Timeout2000()
        {
            MiddleLevelCode.StartProcessWithForm(UIAutomationTestForms.Forms.WinFormsEmpty, 0);

            CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual(
                @"Wait-UiaWindow -pn '" +
                MiddleLevelCode.TestFormProcess +
                "' -Seconds 2;",
                "True");
        }
Пример #21
0
        public void ReadUiaControlName_TestParameterInputFormWithTitle()
        {
//            CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual(
//                @"Get-UiaWindow -Name '" +
//                CmdletUnitTest.TestRunspace.NUnitTitle +
//                "' | Read-UiaControlName",
//                CmdletUnitTest.TestRunspace.NUnitTitle);
            MiddleLevelCode.StartProcessWithForm(UIAutomationTestForms.Forms.WinFormsEmpty, 0);
            CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual1(@"if ((Get-UiaWindow -n " +
                                                                MiddleLevelCode.TestFormNameEmpty +
                                                                " | Read-UiaControlName)) { 1; } else { 0; }");
        }
Пример #22
0
 public void GetWindowByHandle1TimeoutDefault()
 {
     MiddleLevelCode.StartProcessWithForm(UIAutomationTestForms.Forms.WinFormsEmpty, 0);
     CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual(
         @"[void]($handle = Get-Process -Name " +
         MiddleLevelCode.TestFormProcess +
         " | Get-UiaWindow | Read-UiaControlNativeWindowHandle); " +
         @"[void]([UIAutomation.CurrentData]::ResetData()); " +
         @"sleep -Seconds 2; " +
         "Get-UiaWindowFromHandle -Handle $handle | Read-UIAcontrolName;",
         MiddleLevelCode.TestFormNameEmpty);
 }
Пример #23
0
        public void TreeItem_IsSelected_False()
        {
            string expectedResult = "False";

            MiddleLevelCode.StartProcessWithForm(
                UIAutomationTestForms.Forms.WinFormsFull,
                0);
            CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual(
                @"(Get-UiaWindow -pn " +
                MiddleLevelCode.TestFormProcess +
                @" | Get-UiaTreeItem -Name Node0).IsSelected;",
                expectedResult);
        }
Пример #24
0
        public void Preferences_TimeoutAfterSuccess_Window_2()
        {
            string timeoutInterval = "10000";

            MiddleLevelCode.StartProcessWithForm(UIAutomationTestForms.Forms.WinFormsEmpty, 0);
            CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual(
                @"[UIAutomation.Preferences]::Timeout = 10000; " +
                @"$null = Get-UiaWindow -n " +
                MiddleLevelCode.TestFormNameEmpty +
                "; " +
                @"[UIAutomation.Preferences]::Timeout;",
                timeoutInterval);
        }
Пример #25
0
        public void Invoke_ComboBox_Expand()
        {
            string expectedResult = "b2";

            MiddleLevelCode.StartProcessWithForm(
                UIAutomationTestForms.Forms.WinFormsFull,
                0);
            CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual(
                @"Get-UiaWindow -pn " +
                MiddleLevelCode.TestFormProcess +
                " | Get-UiaComboBox -AutomationId comboBox1 | Invoke-UiaComboBoxExpand " +
                " | Get-UiaListItem -Name b2 | Read-UiaControlName;",
                expectedResult);
        }
Пример #26
0
        public void Invoke_MenuItem_Click()
        {
            string expectedResult = "DropDownButton1";

            MiddleLevelCode.StartProcessWithForm(
                UIAutomationTestForms.Forms.WinFormsFull,
                0);
            CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual(
                @"Get-UiaWindow -pn " +
                MiddleLevelCode.TestFormProcess +
                " | Get-UiaMenuItem -Name toolStripDropDownButton2 | Invoke-UiaMenuItemClick " +
                " | Get-UiaMenuItem -Name '" +
                expectedResult +
                @"' | Read-UiaControlName;",
                expectedResult);
        }
        public void TreeItem_ExpandCollapseState_Expanded()
        {
            string expectedResult = "Expanded";

            MiddleLevelCode.StartProcessWithForm(
                UIAutomationTestForms.Forms.WinFormsFull,
                0);
            CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual(
                @"$null = (Get-UiaWindow -pn " +
                MiddleLevelCode.TestFormProcess +
                @" | Get-UiaTreeItem -Name Node0).Expand(); " +
                @"(Get-UiaWindow -pn " +
                MiddleLevelCode.TestFormProcess +
                @" | Get-UiaTreeItem -Name Node0).ExpandCollapseState; ",
                expectedResult);
        }
Пример #28
0
        public void ListItem_Select()
        {
            string expectedResult = "True";

            MiddleLevelCode.StartProcessWithForm(
                UIAutomationTestForms.Forms.WinFormsFull,
                0);
            CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual(
                @"$null = (Get-UiaWindow -pn " +
                MiddleLevelCode.TestFormProcess +
                @" | Get-UiaListItem a001).Select(); " +
                @"(Get-UiaWindow -pn " +
                MiddleLevelCode.TestFormProcess +
                @" | Get-UiaListItem a001).IsSelected;",
                expectedResult);
        }
Пример #29
0
        public void GetWindowByPIDWrong()
        {
            MiddleLevelCode.StartProcessWithForm(UIAutomationTestForms.Forms.WinFormsEmpty, 0);

            CmdletUnitTest.TestRunspace.RunAndGetTheException(
                @"if ((Get-UiaWindow -pid " +
                "12345678 -Seconds 2" +
                ")) { 0; } else { 1; }",
                "CmdletInvocationException",
                // 20130318
                //"Failed to get the window by: process name: '' process Id: 12345678 window title: ''");
                // 20131108
                //"Failed to get the window by: process name: '', process Id: 12345678, window title: '', automationId: '', className: ',");
                // 20140110
                // "Failed to get window in 2000 seconds by: process name: '', process Id: 12345678, window title: '', automationId: '', className: ''");
                "Failed to get window in 2000 milliseconds by: process name: '', process Id: 12345678, window title: '', automationId: '', className: ''.");
        }
Пример #30
0
        public void Preferences_TimeoutAfterFailAndFurtherSuccess_Window_WindowTitle()
        {
            string windowTitle     = "no such window";
            string timeoutInterval = "4000";

            MiddleLevelCode.StartProcessWithForm(UIAutomationTestForms.Forms.WinFormsEmpty, 0);
            CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual(
                @"[UIAutomation.Preferences]::Timeout = 4000; " +
                @"try{ $null = Get-UiaWindow -n '" +
                windowTitle +
                "';} catch {} " +
                @"try{ $null = Get-UiaWindow -n '" +
                MiddleLevelCode.TestFormNameEmpty +
                "';} catch {} " +
                @"[UIAutomation.Preferences]::Timeout;",
                timeoutInterval);
        }