コード例 #1
0
        private void RunsScript()
        {
            guiTestActionLib = Path.Combine(progDir, "GUITestActionLib.xml");

            GUITestUtility.GUIInfo guiUnit = (GUITestUtility.GUIInfo)seqGUIUT.GUIList[clickNum];

            string        ctrlAction = GUITestUtility.GetAGUIAction(guiTestActionLib, guiUnit.GUIControlType);
            StringBuilder sb         = new StringBuilder(10000);

            try             //chapter 12
            {
                Control ctrlTested = (Control)GUITestUtility.VerifyField(AUT, guiUnit.GUIControlName);
                GUITestActions.GetWindowText((int)ctrlTested.Handle, sb, 10000);
            }
            catch {}

            //object[] paramArr = new object[4];
            object[] paramArr = new object[5];             //chapter 10

            if (ctrlAction == "HandleMenuItems")           //chapter 12
            {
                paramArr[0] = AUT.Handle.ToInt32();
            }
            else
            {
                paramArr[0] = 0;
            }

            paramArr[1] = sb.ToString();
            paramArr[2] = guiUnit.GUIClassName;
            paramArr[3] = guiUnit.GUIParentText;
            paramArr[4] = guiUnit.TextEntry;             //chapter 10

            Type       guiTestLibType = new GUITestActions().GetType();
            object     obj            = Activator.CreateInstance(guiTestLibType);
            MethodInfo mi             = guiTestLibType.GetMethod(ctrlAction);

            //chapter 11
            preChecked = DeterminePreCheckedStatus(guiUnit);

            try
            {
                mi.Invoke(obj, paramArr);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            if (clickNum < seqGUIUT.GUIList.Count)
            {
                clickNum++;
                tmrRunScript.Enabled  = false;
                tmrStopScript.Enabled = true;
            }
        }
コード例 #2
0
        private void RunsScript()
        {
            guiTestActionLib = Path.Combine(progDir, "GUITestActionLib.xml");

            GUITestUtility.GUIInfo guiUnit = (GUITestUtility.GUIInfo)seqGUIUT.GUIList[clickNum];

            string ctrlAction = GUITestUtility.GetAGUIAction(guiTestActionLib, guiUnit.GUIControlType);

            StringBuilder sb = new StringBuilder(10000);

            Control ctrlTested = (Control)GUITestUtility.VerifyField(AUT, guiUnit.GUIControlName);

            GUITestActions.GetWindowText((int)ctrlTested.Handle, sb, 10000);

            object[] paramArr = new object[4];
            paramArr[0] = 0;
            paramArr[1] = sb.ToString();            //.Replace("\r\n", "\n");
            paramArr[2] = guiUnit.GUIClassName;
            paramArr[3] = guiUnit.GUIParentText;

            Type       guiTestLibType = new GUITestActions().GetType();
            object     obj            = Activator.CreateInstance(guiTestLibType);
            MethodInfo mi             = guiTestLibType.GetMethod(ctrlAction);

            try
            {
                mi.Invoke(obj, paramArr);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            if (clickNum < seqGUIUT.GUIList.Count)
            {
                clickNum++;
                tmrRunScript.Enabled  = false;
                tmrStopScript.Enabled = true;
            }
        }