コード例 #1
0
        /// <summary>
        /// Waits for an element to be enabled
        /// </summary>
        /// <param name="elementInfo">Repository Item Info of the element to check</param>
        /// <param name="timeout">How long I want to wait for the element to be enabled</param>
        /// <returns>true if the element is enabled</returns>
        public static bool WaitForElementEnabled(RepoItemInfo elementInfo, Duration timeout)
        {
            bool enabled     = false;
            int  checkPeriod = 500; // ms

            // if timeout is longer than a second then check periodically every checkPeriod ms
            if (timeout > 1000)
            {
                int countMax = timeout.Milliseconds / checkPeriod;
                int count    = 0;

                while (count < countMax && !enabled)
                {
                    enabled = CheckItem.checkEnabled(elementInfo, 0);
                    Thread.Sleep(checkPeriod);
                    count++;
                }
            }
            else
            {
                Thread.Sleep(timeout.Milliseconds);
                enabled = CheckItem.checkEnabled(elementInfo, 0);
            }
            return(enabled);
        }
コード例 #2
0
        /// <summary>
        /// Waits for an element to be hidden
        /// </summary>
        /// <param name="elementInfo">Repository Item Info of the element to check</param>
        /// <param name="timeout">How long I want to wait for the element to be hidden</param>
        /// <returns>true if the element is not visible</returns>
        public static bool WaitForElementHidden(RepoItemInfo elementInfo, Duration timeout)
        {
            bool visible     = true;
            int  checkPeriod = 500; // ms

            // if timeout is longer than a second then check periodically every checkPeriod ms
            if (timeout > 1000)
            {
                int countMax = timeout.Milliseconds / checkPeriod;
                int count    = 0;

                while (count < countMax && visible)
                {
                    visible = CheckItem.checkVisible(elementInfo, 0);
                    Thread.Sleep(checkPeriod);
                    count++;
                }
            }
            else
            {
                Thread.Sleep(timeout.Milliseconds);
                visible = CheckItem.checkVisible(elementInfo, 0);
            }
            return(!visible);
        }