Ejemplo n.º 1
0
        /// <summary>
        /// Writes the log file(s). Its intended to be used on the text cleanup.
        /// </summary>
        /// <param name="testContext">The TextContext of the test class.</param>
        /// <remarks>You get the test context created by adding a public property into the class with the cleanup.
        /// For configuring see <see cref="DW.CodedUI.CodedUIEnvironment.LoggerSettings" />.</remarks>
        /// <example>
        /// <code lang="csharp">
        /// <![CDATA[
        /// [CodedUITest]
        /// public class SomethingTests
        /// {
        ///     public TestContext TestContext { get; set; }
        ///
        ///     [TestInitialize]
        ///     public void Setup()
        ///     {
        ///         CodedUIEnvironment.LoggerSettings.LogFilesDirectory = @"D:\CodedUI_Logs";
        ///     }
        ///
        ///     [TestCleanup]
        ///     public void Cleanup()
        ///     {
        ///         LogWriter.Write(TestContext);
        ///     }
        ///
        ///     [TestMethod]
        ///     public void Any_Test_Using_The_DW_CodedUI()
        ///     {
        ///         // Something
        ///     }
        /// }]]>
        /// </code>
        /// </example>
        public static void Write(TestContext testContext)
        {
            if (!CodedUIEnvironment.LoggerSettings.IsEnabled)
            {
                return;
            }

            LogPool.StartDateTimeWritten = false; // On next LogPool.Append the StartDateTime will be set again

            if (CodedUIEnvironment.LoggerSettings.InstantLoggingContext != null)
            {
                ProcessInstantWrittenLog(testContext);
                return;
            }

            if (testContext.CurrentTestOutcome != UnitTestOutcome.Passed || CodedUIEnvironment.LoggerSettings.LogPassedTestsToo)
            {
                var filePath = GetLogFileName(testContext);
                if (filePath == null)
                {
                    return;
                }

                var logs = new StringBuilder();
                AppendHeader(testContext, logs);

                var logLines = LogPool.PopList();
                foreach (var line in logLines)
                {
                    logs.AppendLine(line);
                }

                File.AppendAllText(filePath, logs.ToString());
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets the new size of the window.
        /// </summary>
        /// <param name="width">The new width of the window.</param>
        /// <param name="height">The new height of the window.</param>
        /// <returns>A WindowSetup to be able to append additional actions.</returns>
        public WindowSetup Size(int width, int height)
        {
            LogPool.Append("Set window size to  width {0} and height {1}.", width, height);

            _window.Unsafe.SetSize(new Size(width, height));
            return(this);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Sets the new position of the window.
        /// </summary>
        /// <param name="left">The new position from the left.</param>
        /// <param name="top">The new position from the top.</param>
        /// <returns>A WindowSetup to be able to append additional actions.</returns>
        public WindowSetup Position(int left, int top)
        {
            LogPool.Append("Set window position to left {0} and top {1}.", left, top);

            _window.Unsafe.SetPosition(new Point(left, top));
            return(this);
        }
Ejemplo n.º 4
0
        protected override void OnLoadFinish()
        {
            pool        = new LogPool();
            logList     = new List <LogMetaInfo>();
            logTemplate = panel.transform.Find("ScrollView/Viewport/Content/ItemTemplate").gameObject;

            scrollRect = panel.transform.Find("ScrollView").GetComponent <ScrollRect>();


            logTemplate.SetActive(false);

            btnClear = panel.transform.Find("BtnClear").gameObject;

            btnClear.GetComponent <Button>().onClick.AddListener(() =>
            {
                ClearAllLogs();
            });

            btnCopy = panel.transform.Find("BtnCopy").GetComponent <Button>();
            btnCopy.onClick.AddListener(() =>
            {
                StringBuilder builder = new StringBuilder();
                foreach (var info in logList)
                {
                    builder.AppendLine(info.info);
                }

                EditorInterface.CopyToClipboard(builder.ToString());
            });

            this.cache.AddTemplate(TEMPLATE_ITEM_STR, logTemplate);


            Application.logMessageReceived += OnLog;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Sets the new state of the window.
        /// </summary>
        /// <param name="windowState">The new state of the window.</param>
        /// <returns>A WindowSetup to be able to append additional actions.</returns>
        public WindowSetup State(WindowState windowState)
        {
            LogPool.Append("Set window state to '{0}'.", windowState);

            _window.Unsafe.SetState(windowState);
            return(this);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Returns a tree of information objects which shows the whole tree below the given object.
        /// </summary>
        /// <param name="element">The parent object from which all child elements have to be read.</param>
        /// <returns>The given element as an information object wich all its children in a tree.</returns>
        public static AutomationElementInfo GetFullUITree(AutomationElement element)
        {
            var rootElementInfo = new AutomationElementInfo(element);

            LogPool.Append("Read full UI tree down from '{0}'.", rootElementInfo);
            Read(rootElementInfo);
            return(rootElementInfo);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Searches for a window by the given conditions and settings. If not disabled And.Assert().And.Timeout(10000) gets appended.
        /// </summary>
        /// <param name="use">Defines the conditions to be used for searching for a window.</param>
        /// <param name="is">Defines the relation of the window to another object.</param>
        /// <param name="settings">Defines the settings to be used while searching.</param>
        /// <exception cref="DW.CodedUI.WindowNotFoundException">The window could not be found. (If not disabled.)</exception>
        /// <exception cref="DW.CodedUI.WrongSetupException">Dll is missing or in the wrong version.</exception>
        /// <returns>The found window if any; otherwise an exception as long its not disabled by And.NoAssert(). If its disabled the return is null.</returns>
        public static BasicWindow Search(Use use, Is @is, And settings)
        {
            var condition          = use.GetCondition();
            var settingsConditions = settings.GetConditions();
            var instanceNumber     = settings.GetInstanceNumber();
            var timeout            = settings.GetTimeout();
            var useTimeout         = settingsConditions.Contains(AndCondition.Timeout);
            var assertResult       = settingsConditions.Contains(AndCondition.Assert);
            var checkInstance      = settingsConditions.Contains(AndCondition.Instance);
            var useInterval        = settingsConditions.Contains(AndCondition.Interval);
            var interval           = settings.GetInterval();

            if (CodedUIEnvironment.LoggerSettings.ShortLogging)
            {
                LogPool.Append("Search for a window. {0}", use.GetConditionDescription());
            }
            else
            {
                LogPool.Append("Search for a window. {0}", MessageBuilder.BuildMessage(use, useTimeout, useInterval, interval, timeout, @is));
            }

            var watch = new Stopwatch();

            watch.Start();
            while (true)
            {
                var foundInstance = 0;
                var windows       = GetAllWindows();
                foreach (var window in windows)
                {
                    var matchingWindow = Matches(window, condition, @is);
                    if (matchingWindow == null)
                    {
                        continue;
                    }

                    if (!checkInstance || ++foundInstance == instanceNumber)
                    {
                        LogPool.Append("Window '{0}' found.", matchingWindow);
                        return(matchingWindow);
                    }
                }

                if (!useTimeout || watch.Elapsed.TotalMilliseconds >= timeout)
                {
                    if (assertResult)
                    {
                        throw new WindowNotFoundException(use, useTimeout, useInterval, interval, watch.Elapsed, @is);
                    }
                    return(null);
                }

                if (useInterval)
                {
                    Thread.Sleep((int)interval);
                }
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Releases the modifier key which got pressed before.
 /// </summary>
 /// <param name="modifierKeys">The modifier keys to release.</param>
 /// <returns>A combinable Do to be able to append additional actions.</returns>
 public static CombinableDo ReleaseKey(ModifierKeys modifierKeys)
 {
     return(WrapIt(() =>
     {
         LogPool.Append("Release keys '{0}'.", modifierKeys);
         WinApi.KeyboardEvent((byte)modifierKeys, WinApi.KeyboardEventFlags.KEYEVENTF_EXTENDEDKEY | WinApi.KeyboardEventFlags.KEYEVENTF_KEYUP);
     },
                   string.Format("Cannot release the modifier key '{0}'", modifierKeys)));
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Executes a mouse click with specific mouse buttons.
 /// </summary>
 /// <param name="buttons">The mouse buttons which will be clicked.</param>
 /// <returns>A combinable Do to be able to append additional actions.</returns>
 public static CombinableDo Click(MouseButtons buttons)
 {
     return(WrapIt(() =>
     {
         LogPool.Append("Click with the buttons '{0}'.", buttons);
         WinApi.MouseEvent((int)buttons);
     },
                   string.Format("Cannot click the mouse buttons '{0}'", buttons)));
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Presses and holds the given modifier keys down. Use <see cref="ReleaseKey(ModifierKeys)" /> to release the key back again.
 /// </summary>
 /// <param name="modifierKeys">The modifier keys to press and hold.</param>
 /// <returns>A combinable Do to be able to append additional actions.</returns>
 public static CombinableDo PressKey(ModifierKeys modifierKeys)
 {
     return(WrapIt(() =>
     {
         LogPool.Append("Press key '{0}'.", modifierKeys);
         WinApi.KeyboardEvent((byte)modifierKeys, WinApi.KeyboardEventFlags.KEYEVENTF_EXTENDEDKEY);
     },
                   string.Format("Cannot press down the modifier key '{0}'.", modifierKeys)));
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Presses and holds the given key down. Use <see cref="ReleaseKey(Key)" /> to release the key back again.
 /// </summary>
 /// <param name="key">The key to press and hold.</param>
 /// <returns>A combinable Do to be able to append additional actions.</returns>
 public static CombinableDo PressKey(Key key)
 {
     return(WrapIt(() =>
     {
         LogPool.Append("Press key '{0}'.", key);
         WinApi.KeyboardEvent((byte)key, WinApi.KeyboardEventFlags.KEYEVENTF_EXTENDEDKEY);
     },
                   string.Format("Cannot press down the key '{0}'.", key)));
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Types the given text.
 /// </summary>
 /// <param name="text">The text to type.</param>
 /// <returns>A combinable Do to be able to append additional actions.</returns>
 public static CombinableDo TypeText(string text)
 {
     return(WrapIt(() =>
     {
         LogPool.Append("Type text '{0}'.", text);
         SendText(text);
     },
                   string.Format("Cannot send the text '{0}'", text)));
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Types the given modifier keys.
 /// </summary>
 /// <param name="modifierKeys">The modifier keys to type.</param>
 /// <returns>A combinable Do to be able to append additional actions.</returns>
 public static CombinableDo TypeKey(ModifierKeys modifierKeys)
 {
     return(WrapIt(() =>
     {
         LogPool.Append("Type modifier keys '{0}'.", modifierKeys);
         Type((byte)modifierKeys);
     },
                   string.Format("Cannot type the modifier keys '{0}'", modifierKeys)));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Types the given key.
 /// </summary>
 /// <param name="key">The key to type.</param>
 /// <returns>A combinable Do to be able to append additional actions.</returns>
 public static CombinableDo TypeKey(Key key)
 {
     return(WrapIt(() =>
     {
         LogPool.Append("Type key '{0}'.", key);
         Type((byte)key);
     },
                   string.Format("Cannot type the key '{0}'", key)));
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Releases the key which got pressed before.
 /// </summary>
 /// <param name="key">The key to release.</param>
 /// <returns>A combinable Do to be able to append additional actions.</returns>
 public static CombinableDo ReleaseKey(Key key)
 {
     return(WrapIt(() =>
     {
         LogPool.Append("Release key '{0}'.", key);
         WinApi.KeyboardEvent((byte)key, WinApi.KeyboardEventFlags.KEYEVENTF_EXTENDEDKEY | WinApi.KeyboardEventFlags.KEYEVENTF_KEYUP);
     },
                   string.Format("Cannot release the key '{0}'", key)));
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Executes a mouse double click with specific mouse buttons and hold modifier keys in the center of the given basic element.
 /// </summary>
 /// <param name="element">The basic element to be double clicked.</param>
 /// <param name="buttons">The mouse buttons which will be double clicked.</param>
 /// <param name="modifierKeys">The modifier keys to be hold while the double click is executed.</param>
 /// <returns>A combinable Do to be able to append additional actions.</returns>
 public static CombinableDo DoubleClick(BasicElement element, MouseButtons buttons, ModifierKeys modifierKeys)
 {
     return(WrapIt(() =>
     {
         LogPool.Append("Click with the mouse buttons '{0}' in the center of the '{1}' with the modifier keys '{2}' pressed.", buttons, element, modifierKeys);
         DoubleClickCentered(element, buttons, modifierKeys);
     },
                   string.Format("Cannot click with the mouse buttons '{0}' in the center of the '{1}' with the modifier keys '{2}' pressed.", buttons, element, modifierKeys)));
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Executes a mouse double click with specific mouse buttons and hold modifier keys in the relative position of the given basic element.
 /// </summary>
 /// <param name="element">The basic element to be clicked.</param>
 /// <param name="buttons">The mouse buttons which will be double clicked.</param>
 /// <param name="modifierKeys">The modifier keys to be hold while the double click is executed.</param>
 /// <param name="relativePosition">The relative position in the control where to double click.</param>
 /// <returns>A combinable Do to be able to append additional actions.</returns>
 public static CombinableDo DoubleClick(BasicElement element, MouseButtons buttons, ModifierKeys modifierKeys, At relativePosition)
 {
     return(WrapIt(() =>
     {
         LogPool.Append("Doubleclick with the mouse buttons '{0}' in relative position '{1}' of the '{2}' with the modifier keys '{3}' pressed.", buttons, relativePosition, element, modifierKeys);
         DoubleClickRelative(element, buttons, modifierKeys, relativePosition);
     },
                   string.Format("Cannot doubleclick with the mouse buttons '{0}' in relative position '{1}' of the '{2}' with the modifier keys '{3}' pressed.", buttons, relativePosition, element, modifierKeys)));
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Executes a mouse left click.
 /// </summary>
 /// <returns>A combinable Do to be able to append additional actions.</returns>
 public static CombinableDo Click()
 {
     return(WrapIt(() =>
     {
         LogPool.Append("Click with left mouse button.");
         WinApi.MouseEvent((int)MouseButtons.Left);
     },
                   "Cannot click with the left mouse button."));
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Executes a mouse double click with specific mouse buttons on a relative position in the given basic element.
 /// </summary>
 /// <param name="element">The basic element to be double clicked.</param>
 /// <param name="buttons">The mouse buttons which will be double clicked.</param>
 /// <param name="relativePosition">The relative position in the control where to double click.</param>
 /// <returns>A combinable Do to be able to append additional actions.</returns>
 public static CombinableDo DoubleClick(BasicElement element, MouseButtons buttons, At relativePosition)
 {
     return(WrapIt(() =>
     {
         LogPool.Append("Doubleclick with the mouse buttons '{0}' at the relative position '{1}' on the element '{2}'", buttons, relativePosition, element);
         DoubleClickRelative(element, buttons, relativePosition);
     },
                   string.Format("Cannot doubleclick with the mouse buttons '{0}' at the relative position '{1}' on the element '{2}'", buttons, relativePosition, element)));
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Executes a mouse double click with specific mouse buttons in the center of the given basic element.
 /// </summary>
 /// <param name="element">The basic element to be double clicked.</param>
 /// <param name="buttons">The mouse buttons which will be double clicked.</param>
 /// <returns>A combinable Do to be able to append additional actions.</returns>
 public static CombinableDo DoubleClick(BasicElement element, MouseButtons buttons)
 {
     return(WrapIt(() =>
     {
         LogPool.Append("Doubleclick the BasicElement '{0}' centered with the mouse buttons '{1}'.", element, buttons);
         DoubleClickCentered(element, buttons);
     },
                   string.Format("Cannot doubleclick the BasicElement '{0}' centered with the mouse buttons '{1}'.", element, buttons)));
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Executes a mouse left double click at a relative position of the given basic element with holding modifier keys.
 /// </summary>
 /// <param name="element">The basic element to be double clicked.</param>
 /// <param name="modifierKeys">The modifier keys to be hold while the double click is executed.</param>
 /// <param name="relativePosition">The relative position in the control where to double click.</param>
 /// <returns>A combinable Do to be able to append additional actions.</returns>
 public static CombinableDo DoubleClick(BasicElement element, ModifierKeys modifierKeys, At relativePosition)
 {
     return(WrapIt(() =>
     {
         LogPool.Append("Doubleclick with the left mouse button at the relative position '{0}' on the element '{1}' with the modifier keys {2} pressed.", relativePosition, element, modifierKeys);
         DoubleClickRelative(element, MouseButtons.Left, modifierKeys, relativePosition);
     },
                   string.Format("Cannot doubleclick with the left mouse button at the relative position '{0}' on the element '{1}' with the modifier keys {2} pressed.", relativePosition, element, modifierKeys)));
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Executes a mouse left double click in the center of the given basic element.
 /// </summary>
 /// <param name="element">The basic element to be double clicked.</param>
 /// <returns>A combinable Do to be able to append additional actions.</returns>
 public static CombinableDo DoubleClick(BasicElement element)
 {
     return(WrapIt(() =>
     {
         LogPool.Append("Doubleclick with the left mouse button in the center of the '{0}'.", element);
         DoubleClickCentered(element, MouseButtons.Left);
     },
                   string.Format("Cannot doubleclick the BasicElement '{0}' centered with the left mouse button.", element)));
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Executes a mouse left click on a relative position inside the given basic element.
 /// </summary>
 /// <param name="element">The basic element to be clicked.</param>
 /// <param name="relativePosition">The relative position in the control where to click.</param>
 /// <returns>A combinable Do to be able to append additional actions</returns>
 public static CombinableDo Click(BasicElement element, At relativePosition)
 {
     return(WrapIt(() =>
     {
         LogPool.Append("Click with the left mouse button at the relative position '{0}' on the element '{1}'", relativePosition, element);
         ClickRelative(element, MouseButtons.Left, relativePosition);
     },
                   string.Format("Cannot click with the left mouse button at the relative position '{0}' on the element '{1}'", relativePosition, element)));
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Places the mouse cursor on the specific position.
 /// </summary>
 /// <param name="to">The position where the mouse cursor should be placed.</param>
 /// <returns>A combinable Do to be able to append additional actions.</returns>
 public static CombinableDo Move(Position to)
 {
     return(WrapIt(() =>
     {
         var position = to.GetPosition();
         LogPool.Append("Place the mouse cursor on position '{0}'.", position);
         Cursor.Position = position.ToDrawingPoint();
     },
                   string.Format("Cannot place the mouse cursor on position '{0}'.", to.GetPosition())));
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Executes a mouse left click at a specific position within the screen.
 /// </summary>
 /// <param name="screenCoordinate">The point on the whole screen where to click.</param>
 /// <returns>A combinable Do to be able to append additional actions.</returns>
 public static CombinableDo Click(Point screenCoordinate)
 {
     return(WrapIt(() =>
     {
         LogPool.Append("Click with the left mouse button on the screen coordinate '{0}'.", screenCoordinate);
         Cursor.Position = screenCoordinate.ToDrawingPoint();
         WinApi.MouseEvent((int)MouseButtons.Left);
     },
                   string.Format("Click with the left mouse button on the screen coordinate '{0}'.", screenCoordinate)));
 }
Ejemplo n.º 26
0
        private static TControl StartSearchChild <TControl>(By by, From from, With with) where TControl : BasicElement
        {
            var condition     = by.GetCondition();
            var rawCondition  = by.GetRawCondition();
            var sourceElement = from.GetSourceElement();

            var settings       = with.GetConditions();
            var useTimeout     = settings.Contains(WithCondition.Timeout);
            var timeout        = with.GetTimeout();
            var assertResult   = settings.Contains(WithCondition.Assert);
            var useInterval    = settings.Contains(WithCondition.Interval);
            var interval       = with.GetInterval();
            var needsToBeReady = settings.Contains(WithCondition.ReadyToUse);

            if (CodedUIEnvironment.LoggerSettings.ShortLogging)
            {
                LogPool.Append("Search for UI element. {0}", by.GetConditionDescription());
            }
            else
            {
                LogPool.Append("Search for UI element down from '{0}'. {1}", sourceElement, MessageBuilder.BuildMessage(by, useTimeout, useInterval, timeout, interval));
            }

            var watch = new Stopwatch();

            watch.Start();
            while (true)
            {
                var foundItem = StartSearchChild <TControl>(sourceElement, condition, rawCondition);
                if (foundItem != null)
                {
                    if (!needsToBeReady)
                    {
                        LogPool.Append("UI element '{0}' found.", foundItem);
                        return(foundItem);
                    }

                    return(ReturnIfReady(assertResult, by, useTimeout, useInterval, timeout, watch, interval, false, foundItem));
                }

                if (!useTimeout || watch.Elapsed.TotalMilliseconds >= timeout)
                {
                    if (assertResult)
                    {
                        throw new UIElementNotFoundException(by, useTimeout, useInterval, interval, watch.Elapsed, false);
                    }
                    return(null);
                }

                if (useInterval)
                {
                    Thread.Sleep((int)interval);
                }
            }
        }
Ejemplo n.º 27
0
 /// <summary>
 /// Executes a mouse left click while holding specific modifier keys.
 /// </summary>
 /// <param name="modifierKeys">The modifier keys to be hold while the click is executed.</param>
 /// <returns>A combinable Do to be able to append additional actions.</returns>
 public static CombinableDo Click(ModifierKeys modifierKeys)
 {
     return(WrapIt(() =>
     {
         LogPool.Append("Click with the left mouse button and with the modifier keys '{0}' pressed.", modifierKeys);
         KeyboardEx.PressKey(modifierKeys);
         WinApi.MouseEvent((int)MouseButtons.Left);
         KeyboardEx.ReleaseKey(modifierKeys);
     },
                   string.Format("Cannot click the left mouse button with the modifier keys '{0}' pressed.", modifierKeys)));
 }
Ejemplo n.º 28
0
        /// <summary>
        /// Gives the BasicElement the focus and types the given modifier keys.
        /// </summary>
        /// <param name="control">The BasicElement who should get the focus before typing the key.</param>
        /// <param name="modifierKeys">The modifier keys to type.</param>
        /// <returns>A combinable Do to be able to append additional actions.</returns>
        public static CombinableDo TypeKey(BasicElement control, ModifierKeys modifierKeys)
        {
            return(WrapIt(() =>
            {
                LogPool.Append("Set control focus for keyboard inputs on '{0}'.", control);
                control.AutomationElement.SetFocus();

                LogPool.Append("Type modifier keys '{0}'.", modifierKeys);
                Type((byte)modifierKeys);
            },
                          string.Format("Cannot press down the modifier keys '{0}' with the '{1}' focused.", modifierKeys, control)));
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Gives the BasicElement the focus and types the given text with a small delay time between each character.
        /// </summary>
        /// <param name="control">The BasicElement who should get the focus before typing the text.</param>
        /// <param name="text">The text to type.</param>
        /// <param name="delay">The time to wait after each character in milliseconds.</param>
        /// <returns>A combinable Do to be able to append additional actions.</returns>
        public static CombinableDo TypeText(BasicElement control, string text, int delay)
        {
            return(WrapIt(() =>
            {
                LogPool.Append("Set control focus for keyboard inputs on '{0}'.", control);
                control.AutomationElement.SetFocus();

                LogPool.Append("Type text '{0}' with a delay of {1} milliseconds.", text, delay);
                SendText(text, delay);
            },
                          string.Format("Cannot send the text '{0}' with the '{1} focused.'", text, control)));
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Gives the BasicElement the focus and presses and holds the given key down. Use <see cref="ReleaseKey(Key)" /> to release the key back again.
        /// </summary>
        /// <param name="control">The BasicElement who should get the focus before pressing the key.</param>
        /// <param name="key">The key to press and hold.</param>
        /// <returns>A combinable Do to be able to append additional actions.</returns>
        public static CombinableDo PressKey(BasicElement control, Key key)
        {
            return(WrapIt(() =>
            {
                LogPool.Append("Set control focus for keyboard inputs on '{0}'.", control);
                control.AutomationElement.SetFocus();

                LogPool.Append("Press key '{0}'.", key);
                WinApi.KeyboardEvent((byte)key, WinApi.KeyboardEventFlags.KEYEVENTF_EXTENDEDKEY);
            },
                          string.Format("Cannot press down the key '{0}' with the '{1}' focused.", key, control)));
        }
Ejemplo n.º 31
0
 static LogManager()
 {
     LogPool = new LogPoolBuilder().Build();
 }