Beispiel #1
0
        public override EnumActionResult Execute()
        {
            ControlUltraTree utree = _vm.GetUltraTree();

            if (null == utree)
            {
                _vm.host.WriteLog("No ultra tree object.");
                return(EnumActionResult.ERROR);
            }

            string key = _vm.variables.Get(m_params[1]);

            if (false == utree.Children.ContainsKey(key))
            {
                _vm.host.WriteLog("Ultra Tree Children doesn't contain key: '" + key + "'");
                return(EnumActionResult.ERROR);
            }

            AutomationElement treeItem = utree.Children[key];

            _vm.host.UpdateMarker(treeItem.Current.BoundingRectangle);
            UtilAutomation.ClickOn(treeItem.Current.BoundingRectangle, false);

            return(EnumActionResult.OK);
        }
Beispiel #2
0
        private void Explore(AutomationElement tree)
        {
            _vm.host.UpdateMarker(tree.Current.BoundingRectangle);

            PropertyCondition           typeTreeItem = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.TreeItem);
            AutomationElementCollection col          = tree.FindAll(TreeScope.Descendants, typeTreeItem);

            if (0 == col.Count)
            {
                _vm.host.WriteLog("No elements, nothing to explore.");
                return;
            }

            ControlUltraTree utree = new ControlUltraTree();

            utree.Name = tree.Current.AutomationId;

            double LeftParent = col[0].Current.BoundingRectangle.Left;

            foreach (AutomationElement elem in col)
            {
                double LeftCurrent = elem.Current.BoundingRectangle.Left;

                if (LeftCurrent == LeftParent) // root element
                {
                    utree.Roots.Add(elem.Current.Name, elem);
                }
                else
                {
                    utree.Children.Add(elem.Current.Name, elem);
                }
            }
            _vm.AddControl(utree);
        }
Beispiel #3
0
        private void CollapseAll(AutomationElement tree)
        {
            ControlUltraTree utree = _vm.GetUltraTree();

            if (null == utree)
            {
                string msg = "'CollapseAll' command is used in pair with 'ExpandAll'.";
                _vm.host.WriteLog(msg);
                return;
            }

            List <AutomationElement> list = new List <AutomationElement>();

            foreach (KeyValuePair <string, AutomationElement> item in utree.Roots)
            {
                list.Add(item.Value);
            }

            for (int i = list.Count - 1; i > -1; --i)
            {
                _vm.host.UpdateMarker(list[i].Current.BoundingRectangle);
                UtilAutomation.ClickOn(list[i].Current.BoundingRectangle, true);
                UtilSys.Wait(40);
            }
            _vm.RemoveControl(tree.Current.Name);
        }
Beispiel #4
0
        public void AddControl(ControlBase ctrl)
        {
            if (ctrl is ControlUltraTree)
            {
                m_utree = (ControlUltraTree)ctrl;
            }

            if (ctrl is ControlGrid)
            {
                m_grid = (ControlGrid)ctrl;
            }

            if (m_dicControls.ContainsKey(ctrl.Name))
            {
                m_dicControls[ctrl.Name] = ctrl;
            }
            else
            {
                m_dicControls.Add(ctrl.Name, ctrl);
            }
        }
Beispiel #5
0
        public bool Init()
        {
            m_Status = VMStatus.INITIALIZATION;

            string path = Path.Combine(host.StartupPath, @"data\log\" + Path.GetFileNameWithoutExtension(m_script.Path) + ".log");

            host.SetLogFile(path, host.BigBrother);

            m_variables = new VariableManager(this, m_script);

            StringBuilder sb = new StringBuilder();

            sb.Append("<Playback ");

            string[,] attributes =
            {
                { "script=",  m_script.Path             },
                { "On=",      UtilSys.GetDateTime()     },
                { "Autorun=", host.IsAutorun.ToString() },
            };

            for (int i = 0; i < attributes.GetLength(0); ++i)
            {
                sb.Append(" " + attributes[i, 0] + "\"" + attributes[i, 1] + "\"");
            }

            sb.Append(">");

            string msg = sb.ToString();

            host.WriteLog(msg);

            m_dtStartTime = DateTime.Now;

            m_actionError = null;

            // register events are using this
            m_bErrorIsHandled = false;
            m_bQuitIsHandled  = false;

            m_utree = null;
            m_grid  = null;
            m_dicControls.Clear();
            m_dicCache.Clear();
            m_dicGotoCounts.Clear();
            m_InstrStack.Clear();
            m_CallStack.Clear();
            m_IfStack.Clear();
            m_LoopStack.Clear(); // this stack is used by instructions like for, while, foreach
            m_FnNameStack.Clear();
            m_ErrStack.Clear();

            m_listAfterEachCommand.Clear();
            m_listAfterCommands.Clear();
            m_listOnError.Clear();
            m_listOnQuit.Clear();

            host.ReleaseSQLStuff();

            m_FnNameStack.Push(VariableManager._GlobalScopeName);

            m_variables.Reset();
            m_variables.AddSystem("$ERROR", "False");
            m_variables.AddSystem("sys.speed", Speed.ToString());
            m_variables.AddSystem("sys.SaveScreenshotOnError", m_bSaveScreenshotOnError.ToString());
            m_variables.AddSystem("env.ScreenWidht", Screen.PrimaryScreen.Bounds.Width.ToString());
            m_variables.AddSystem("env.ScreenHeight", Screen.PrimaryScreen.Bounds.Height.ToString());


            foreach (KeyValuePair <string, string> kv in m_script.Scopes[0].Variables)
            {
                m_variables.Add(kv.Key, kv.Value);
            }

            foreach (KeyValuePair <string, string> kv in m_script.Scopes[0].Consts)
            {
                m_variables.AddConst(kv.Key, kv.Value);
            }

            foreach (KeyValuePair <string, string> kv in Data.Vars)
            {
                m_variables.AddExternal(kv.Key, kv.Value);
            }

            m_IP = m_script.EntryPoint;

            if (-1 == m_IP)
            {
                m_ErrStack.Push("No entry point in script.\r\nEdit script file and enter the [sys.start] command from which point you want playback to begin.");
                return(false);
            }

            m_Status = VMStatus.IN_PLAYBACK;
            return(true);
        }