예제 #1
0
        public static void SendThreeKeys(System.Windows.Input.Key key1, System.Windows.Input.Key key2, System.Windows.Input.Key key3, string msg, int sleepTime)
        {
            Thread.Sleep(sleepTime);

            Library.ValidateArgumentNonNull(msg, "SendSingleKey() msg argument is null");

            if (msg.Length > 0)
            {
                msg = msg + " by ";
            }

            /* changing to new flexible logging */
            //Logger.LogComment(msg + "Sending keys " + key1.ToString() + ", " + key2.ToString() + " + " + key3.ToString());
            UIVerifyLogger.LogComment(msg + "Sending keys " + key1.ToString() + ", " + key2.ToString() + " + " + key3.ToString());

            ATGTestInput.Input.SendKeyboardInput(key1, true);
            Thread.Sleep(300);
            ATGTestInput.Input.SendKeyboardInput(key2, true);
            Thread.Sleep(300);
            ATGTestInput.Input.SendKeyboardInput(key3, true);
            Thread.Sleep(sleepTime);
            ATGTestInput.Input.SendKeyboardInput(key3, false);
            ATGTestInput.Input.SendKeyboardInput(key1, false);
            ATGTestInput.Input.SendKeyboardInput(key2, false);
            Thread.Sleep(sleepTime);
        }
예제 #2
0
        public static void TrimRangeCRLF(AutomationElement autoElement, TextPatternRange callingRange)
        {
            Library.ValidateArgumentNonNull(autoElement, "AutomationElement cannot be null");
            Library.ValidateArgumentNonNull(autoElement, "callingRange cannot be null");

            if (IsRichEdit(autoElement) == true)
            {
                int    actualOffset   = 0; // Actual   offset of \r, \n or \r\n
                int    expectedOffset = 0; // Expected offset of \r, \n or \r\n
                string text           = callingRange.GetText(-1);

                expectedOffset = GetTrailingCRLFOffset(text);

                // Now... move the endpoint
                actualOffset = callingRange.MoveEndpointByUnit(TextPatternRangeEndpoint.End, TextUnit.Character, expectedOffset);

                if (actualOffset != expectedOffset)
                {
                    throw new InvalidOperationException("Unable to move endpoint back by " + expectedOffset + " characters. Actual = " + actualOffset);
                }
                else
                {
                    /* changing to new flexible logging */
                    //Logger.LogComment("Adjusted size of range for RichEdit control by omitting last " + expectedOffset + " characters");
                    UIVerifyLogger.LogComment("Adjusted size of range for RichEdit control by omitting last " + expectedOffset + " characters");
                }
            }
        }
예제 #3
0
        public static void SendOneKey(System.Windows.Input.Key key, string msg, int sleepTime)
        {
            Thread.Sleep(sleepTime);

            Library.ValidateArgumentNonNull(msg, "msg argument cannot be null");

            if (msg.Length > 0)
            {
                msg = msg + " by ";
            }

            /* changing to new flexible logging */
            //Logger.LogComment(msg + "Sending key " + key.ToString());
            UIVerifyLogger.LogComment(msg + "Sending key " + key.ToString());

            ATGTestInput.Input.SendKeyboardInput(key, true);
            ATGTestInput.Input.SendKeyboardInput(key, false);
        }
예제 #4
0
        public const int TIMEWAIT = 100;                        // Used for starting process

        #endregion

        #region AutomationElementFromCustomId
        // -------------------------------------------------------------------
        // Finds an automation element from a given Automation ID
        // -------------------------------------------------------------------
        static public AutomationElement AutomationElementFromCustomId(AutomationElement element, object identifier, bool verbose)
        {
            Library.ValidateArgumentNonNull(element, "Automation Element");
            Library.ValidateArgumentNonNull(identifier, "Automation ID");

            if (verbose == true)
            {
                /* changing to new flexible logging */
                //Logger.LogComment("Looking for control (" + identifier + ")");
                UIVerifyLogger.LogComment("Looking for control (" + identifier + ")");
            }

            AutomationElement ae;

            ae = element.FindFirst(TreeScope.Children | TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, identifier));
            if (ae == null)
            {
                throw new ArgumentException("Could not identify the element based on the AutomationIdProperty");
            }

            return(ae);
        }