예제 #1
0
        /// <summary>
        ///     Set value of a DataGridCell and then verify
        /// </summary>
        /// <param name="value">Value to set</param>
        /// <param name="shouldClick">Should click before setting text (yes/no)</param>
        /// <param name="shouldVerify">Indicate whether or not to verify</param>
        /// <param name="window">Window to perform text entry on</param>
        public void SetValue(string value, bool shouldClick = true, bool shouldVerify = true, Window window = null)
        {
            ReportActionValue("SetValue", value);

            if (window == null)
            {
                window = WorkSpace.MainWindow.Window;
            }

            if (shouldClick)
            {
                UIItem.Click();
            }

            window.Keyboard.Enter(value);
            window.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.RETURN);

            CaptureImage();

            if (shouldVerify)
            {
                var friendlyMessage = ConstructFriendlyMessage(Resources.FriendlyDataGridCellSetMsg, value);

                QAAssert.Contains(Value, value, friendlyMessage);
            }
        }
예제 #2
0
        /// <summary>
        ///     Compare values from two cells
        /// </summary>
        /// <param name="expectedTableData">Expected values</param>
        /// <param name="actualTableData">Actual values</param>
        /// <param name="rowNumber">Row number of cell</param>
        /// <param name="columnNumber">Column number of cell</param>
        private void CompareCellData(
            List <List <string> > expectedTableData,
            List <List <string> > actualTableData,
            int rowNumber,
            int columnNumber)
        {
            var actualValue   = actualTableData[rowNumber][columnNumber].Replace("[comma]", ",");
            var expectedValue = string.Empty;

            try
            {
                expectedValue = expectedTableData[rowNumber][columnNumber].Replace("[comma]", ",");
            }
            catch (ArgumentOutOfRangeException)
            {
                expectedValue = "<UNDEFINED>";
            }

            QAAssert.AreEqual(expectedValue, actualValue, continueOnFailure: true);
            if (!expectedValue.Equals(actualValue))
            {
                Report.Output(
                    Report.Level.Fail,
                    Resources.DataGridDifferentValueMsg,
                    rowNumber,
                    columnNumber,
                    expectedValue,
                    actualValue);

                hasFoundMismatch = true;
            }
        }
예제 #3
0
        /// <summary>
        ///     UnCheck ListItem and then verify
        /// </summary>
        /// <param name="shouldVerify">Indicate whether or not to verify</param>
        public void UnCheck(bool shouldVerify = true)
        {
            ReportAction("UnCheck");
            UIItem.UnCheck();
            CaptureImage();

            if (shouldVerify)
            {
                var friendlyMessage = ConstructFriendlyMessage(Resources.FriendlyListItemUnCheckMsg);
                QAAssert.AreEqual(false, UIItem.Checked, friendlyMessage);
            }
        }
예제 #4
0
        /// <summary>
        ///     Compare the row count of two tables.
        /// </summary>
        /// <param name="expectedRowCount">Expected table row count</param>
        /// <param name="actualRowCount">Actual table row count</param>
        private void CompareRowCount(int expectedRowCount, int actualRowCount)
        {
            var rowCountMessage = string.Format(
                Resources.FriendlyDataGridCompareRowCountMsg,
                FriendlyName);

            QAAssert.AreEqual(
                expectedRowCount,
                actualRowCount,
                rowCountMessage,
                true);
        }
예제 #5
0
        /// <summary>
        ///     Unselects a CheckBox
        /// </summary>
        /// <param name="shouldVerify">Indicate whether or not to verify</param>
        public void UnSelect(bool shouldVerify = true)
        {
            ReportAction("UnSelect");
            UIItem.UnSelect();
            CaptureImage();

            if (shouldVerify)
            {
                var friendlyMessage = ConstructFriendlyMessage(Resources.FriendlyCheckBoxUnSelectMsg);
                QAAssert.AreEqual(false, UIItem.IsSelected, friendlyMessage);
            }
        }
예제 #6
0
        /// <summary>
        ///     Select this row
        /// </summary>
        /// <param name="shouldVerify">Indicate whether or not to verify</param>
        public void Select(bool shouldVerify = true)
        {
            ReportAction("Select");
            UIItem.Select();
            CaptureImage();

            if (shouldVerify)
            {
                var friendlyMessage = ConstructFriendlyMessage(Resources.FriendlyTableRowSelectMsg);
                QAAssert.AreEqual(true, UIItem.IsFocussed, friendlyMessage);
            }
        }
예제 #7
0
        /// <summary>
        ///     Set the value of the textbox to a value but without the keyboard events
        ///     This will not represent exactly how a user will enter the value but the EnterText method does not support
        ///     Unicode characters
        /// </summary>
        /// <param name="text">Text to enter</param>
        /// <param name="shouldVerify">Indicate whether or not to verify</param>
        public void SetUnicodeText(string text, bool shouldVerify = true)
        {
            ReportActionValue("EnterText", text);
            UIItem.BulkText = text;
            Thread.Sleep(100);
            CaptureImage();

            if (shouldVerify)
            {
                var friendlyMessage = ConstructFriendlyMessage(Resources.FriendlyTextBoxSetMsg, text);
                QAAssert.AreEqual(text, UIItem.Text, friendlyMessage);
            }
        }
예제 #8
0
        /// <summary>
        ///     Enter text into a TextBox using keyboard and then verify.
        ///     Always try to use this method instead of SetValue() because this a closer
        ///     implementation to how a user would normally set the value of a TextBox.
        /// </summary>
        /// <param name="text">Text to enter</param>
        /// <param name="shouldVerify">Indicate whether or not to verify</param>
        public void EnterText(string text, bool shouldVerify = true)
        {
            ReportActionValue("EnterText", text);
            UIItem.Enter(text);
            WaitForTextInput(text.Length);
            CaptureImage();

            if (shouldVerify)
            {
                var friendlyMessage = ConstructFriendlyMessage(Resources.FriendlyTextBoxSetMsg, text);
                QAAssert.AreEqual(text, UIItem.Text, friendlyMessage);
            }
        }
예제 #9
0
        /// <summary>
        ///     Set value of a TextBox using automation and then verify.
        ///     Only call this method when EnterText() does not work.
        /// </summary>
        /// <param name="value">Value to set</param>
        /// <param name="shouldVerify">Indicate whether or not to verify</param>
        public void SetValue(string value, bool shouldVerify = true)
        {
            ReportActionValue("SetValue", value);
            UIItem.SetValue(value);
            Thread.Sleep(100);
            CaptureImage();

            if (shouldVerify)
            {
                var friendlyMessage = ConstructFriendlyMessage(Resources.FriendlyTextBoxSetMsg, value);
                QAAssert.AreEqual(value, UIItem.Text, friendlyMessage);
            }
        }
예제 #10
0
파일: QATab.cs 프로젝트: EXHALE97/GIT-VS
        public void SelectTabPage(string tabTitle, bool shouldVerify = true)
        {
            ReportAction("Select tab ");
            UIItem.SelectTabPage(tabTitle);
            CaptureImage();

            if (shouldVerify)
            {
                var friendlyMessage = ConstructFriendlyMessage(Resources.FriendlyTabSelectMsg, tabTitle);

                QAAssert.AreEqual(tabTitle, UIItem.SelectedTab.ToString(), friendlyMessage);
            }
        }
예제 #11
0
        /// <summary>
        ///     Compare values from two tables that are expressed as a list
        /// </summary>
        /// <param name="expectedTableData">Expected values</param>
        /// <param name="actualTableData">Actual values</param>
        private void CompareTableData(
            List <List <string> > expectedTableData,
            List <List <string> > actualTableData)
        {
            hasFoundMismatch = false;
            for (var i = 0; i < actualTableData.Count; i++)
            {
                CompareRowData(expectedTableData, actualTableData, i);
            }

            var friendlyMessage = string.Format(Resources.FriendlyDataGridComparePassMsg, FriendlyName);

            QAAssert.IsFalse(hasFoundMismatch, friendlyMessage, true);
        }
예제 #12
0
        /// <summary>
        ///     Select item contained inside ComboBox by clicking on it with the cursor
        /// </summary>
        /// <param name="itemText">Item text</param>
        /// <param name="shouldVerify">Indicate whether or not to verify</param>
        public void ClickItemWithText(string itemText, bool shouldVerify = false)
        {
            ReportActionValue("ClickItemWithName", itemText);

            var listItemFound = FindItemWithText(itemText);

            listItemFound.Click();

            if (shouldVerify)
            {
                var friendlyMessage = ConstructFriendlyMessage(Resources.FriendlyComboBoxSelectMsg, itemText);
                QAAssert.IsTrue(QAListItem.GetParent(listItemFound, string.Empty).IsSelected, friendlyMessage);
            }
        }
예제 #13
0
        /// <summary>
        ///     Select this row
        /// </summary>
        /// <param name="shouldVerify">Indicate whether or not to verify</param>
        public void Select(bool shouldVerify = true)
        {
            ReportAction("Select");
            UIItem.Select();
            if (!UIItem.IsSelected)
            {
                RightClick();
                Desktop.Instance.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.ESCAPE);
                Desktop.Instance.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.DOWN);
                Desktop.Instance.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.UP);
            }
            CaptureImage();

            if (shouldVerify)
            {
                var friendlyMessage = ConstructFriendlyMessage(Resources.FriendlyDataGridRowSelectMsg);
                QAAssert.AreEqual(true, UIItem.IsSelected, friendlyMessage);
            }
        }
예제 #14
0
        /// <summary>
        ///     Set value of a popup from a TableCell and then verify
        /// </summary>
        /// <param name="value">Value to click</param>
        /// <param name="shouldVerify">Indicate whether or not to verify</param>
        public void SetPopupValue(string value, bool shouldVerify = true)
        {
            ReportActionValue("SetPopupValue", value);
            UIItem.Click();
            UIItem.Click();

            var popup = QAWindow.GetModalWindow(SearchCriteria.ByAutomationId(string.Empty).AndByClassName("Popup"), WorkSpace.MainWindow.Window);

            var listItemPopup = QAListItem.Get(SearchCriteria.ByText(value), string.Empty, popup.Window);

            listItemPopup.Click();
            CaptureImage();

            if (shouldVerify)
            {
                var friendlyMessage = ConstructFriendlyMessage(Resources.FriendlyDataGridCellSetMsg, value);
                QAAssert.AreEqual(Value, value, friendlyMessage);
            }
        }
예제 #15
0
        /// <summary>
        ///     Select item contained inside ComboBox using Automation
        /// </summary>
        /// <param name="itemText">Item text</param>
        /// <param name="shouldVerify">Indicate whether or not to verify</param>
        /// <param name="useReturnForSelection">
        ///     UIItem.Click does not work in all situations,
        ///     for such cases pass the last parameter as true to make sure selection works for those cases
        /// </param>
        public void Select(string itemText, bool shouldVerify = true, bool useReturnForSelection = false)
        {
            ReportAction("Select");
            UIItem.Select(itemText);
            CaptureImage();

            if (shouldVerify)
            {
                var friendlyMessage = ConstructFriendlyMessage(Resources.FriendlyComboBoxSelectMsg, itemText);
                QAAssert.AreEqual(itemText, UIItem.SelectedItemText, friendlyMessage);
            }

            if (useReturnForSelection)
            {
                UIItem.KeyIn(KeyboardInput.SpecialKeys.RETURN);
            }
            else
            {
                UIItem.Click();
            }
        }
예제 #16
0
파일: QAItem.cs 프로젝트: EXHALE97/GIT-VS
        internal static AutomationElement GetByXPath(string xpath, AutomationElement scope = null, int timeout = 0)
        {
            var topNodesList = scope == null
                ? WorkSpace.XmlDoc.SelectNodes(xpath)
                : scope.XmlHierarhy().SelectNodes(xpath);

            QAAssert.IsNotNull(topNodesList);

            switch (topNodesList.Count)
            {
            case 0:
                return(null);

            case 1:
                return(FindAEwithTimeout(topNodesList[0], xpath, timeout));

            default:
                throw new NullReferenceException(
                          "There are multiple mathing nodes or node is missed. Check your xPath.");
            }
        }
예제 #17
0
        /// <summary>
        ///     Set value of a TableCell and then verify
        /// </summary>
        /// <param name="value">Value to set</param>
        /// <param name="shouldClick">Should click before setting text (yes/no)</param>
        /// <param name="shouldVerify">Indicate whether or not to verify</param>
        public void SetValue(string value, bool shouldClick = true, bool shouldVerify = true)
        {
            ReportActionValue("SetValue", value);
            if (shouldClick)
            {
                UIItem.Click();
            }

            WorkSpace.MainWindow.Keyboard.Enter(value);
            WorkSpace.MainWindow.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.RETURN);
            Thread.Sleep(100);
            CaptureImage();

            if (shouldVerify)
            {
                var friendlyMessage = ConstructFriendlyMessage(Resources.FriendlyDataGridCellSetMsg, value);

                // Decimal places are often affixed to the end of the text
                // so ensure expected text is a subset of actual text
                QAAssert.Contains(Value, value, friendlyMessage);
            }
        }
예제 #18
0
        public void GetElement()
        {
            var button = QAButton.Get(@"//button[contains(@Name,'FILE')]", "Button FILE");

            QAAssert.IsTrue(button.Exists);
        }