Esempio n. 1
0
        //**********************************************************************
        /// <summary>
        /// Map the action and call executeCommand to run script's steps.
        /// </summary>
        public static bool performScripts(ArrayList stepList)
        {
            LxSetup mainOp = LxSetup.getInstance();

            // Map action
            m_ActionMap.Clear();
            m_ActionMap.Add("InputKeys", new object[] { "PressKeys", "1" });
            m_ActionMap.Add("Click", new object[] { "Click", "0" });
            m_ActionMap.Add("Set", new object[] { "Check", "0" });
            m_ActionMap.Add("Clear", new object[] { "Uncheck", "0" });
            // m_ActionMap.Add("UnverifiedClickTab", new object[] {"Click","0"});
            m_ActionMap.Add("DoubleClick", new object[] { "DoubleClick", "0" });
            m_ActionMap.Add("Collapse", new object[] { "CollapseAll", "0" });
            m_ActionMap.Add("Expand", new object[] { "ExpandAll", "0" });
            m_ActionMap.Add("Select", new object[] { "SelectedItemText", "S1" });
            m_ActionMap.Add("CellContentClick", new object[] { "Click", "S2" });
            m_ActionMap.Add("SetTextValue", new object[] { "PressKeys", "S3" });
            m_ActionMap.Add("ClickItem", new object[] { "Click", "S4" });
            m_ActionMap.Add("VerifyToolTips", new object[] { "MoveTo", "S5" });
            m_ActionMap.Add("VerifyContains", new object[] { "Verify", "S6" });
            m_ActionMap.Add("VerifyNotContains", new object[] { "Verify", "S7" });
            m_ActionMap.Add("MoveTo", new object[] { "MoveTo", "S8" });
            m_ActionMap.Add("ClickCell", new object[] { "Click", "S9" });
            m_ActionMap.Add("DoubleClickItem", new object[] { "DoubleClick", "S10" });
            m_ActionMap.Add("RightClick", new object[] { "RightClick", "S11" });

            // Run the item in stepList
            foreach (LxScriptItem item in stepList)
            {
                bool resultFlag = true;
                try
                {
                    resultFlag = executeCommand(item);
                }
                catch (Exception e)
                {
                    resultFlag = false;
                    LxLog.Error("Error", e.Message.ToString());
                }

                // Log each step is pass or not
                mainOp.opXls.writeCell(Convert.ToInt32(item.m_Index) + 1, 14, resultFlag == true?"Pass":"******");
                LxLog.Info("Info", item.m_Index + " " + item.m_Component + " " + item.m_Action + " " + (resultFlag == true?"Success":"Failure"));
//				if(resultFlag == false)
//				{
//					return false;
//				}
            }
            return(true);
        }
Esempio n. 2
0
        //**********************************************************************
        /// <summary>
        /// Map the action and call executeCommand to run script's steps.
        /// </summary>
        public static bool performScripts(ArrayList stepList)
        {
            LxSetup mainOp = LxSetup.getInstance();

            // Map action
            m_ActionMap.Clear();
            m_ActionMap.Add("InputKeys", new object[] { "PressKeys", "1" });
            m_ActionMap.Add("Click", new object[] { "Click", "0" });
            m_ActionMap.Add("Set", new object[] { "Check", "0" });
            m_ActionMap.Add("Clear", new object[] { "Uncheck", "0" });
            // m_ActionMap.Add("UnverifiedClickTab", new object[] {"Click","0"});
            m_ActionMap.Add("DoubleClick", new object[] { "DoubleClick", "0" });
            m_ActionMap.Add("Collapse", new object[] { "CollapseAll", "0" });
            m_ActionMap.Add("Expand", new object[] { "ExpandAll", "0" });
            m_ActionMap.Add("Select", new object[] { "SelectedItemText", "S1" });
            m_ActionMap.Add("CellContentClick", new object[] { "Click", "S2" });
            m_ActionMap.Add("SetTextValue", new object[] { "PressKeys", "S3" });
            m_ActionMap.Add("ClickItem", new object[] { "Click", "S4" });
            m_ActionMap.Add("VerifyToolTips", new object[] { "MoveTo", "S5" });
            m_ActionMap.Add("VerifyContains", new object[] { "Verify", "S6" });
            m_ActionMap.Add("VerifyNotContains", new object[] { "Verify", "S7" });
            m_ActionMap.Add("MoveTo", new object[] { "MoveTo", "S8" });
            m_ActionMap.Add("ClickCell", new object[] { "Click", "S9" });
            m_ActionMap.Add("DoubleClickItem", new object[] { "DoubleClick", "S10" });
            m_ActionMap.Add("RightClick", new object[] { "RightClick", "S11" });
            m_ActionMap.Add("InputCell", new object[] { "Click", "S12" });
            m_ActionMap.Add("ClickLocation", new object[] { "Click", "S13" });

            // Run the item in stepList
            // If wrongCount =3, it means that the command fails three times continuously.
            int    wrongTime  = 3;
            int    wrongCount = 0;
            string groupName  = "TryToRunTimes";
            string key        = "Try_Times";

            wrongTime = int.Parse(myparseToValue(groupName, key));
            //        MessageBox.Show("wrong Time ="+wrongTime);


            bool finalResult = true;

            foreach (LxScriptItem item in stepList)
            {
                bool resultFlag = true;
                try
                {
                    resultFlag = executeCommand(item);
                    wrongCount = 0;
                }
                catch (Exception e)
                {
                    wrongCount++;
                    resultFlag  = false;
                    finalResult = false;
                    LxLog.Error("Error", e.Message.ToString());
                }

                // Log each step is pass or not
                mainOp.opXls.writeCell(Convert.ToInt32(item.m_Index) + 1, 14, resultFlag == true?"Pass":"******");
                LxLog.Info("Info", item.m_Index + " " + item.m_Component + " " + item.m_Action + " " + (resultFlag == true?"Success":"Failure"));

                //If this script fails three times continuously, break this execution.
                if (wrongCount == wrongTime)
                {
                    break;
                }
            }

            return(finalResult);
        }
Esempio n. 3
0
        /// <summary>
        /// Read the application path from scripts and run
        /// </summary>
        public void runApp()
        {
            if (!File.Exists(m_strExcelDirve))
            {
                runOverOneCase(getTestCaseName());
                throw new Ranorex.ElementNotFoundException("The file " + m_strExcelDirve + " not found", null);
            }
            opXls = new LxXlsOper();
            opXls.open(m_strExcelDirve);
            m_strApplicationName = opXls.readCell(2, 2);
            Console.WriteLine(m_strApplicationName);

            m_iRowNum = Convert.ToInt16(opXls.readCell(7, 2));

            m_strPrecondition = opXls.readCell(23, 2);


            string runningRange = opXls.readCell(8, 2);
            Regex  rex          = new Regex("[0-9]+");


            if (runningRange == "" || runningRange.IndexOf("a") != -1)
            {
                m_iRowStart = 1;
                m_iRowEnd   = m_iRowNum;
            }
            else
            {
                string[] range = runningRange.Split('-');
                m_iRowStart = Convert.ToInt16(range[0]);
                if (runningRange.IndexOf("-") == -1)
                {
                    m_iRowEnd = m_iRowNum;
                }
                else
                {
                    m_iRowEnd = Convert.ToInt16(range[1]);
                }
            }

            if (m_iRowStart == 1 && m_strApplicationName != "")
            {
                m_iProcessId = Host.Local.RunApplication(parseToValue(m_strApplicationName));
            }
            else
            {
                m_iProcessId = 0;
            }

            //Excute Precondition script to verify the Precondtion.
            try
            {
                if (!(m_strPrecondition.Trim().Equals("")))
                {
                    VerifyCondition();
                }
            }
            catch (Exception e)
            {
                LxLog.Error("Error", "The Precondition is not ready because: " + e.Message.ToString());
                return;
            }
        }