/// <summary>
        /// get a Selenium Action for the line
        /// </summary>
        /// <param name="actLine">the action line</param>
        /// <returns>the Selenium Action</returns>
        public override IAction getAction(ActionLine actLine)
        {
            IWebElement targetControl = null;

            if (!Actions.ContainsKey(actLine.ActionName))
                return null;

            if (actLine.WindowName != null)
            {
                if (!CheckWindow(actLine.WindowName))
                    throw new Exception(Constants.Messages.Error_Matching_Window_NotFound);

                if (actLine.ControlName != null)
                {
                    if (!Parent.Interfaces[actLine.WindowName].Controls.ContainsKey(actLine.ControlName))
                throw new Exception(Constants.Messages.Error_Matching_Control_NoDefinition);

                targetControl = FindControl(Parent.Interfaces[actLine.WindowName].Controls[actLine.ControlName]);
                    if (targetControl == null)
                        throw new Exception(Constants.Messages.Error_Matching_Control_NotFound);
                }
            }

            // prepare the action
            SeleniumAction action = Actions[actLine.ActionName] as SeleniumAction;
            action.Control = targetControl;
            action.Params = actLine.Arguments;

            return action;
        }
Example #2
0
        /// <summary>
        /// write an error to the report
        /// </summary>
        /// <param name="actLine">the error action line</param>
        /// <param name="why">the reason</param>
        public void WriteError(ActionLine actLine, string why)
        {
            SourceLine line = new SourceLine();
            for (int i = 0; i < Indent + 1; i++)
                line.Columns.Add(string.Empty);

            line.Columns.Add(actLine.ActionName);
            if (actLine.WindowName != null || actLine.ControlName != null)
            {
                line.Columns.Add(actLine.WindowName != null ? actLine.WindowName : string.Empty);
                line.Columns.Add(actLine.ControlName != null ? actLine.ControlName : string.Empty);
            }
            foreach (string key in actLine.Arguments.Keys)
                line.Columns.Add(key + Constants.PropertyDelimeter + actLine.Arguments[key]);
            line.Columns.Add(Constants.ReportText.ErrorLinePrefix + why);

            Lines.Add(line);
        }
Example #3
0
        /// <summary>
        /// write a line to the report
        /// </summary>
        /// <param name="actLine">information about the action</param>
        /// <param name="result">result of the action</param>
        public void WriteLine(ActionLine actLine, ActionResult result)
        {
            SourceLine line = new SourceLine();
            for (int i = 0; i < Indent + 1; i++)
                line.Columns.Add(string.Empty);

            line.Columns.Add(actLine.ActionName);
            if (actLine.WindowName != null || actLine.ControlName != null)
            {
                line.Columns.Add(actLine.WindowName != null ? actLine.WindowName : string.Empty);
                line.Columns.Add(actLine.ControlName != null ? actLine.ControlName : string.Empty);
            }
            foreach (string key in actLine.Arguments.Keys)
                line.Columns.Add(key + Constants.PropertyDelimeter + actLine.Arguments[key]);
            line.Columns.Add(result != ActionResult.NORET ? result.ToString() : string.Empty);

            if (result == ActionResult.PASSED || result == ActionResult.FAILED)
            {
                TotalCheck++;
                if (result == ActionResult.PASSED)
                    TotalPassed++;
            }
            else if (result == ActionResult.WARNING)
                TotalWarning++;

            Lines.Add(line);
        }
        /// <summary>
        /// create an action for the line
        /// </summary>
        /// <param name="actLine">the action line</param>
        /// <returns>the action</returns>
        public override IAction getAction(ActionLine actLine)
        {
            Window targetWindow = null;
            IUIItem targetControl = null;

            if (!Actions.ContainsKey(actLine.ActionName))
                return null;
            if (actLine.WindowName != null && !Parent.Interfaces.ContainsKey(actLine.WindowName))
                throw new Exception(Constants.Messages.Error_Matching_Window_NoDefinition);

            // search for the target control
            if (actLine.WindowName != null)
            {
                targetWindow = FindWindow(Parent.Interfaces[actLine.WindowName].Properties);
                if (targetWindow != null && actLine.ControlName != null)
                {
                    if (!Parent.Interfaces[actLine.WindowName].Controls.ContainsKey(actLine.ControlName))
                        throw new Exception(Constants.Messages.Error_Matching_Control_NoDefinition);

                    targetControl = FindControl(targetWindow, Parent.Interfaces[actLine.WindowName].Controls[actLine.ControlName]);
                }
            }

            // prepare the action
            UIAAction action = Actions[actLine.ActionName] as UIAAction;
            action.Window = targetWindow;
            action.Control = targetControl;
            action.Params = actLine.Arguments;

            return action;
        }
Example #5
0
 /// <summary>
 /// create an action for the line
 /// </summary>
 /// <param name="actLine">the action line</param>
 /// <returns>the action</returns>
 public virtual IAction getAction(ActionLine actLine)
 {
     return null;
 }
Example #6
0
        /// <summary>
        /// process script data from parser
        /// </summary>
        protected override void ProcessLoadedData()
        {
            base.ProcessLoadedData();

            try
            {
                // process each source line: convert it to action line
                foreach (SourceLine line in Parser.Lines)
                {
                    if (line.ColumnCount > 0)
                    {
                        ActionLine actLine = new ActionLine();
                        actLine.ActionName = line.Columns[0].ToLower();
                        for (int i = 1; i < line.ColumnCount; i++)
                        {
                            string[] pairs = line.Columns[i].Split(Constants.PropertyDelimeter.ToCharArray(), 2);
                            if (pairs.Length != 2)
                                throw new FormatException(Constants.Messages.Error_Parsing_Script);
                            if (Constants.Keywords.KeywordWindow.Equals(pairs[0], StringComparison.CurrentCultureIgnoreCase))
                                actLine.WindowName = pairs[1].ToLower();
                            else if (Constants.Keywords.KeywordControl.Equals(pairs[0], StringComparison.CurrentCultureIgnoreCase))
                                actLine.ControlName = pairs[1].ToLower();
                            else
                                actLine.Arguments[pairs[0].ToLower()] = pairs[1];
                        }
                        ActionLines.Add(actLine);
                    }
                }
            }
            catch
            {
                ActionLines.Clear();

                throw;
            }
        }
Example #7
0
        /// <summary>
        /// manipulate action line with data from DataSet
        /// </summary>
        /// <param name="actLine">the raw action line</param>
        /// <returns>the manipulated action line</returns>
        private ActionLine ManipulateData(ActionLine actLine)
        {
            ActionLine newLine = new ActionLine();
            newLine.ActionName = actLine.ActionName;
            newLine.WindowName = CheckForVariable(actLine.WindowName);
            newLine.ControlName = CheckForVariable(actLine.ControlName);

            foreach (string key in actLine.Arguments.Keys)
                newLine.Arguments[key] = CheckForVariable(actLine.Arguments[key]);

            return newLine;
        }
Example #8
0
        /// <summary>
        /// get corresponding Action object from all Action Managers
        /// </summary>
        /// <param name="actLine">the action line</param>
        /// <returns>the found action</returns>
        private IAction getAction(ActionLine actLine)
        {
            int i = 0;
            IAction action = null;
            while (action == null && i < ActionManagers.Count)
                action = ActionManagers[i++].getAction(actLine);

            return action;
        }