Exemple #1
0
        public override EnumActionResult Execute()
        {
            string column = _vm.variables.Get(m_params[1]);
            string value  = _vm.variables.Get(m_params[3]);

            string[] columns = column.Split('|');
            string[] values  = value.Split('|');
            bool[]   founds  = new bool[columns.Length];

            ControlGrid grd = _vm.GetGrid();
            List <Dictionary <string, string> > rows = grd.Rows;

            int i = 0;

            foreach (Dictionary <string, string> item in rows)
            {
                for (int j = 0; j < founds.Length; ++j)
                {
                    founds[j] = false;
                }

                int colIndex = 0;

                foreach (string col in columns)
                {
                    if (!item.ContainsKey(col))
                    {
                        _vm.host.WriteLog("Column '" + col + "' NOT found.");
                        return(EnumActionResult.ERROR);
                    }

                    if (values[colIndex] == item[col])
                    {
                        _vm.host.WriteLog("Item '" + item[col] + "' found in column '" + columns[colIndex] + "'");
                        founds[colIndex] = true;
                    }
                    ++colIndex;
                }

                bool found = false;

                for (int k = 0; k < founds.Length; ++k)
                {
                    found = founds[k];
                }

                if (found)
                {
                    _vm.host.UpdateMarker(grd.aeRows[i].Current.BoundingRectangle);
                    _vm.host.aeCurrent = grd.aeRows[i];
                    AutomationPattern.ScrollIntoView(_vm.host.aeCurrent);
                    _vm.host.aeCurrent.SetFocus();
                    return(EnumActionResult.TEST_OK);
                }
                ++i;
            }
            _vm.host.WriteLog("Item NOT found.");
            return(EnumActionResult.TEST_FAILED);
        }
        public override EnumActionResult Execute()
        {
            AutomationElement head = Finder.GetDataGridHeader(_vm.host.aeCurrent);

            if (null == head)
            {
                UtilSys.MessageBox("Unable to find grid header.");
                return(EnumActionResult.ERROR);
            }

            int i = 0;

            string[] colNames = Finder.GetDataGridHeadNames(head);

            ControlGrid grd = new ControlGrid();

            grd.Name = "griiid";

            _vm.AddControl(grd);

            ControlGrid grid = _vm.GetGrid();

            grid.Rows.Clear();

            grid.aeRows = UtilAutomation.GetDataGridRows(_vm.host.aeCurrent);

            if (null == grid.aeRows)
            {
                _vm.host.WriteLog("no DataGrid items???");
                return(EnumActionResult.ERROR);
            }

            _vm.host.WriteLog("Listing DataGridItems: " + grid.aeRows.Count);
            _vm.host.WriteLog("----------------------------- Begin");

            foreach (AutomationElement item in grid.aeRows)
            {
                _vm.host.UpdateMarker(item.Current.BoundingRectangle);

                i = 0;
                AutomationElementCollection cells = Finder.GetDataGridRowCells(item);

                Dictionary <string, string> d = new Dictionary <string, string>();

                foreach (AutomationElement cell in cells)
                {
                    //string msg = colNames[i] + ": " + cell.Current.Name;
                    //_vm.host.WriteLog(msg);
                    d.Add(colNames[i], cell.Current.Name);
                    ++i;
                }
                grid.Rows.Add(d);
            }
            _vm.host.WriteLog("----------------------------- End");
            return(EnumActionResult.OK);
        }
Exemple #3
0
        public override EnumActionResult Execute()
        {
            try
            {
                string key = string.Empty;

                int indexToFind = int.Parse(_vm.variables.Get(m_params[1]));

                ControlGrid grd = _vm.GetGrid();

                if (indexToFind >= grd.aeRows.Count)
                {
                    _vm.host.WriteLog("GetCellValue Requested index is greater [" + indexToFind + "] than number of rows is: " + grd.aeRows.Count);
                    return(EnumActionResult.ERROR);
                }

                _vm.host.aeCurrent = grd.aeRows[indexToFind];

                _vm.host.UpdateMarker(_vm.host.aeCurrent.Current.BoundingRectangle);
                AutomationPattern.ScrollIntoView(_vm.host.aeCurrent);
                _vm.host.aeCurrent.SetFocus();

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

                Dictionary <string, string> dic = grd.Rows[indexToFind];

                AutomationElement           row   = grd.aeRows[indexToFind];
                AutomationElementCollection cells = row.FindAll(TreeScope.Children, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Text));

                int j = 0;
                foreach (string k in dic.Keys)
                {
                    if (k == key)
                    {
                        string value = cells[j].Current.Name;
                        _vm.variables.Update(m_params[5], value);

                        return(EnumActionResult.OK);
                    }
                    ++j;
                }

                _vm.host.WriteLog("GetCellValue Column [" + key + "] NOT found");

                return(EnumActionResult.ERROR);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #4
0
        public override EnumActionResult Execute()
        {
            try
            {
                string key = string.Empty;

                int indexToFind = int.Parse(_vm.variables.Get(m_params[1]));

                ControlGrid grd = _vm.GetGrid();

                _vm.host.aeCurrent = grd.aeRows[indexToFind];

                _vm.host.UpdateMarker(_vm.host.aeCurrent.Current.BoundingRectangle);
                AutomationPattern.ScrollIntoView(_vm.host.aeCurrent);
                _vm.host.aeCurrent.SetFocus();


                AutomationElement           row   = grd.aeRows[indexToFind];
                AutomationElementCollection cells = row.FindAll(TreeScope.Children, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Text));

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

                Dictionary <string, string> dic = grd.Rows[indexToFind];

                int j = 0;

                foreach (string k in dic.Keys)
                {
                    if (k == key)
                    {
                        UtilAutomation.ClickOn(cells[j].Current.BoundingRectangle, true);
                        UtilSys.Wait(500);

                        string value = _vm.variables.Get(m_params[5]);
                        value += "+{ENTER}";
                        System.Windows.Forms.SendKeys.SendWait(value);

                        return(EnumActionResult.OK);
                    }
                    ++j;
                }
                return(EnumActionResult.ERROR);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public override EnumActionResult Execute()
        {
            try
            {
                int indexToFind = int.Parse(_vm.variables.Get(m_params[1]));

                ControlGrid grd = _vm.GetGrid();

                _vm.host.aeCurrent = grd.aeRows[indexToFind];

                _vm.host.UpdateMarker(_vm.host.aeCurrent.Current.BoundingRectangle);
                AutomationPattern.ScrollIntoView(_vm.host.aeCurrent);
                _vm.host.aeCurrent.SetFocus();
                return(EnumActionResult.TEST_OK);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #6
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);
            }
        }
Exemple #7
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);
        }