예제 #1
0
        public override bool Play(MappedItem control, Log log)
        {
            double seconds;

            if (!double.TryParse(delayParameter.GetValue(), out seconds))
            {
                log.CreateLogItem(LogItemCategory.Error, "Not a valid value for seconds", null);
                return false;
            }

            Thread.Sleep(TimeSpan.FromSeconds(seconds));
            log.CreateLogItem(LogItemCategory.Event, string.Format("Delayed {0} second(s)", seconds));

            return true;
        }
예제 #2
0
        public override bool Play(MappedItem control, Log log)
        {
            Variable variable = this.TestItem.Test.Variables.FirstOrDefault(v => v.Name.Equals(variableParam.Value));
            variable.Value = valueParam.GetValue();

            log.CreateLogItem(LogItemCategory.Message, string.Format("Variable '{0}' was set to value: {1}", variable.Name, variable.Value));

            return true;
        }
예제 #3
0
        public override bool Play(MappedItem control, Log log)
        {
            log.CreateLogItem(LogItemCategory.Event, nameParameter.GetValue());
            log.StartLogItemChildren();

            foreach (TestItem testItem in TestItem.TestItems)
            {
                if (!testItem.Play(log))
                    return false;
            }

            log.EndLogItemChildren();
            return true;
        }
예제 #4
0
        public override bool Play(MappedItem control, Log log)
        {
            string testName = testNameParam.GetValue();
            string filePath =
                this.TestItem.Test.Project.TestFiles.First(
                    t => t.Name.Substring(0, t.Name.Length - DefaultData.TestExtension.Length).Equals(testName)).FilePath;

            Test test = testFileManager.Open(filePath);
            test.Project = TestItem.Test.Project;

            log.CreateLogItem(LogItemCategory.Event, string.Format("Running test: {0}", testName));
            log.StartLogItemChildren();
            test.Play(log);
            log.EndLogItemChildren();
            return true;
        }
예제 #5
0
        public override bool Play(MappedItem mappedItem, Log log)
        {
            AppProcess process = AppManager.GetProcess(mappedItem);
            MappedItem window = AppManager.GetWindow(mappedItem);

            IUIItem uiItem = AppPlaybackService.GetControl(process, window, mappedItem, AppManager);
            AutomationElement findWindowElement = ExternalAppInfoManager.GetWindowAutomationElement(uiItem);

            Point clickPoint = this.GetClickPoint(CreateScreenshot(log, findWindowElement.Current.NativeWindowHandle, false));
            Point globalPoint = new Point((int)uiItem.Bounds.X + clickPoint.X, (int)uiItem.Bounds.Y + clickPoint.Y);

            Cursor.Position = globalPoint;

            Screenshot screenshot = CreateScreenshot(log, findWindowElement.Current.NativeWindowHandle);
            screenshot.Adornments.Add(
                new ControlHighlightAdornment
                {
                    X = (int)uiItem.Bounds.X - (int)findWindowElement.Current.BoundingRectangle.X,
                    Y = (int)uiItem.Bounds.Y - (int)findWindowElement.Current.BoundingRectangle.Y,
                    Width = (int)uiItem.Bounds.Width,
                    Height = (int)uiItem.Bounds.Height
                });

            Cursor.LeftClick(globalPoint);

            string description = string.Format("The {0} was clicked with the left mouse button", mappedItem.Type);

            log.CreateLogItem(LogItemCategory.Event, description, screenshot);

            int screenshotX = globalPoint.X - (int)findWindowElement.Current.BoundingRectangle.X;
            int screenshotY = globalPoint.Y - (int)findWindowElement.Current.BoundingRectangle.Y;

            screenshot.Adornments.Add(new ClickAdornment { ClickX = screenshotX, ClickY = screenshotY });

            return true;
        }
        public override bool Play(MappedItem control, Log log)
        {
            Variable variable = this.TestItem.Test.Variables.FirstOrDefault(v => v.Name.Equals(variableParam.Value));

            string filePath = filePathParam.GetValue();

            string[] fileLines = File.ReadAllLines(filePath);

            DataTable dataTable = variable.DataTableValue;

            //string[] columnNames = variable.DataTableValue.Columns.OfType<DataColumn>().Select(c => c.ColumnName).ToArray();

            dataTable.Clear();

            foreach (string row in fileLines)
            {
                string[] fields = row.Split(',');
                dataTable.Rows.Add(fields);
            }

            log.CreateLogItem(LogItemCategory.Message, string.Format("Variable '{0}' was set from file : {1}", variable.Name, filePath));

            return true;
        }
예제 #7
0
        public override bool Play(MappedItem control, Log log)
        {
            log.CreateLogItem(LogItemCategory.Message, string.Format("Message: {0}", messageParameter.GetValue()));

            return true;
        }
예제 #8
0
        public override bool Play(MappedItem mappedItem, Log log)
        {
            string text = textParam.GetValue();
            Keyboard.SendKeys(text);

            AppProcess process = AppManager.GetProcess(mappedItem);
            MappedItem window = AppManager.GetWindow(mappedItem);

            IUIItem uiItem = AppPlaybackService.GetControl(process, window, mappedItem, AppManager);

            AutomationElement findWindowElement = uiItem.AutomationElement;

            while (findWindowElement.Current.LocalizedControlType != "window"
                && !(findWindowElement.Current.LocalizedControlType == "pane"
                 && TreeWalker.ControlViewWalker.GetParent(findWindowElement).Current.LocalizedControlType == "process"))
            {
                findWindowElement = TreeWalker.ControlViewWalker.GetParent(findWindowElement);
            }

            Screenshot screenshot = CreateScreenshot(log, findWindowElement.Current.NativeWindowHandle);

            screenshot.Adornments.Add(
                new ControlHighlightAdornment
                {
                    X = (int)uiItem.Bounds.X - (int)findWindowElement.Current.BoundingRectangle.X,
                    Y = (int)uiItem.Bounds.Y - (int)findWindowElement.Current.BoundingRectangle.Y,
                    Width = (int)uiItem.Bounds.Width,
                    Height = (int)uiItem.Bounds.Height
                });

            string description = string.Format("The text '{0}' was entered in {1}", text, mappedItem.Name);
            log.CreateLogItem(LogItemCategory.Event, description, screenshot);

            return true;
        }
예제 #9
0
 public virtual bool Play(Log log)
 {
     try
     {
         bool result;
         result = Operation.Play(Control, log);
         return result;
     }
     catch (Exception ex)
     {
         log.CreateLogItem(LogItemCategory.Error, string.Format("An error occurred when executing the {0} Operation.", Operation.Name), null);
         return false;
     }
 }
        public override bool Play(MappedItem control, Log log)
        {
            Variable variable = this.TestItem.Test.Variables.FirstOrDefault(v => v.Name.Equals(variableParam.Value));

            AppProcess process = AppManager.GetProcess(control);
            MappedItem window = AppManager.GetWindow(control);

            IUIItem uiItem = AppPlaybackService.GetControl(process, window, control, AppManager);
            Point clickPoint = new Point(X, Y);
            Point globalPoint = new Point((int)uiItem.Bounds.X + clickPoint.X, (int)uiItem.Bounds.Y + clickPoint.Y);

            Screenshot screenshot = CreateScreenshot(log);

            Cursor.LeftClick(globalPoint);
            string actualText = CopyText();

            variable.Value = actualText;

            log.CreateLogItem(LogItemCategory.Message, string.Format("Variable '{0}' was set to value: {1}", variable.Name, variable.Value));

            return true;
        }
        public override bool Play(MappedItem control, Log log)
        {
            AppProcess process = AppManager.GetProcess(control);
            MappedItem window = AppManager.GetWindow(control);

            IUIItem uiItem = AppPlaybackService.GetControl(process, window, control, AppManager);
            Point clickPoint = new Point(X,Y);
            Point globalPoint = new Point((int)uiItem.Bounds.X + clickPoint.X, (int)uiItem.Bounds.Y + clickPoint.Y);

            Screenshot screenshot = CreateScreenshot(log);

            Cursor.LeftClick(globalPoint);
            string actualText = CopyText();
            string expectedText = textParam.GetValue();

            if (actualText == null)
                actualText = "";

            if (expectedText == null)
                expectedText = "";

            string originalExpectedText = expectedText;

            foreach (Variable v in this.TestItem.Test.Variables.OrderBy(v => v.Name.Length))
            {
                expectedText = expectedText.Replace(v.Name, v.Value.ToString());
            }

            Expression e = new Expression(expectedText);

            try
            {
                expectedText = e.Evaluate().ToString();
            }
            catch (Exception ex)
            {
                //e.Evaluate() errored out.  Probably not an expression

                expectedText = originalExpectedText;
            }

            if(!Equals(actualText, expectedText))
            {
                string error = "Expected \"{0}\" but value was \"{1}\"";
                error = string.Format(error, expectedText, actualText);

                log.CreateLogItem(LogItemCategory.Error, error, screenshot);
                return false;
            }

            string description = "Validated that the text at ({0},{1}) on {2} is equal to \"{3}\"";
            description = string.Format(description, X, Y, control.Name, Text);

            log.CreateLogItem(LogItemCategory.Validation, description, screenshot);

            return true;
        }