diff --git a/docs/Windows/WindowsControlWrappers.md b/docs/Windows/WindowsControlWrappers.md index 140625ab..5e2cdb87 100644 --- a/docs/Windows/WindowsControlWrappers.md +++ b/docs/Windows/WindowsControlWrappers.md @@ -1,12 +1,12 @@ # Windows control wrappers -The goal of the platform control wrappers is to provide an easy set of elements which surface up properties and actions of the actual controls within the UI to make it easier for you to write tests that interact with them. +The goal of the platform control wrappers is to provide an easy set of elements that surface up properties and actions of the actual controls within the UI to make it easier for you to write tests that interact with them. These Windows control wrappers are designed to be used with applications built for the Windows platform. ## UWP Core Controls -These UWP control wrappers are designed to be used with applications built with Windows 10 SDK controls. +These Windows control wrappers are designed to be used with applications built with Windows 10 SDK controls. **NOTE**, these control wrappers will also work with the WinUI alternatives. @@ -43,8 +43,9 @@ These UWP control wrappers are designed to be used with applications built with ## WinUI Controls -These UWP control wrappers are designed to be used with controls from the [WinUI](https://github.com/microsoft/microsoft-ui-xaml) suite. +These Windows control wrappers are designed to be used with controls from the [WinUI](https://github.com/microsoft/microsoft-ui-xaml) suite. +- [InfoBar](../../src/Legerity.WinUI/InfoBar.cs) - [MenuBar](../../src/Legerity.WinUI/MenuBar.cs) - [MenuBarItem](../../src/Legerity.WinUI/MenuBarItem.cs) - [NavigationView](../../src/Legerity.WinUI/NavigationView.cs) @@ -54,7 +55,7 @@ These UWP control wrappers are designed to be used with controls from the [WinUI ## Windows Community Toolkit Controls -These UWP control wrappers are designed to be used with controls from the [Windows Community Toolkit](https://github.com/windows-toolkit/WindowsCommunityToolkit) suite. +These Windows control wrappers are designed to be used with controls from the [Windows Community Toolkit](https://github.com/windows-toolkit/WindowsCommunityToolkit) suite. - [BladeView](../../src/Legerity.WCT/BladeView.cs) - [BladeViewItem](../../src/Legerity.WCT/BladeViewItem.cs) @@ -64,7 +65,7 @@ These UWP control wrappers are designed to be used with controls from the [Windo ## Telerik UWP Controls -These UWP control wrappers are designed to be used with controls from the [Telerik UI for UWP](https://github.com/telerik/UI-For-UWP) suite. +These Windows control wrappers are designed to be used with controls from the [Telerik UI for UWP](https://github.com/telerik/UI-For-UWP) suite. - [RadAutoCompleteBox](../../src/Legerity.Telerik.Uwp/RadAutoCompleteBox.cs) - [RadBulletGraph](../../src/Legerity.Telerik.Uwp/RadBulletGraph.cs) @@ -73,7 +74,7 @@ These UWP control wrappers are designed to be used with controls from the [Teler ## MADE.NET Controls -These UWP control wrappers are designed to be used with controls from the [MADE.NET](https://github.com/MADE-Apps/MADE.NET) suite. +These Windows control wrappers are designed to be used with controls from the [MADE.NET](https://github.com/MADE-Apps/MADE.NET) suite. - [DropDownList](../../src/Legerity.MADE/DropDownList.cs) - [InputValidator](../../src/Legerity.MADE/InputValidator.cs) \ No newline at end of file diff --git a/samples/XamlControlsGallery/BaseTestClass.cs b/samples/XamlControlsGallery/BaseTestClass.cs index 78309566..ef6d4a3f 100644 --- a/samples/XamlControlsGallery/BaseTestClass.cs +++ b/samples/XamlControlsGallery/BaseTestClass.cs @@ -20,7 +20,8 @@ public virtual void Initialize() new WindowsAppManagerOptions(StoreSampleApp) { DriverUri = "http://127.0.0.1:4723", - LaunchWinAppDriver = true + LaunchWinAppDriver = true, + Maximize = true }); } diff --git a/samples/XamlControlsGallery/Pages/Collections/FlipViewPage.cs b/samples/XamlControlsGallery/Pages/Collections/FlipViewPage.cs index 5ea11c8a..8ad29b4d 100644 --- a/samples/XamlControlsGallery/Pages/Collections/FlipViewPage.cs +++ b/samples/XamlControlsGallery/Pages/Collections/FlipViewPage.cs @@ -4,8 +4,6 @@ namespace XamlControlsGallery.Pages.Collections using Legerity.Pages; using Legerity.Windows.Elements.Core; - using Legerity.Windows.Extensions; - using Microsoft.VisualStudio.TestTools.UnitTesting; using OpenQA.Selenium; diff --git a/samples/XamlControlsGallery/Pages/DateAndTime/CalendarDatePickerPage.cs b/samples/XamlControlsGallery/Pages/DateAndTime/CalendarDatePickerPage.cs index f0b4453a..4f049b54 100644 --- a/samples/XamlControlsGallery/Pages/DateAndTime/CalendarDatePickerPage.cs +++ b/samples/XamlControlsGallery/Pages/DateAndTime/CalendarDatePickerPage.cs @@ -8,7 +8,6 @@ namespace XamlControlsGallery.Pages.DateAndTime using Microsoft.VisualStudio.TestTools.UnitTesting; using OpenQA.Selenium; - using OpenQA.Selenium.Appium.Windows; /// /// Defines the CalendarDatePickerPage page of the XAML Controls Gallery application. diff --git a/samples/XamlControlsGallery/Pages/DateAndTime/CalendarViewPage.cs b/samples/XamlControlsGallery/Pages/DateAndTime/CalendarViewPage.cs index 86406685..7e73fc38 100644 --- a/samples/XamlControlsGallery/Pages/DateAndTime/CalendarViewPage.cs +++ b/samples/XamlControlsGallery/Pages/DateAndTime/CalendarViewPage.cs @@ -8,7 +8,6 @@ namespace XamlControlsGallery.Pages.DateAndTime using Microsoft.VisualStudio.TestTools.UnitTesting; using OpenQA.Selenium; - using OpenQA.Selenium.Appium.Windows; /// /// Defines the CalendarView page of the XAML Controls Gallery application. diff --git a/samples/XamlControlsGallery/Pages/Media/InkToolbarPage.cs b/samples/XamlControlsGallery/Pages/Media/InkToolbarPage.cs index 398d58f7..4e12832d 100644 --- a/samples/XamlControlsGallery/Pages/Media/InkToolbarPage.cs +++ b/samples/XamlControlsGallery/Pages/Media/InkToolbarPage.cs @@ -1,13 +1,8 @@ namespace XamlControlsGallery.Pages.Media { - using System.Threading; - using Legerity.Pages; using Legerity.Windows.Elements.Core; using Legerity.Windows.Extensions; - - using Microsoft.VisualStudio.TestTools.UnitTesting; - using OpenQA.Selenium; /// diff --git a/samples/XamlControlsGallery/Pages/MenusAndToolbars/MenuBarPage.cs b/samples/XamlControlsGallery/Pages/MenusAndToolbars/MenuBarPage.cs index b21d9f9e..932d3d8e 100644 --- a/samples/XamlControlsGallery/Pages/MenusAndToolbars/MenuBarPage.cs +++ b/samples/XamlControlsGallery/Pages/MenusAndToolbars/MenuBarPage.cs @@ -1,7 +1,5 @@ namespace XamlControlsGallery.Pages.MenusAndToolbars { - using System.Linq; - using Legerity; using Legerity.Pages; using Legerity.Windows.Elements.Core; using Legerity.Windows.Elements.WinUI; diff --git a/samples/XamlControlsGallery/Pages/Navigation/TabViewPage.cs b/samples/XamlControlsGallery/Pages/Navigation/TabViewPage.cs index 1d033333..c463bfed 100644 --- a/samples/XamlControlsGallery/Pages/Navigation/TabViewPage.cs +++ b/samples/XamlControlsGallery/Pages/Navigation/TabViewPage.cs @@ -1,9 +1,6 @@ namespace XamlControlsGallery.Pages.Navigation { - using System.Linq; - using Legerity.Pages; - using Legerity.Windows.Elements.Core; using Legerity.Windows.Elements.WinUI; using Legerity.Windows.Extensions; diff --git a/samples/XamlControlsGallery/Pages/NavigationMenu.cs b/samples/XamlControlsGallery/Pages/NavigationMenu.cs index 229d51b5..14c59721 100644 --- a/samples/XamlControlsGallery/Pages/NavigationMenu.cs +++ b/samples/XamlControlsGallery/Pages/NavigationMenu.cs @@ -8,8 +8,7 @@ namespace XamlControlsGallery.Pages using Microsoft.VisualStudio.TestTools.UnitTesting; using OpenQA.Selenium; - using OpenQA.Selenium.Appium.Windows; - + using StatusAndInfo; using XamlControlsGallery.Pages.BasicInput; using XamlControlsGallery.Pages.Collections; using XamlControlsGallery.Pages.DateAndTime; @@ -127,6 +126,12 @@ public FlipViewPage GoToFlipViewPage() return new FlipViewPage(); } + public InfoBarPage GoToInfoBarPage() + { + this.SearchForControl("InfoBar"); + return new InfoBarPage(); + } + /// /// Navigates to the ink toolbar control page. /// diff --git a/samples/XamlControlsGallery/Pages/StatusAndInfo/InfoBarPage.cs b/samples/XamlControlsGallery/Pages/StatusAndInfo/InfoBarPage.cs new file mode 100644 index 00000000..392db588 --- /dev/null +++ b/samples/XamlControlsGallery/Pages/StatusAndInfo/InfoBarPage.cs @@ -0,0 +1,27 @@ +namespace XamlControlsGallery.Pages.StatusAndInfo +{ + using Legerity.Pages; + using Legerity.Windows.Elements.WinUI; + using Legerity.Windows.Extensions; + using OpenQA.Selenium; + + /// + /// Defines the InfoBar page of the XAML Controls Gallery application. + /// + public class InfoBarPage : BasePage + { + private readonly By closableBarWithOptsQuery = ByExtensions.AutomationId("TestInfoBar1"); + + /// + /// Gets a given trait of the page to verify that the page is in view. + /// + protected override By Trait => By.XPath(".//*[@Name='InfoBar'][@AutomationId='TitleTextBlock']"); + + public InfoBarPage CloseClosableBarWithOptions() + { + InfoBar closeableBarWithOpts = this.WindowsApp.FindElement(this.closableBarWithOptsQuery); + closeableBarWithOpts.Close(); + return this; + } + } +} \ No newline at end of file diff --git a/samples/XamlControlsGallery/Pages/Text/NumberBoxPage.cs b/samples/XamlControlsGallery/Pages/Text/NumberBoxPage.cs index f0b86f54..678b30a9 100644 --- a/samples/XamlControlsGallery/Pages/Text/NumberBoxPage.cs +++ b/samples/XamlControlsGallery/Pages/Text/NumberBoxPage.cs @@ -1,7 +1,6 @@ namespace XamlControlsGallery.Pages.Text { using Legerity.Pages; - using Legerity.Windows.Elements.Core; using Legerity.Windows.Elements.WinUI; using Legerity.Windows.Extensions; diff --git a/samples/XamlControlsGallery/Tests/Media/InkToolbarTests.cs b/samples/XamlControlsGallery/Tests/Media/InkToolbarTests.cs index b4b2b80d..42e68196 100644 --- a/samples/XamlControlsGallery/Tests/Media/InkToolbarTests.cs +++ b/samples/XamlControlsGallery/Tests/Media/InkToolbarTests.cs @@ -1,11 +1,8 @@ namespace XamlControlsGallery.Tests.Media { - using System; - using Microsoft.VisualStudio.TestTools.UnitTesting; using XamlControlsGallery.Pages; - using XamlControlsGallery.Pages.DateAndTime; using XamlControlsGallery.Pages.Media; [TestClass] diff --git a/samples/XamlControlsGallery/Tests/MenusAndToolbars/AppBarToggleButtonTests.cs b/samples/XamlControlsGallery/Tests/MenusAndToolbars/AppBarToggleButtonTests.cs index bed33093..ea79b9e9 100644 --- a/samples/XamlControlsGallery/Tests/MenusAndToolbars/AppBarToggleButtonTests.cs +++ b/samples/XamlControlsGallery/Tests/MenusAndToolbars/AppBarToggleButtonTests.cs @@ -3,7 +3,6 @@ namespace XamlControlsGallery.Tests.BasicInput using Microsoft.VisualStudio.TestTools.UnitTesting; using XamlControlsGallery.Pages; - using XamlControlsGallery.Pages.BasicInput; using XamlControlsGallery.Pages.MenusAndToolbars; [TestClass] diff --git a/samples/XamlControlsGallery/Tests/MenusAndToolbars/CommandBarTests.cs b/samples/XamlControlsGallery/Tests/MenusAndToolbars/CommandBarTests.cs index 6aeab3b2..059cd931 100644 --- a/samples/XamlControlsGallery/Tests/MenusAndToolbars/CommandBarTests.cs +++ b/samples/XamlControlsGallery/Tests/MenusAndToolbars/CommandBarTests.cs @@ -3,7 +3,6 @@ namespace XamlControlsGallery.Tests.BasicInput using Microsoft.VisualStudio.TestTools.UnitTesting; using XamlControlsGallery.Pages; - using XamlControlsGallery.Pages.BasicInput; using XamlControlsGallery.Pages.MenusAndToolbars; [TestClass] diff --git a/samples/XamlControlsGallery/Tests/MenusAndToolbars/MenuBarTests.cs b/samples/XamlControlsGallery/Tests/MenusAndToolbars/MenuBarTests.cs index 4b672fcb..525e81f5 100644 --- a/samples/XamlControlsGallery/Tests/MenusAndToolbars/MenuBarTests.cs +++ b/samples/XamlControlsGallery/Tests/MenusAndToolbars/MenuBarTests.cs @@ -1,12 +1,7 @@ namespace XamlControlsGallery.Tests.BasicInput { - using System.Linq; - using Legerity; - using Legerity.Windows.Elements.WinUI; using Microsoft.VisualStudio.TestTools.UnitTesting; - using OpenQA.Selenium; using XamlControlsGallery.Pages; - using XamlControlsGallery.Pages.BasicInput; using XamlControlsGallery.Pages.MenusAndToolbars; [TestClass] diff --git a/samples/XamlControlsGallery/Tests/Navigation/TabViewTests.cs b/samples/XamlControlsGallery/Tests/Navigation/TabViewTests.cs index 6d81e229..5bbf4721 100644 --- a/samples/XamlControlsGallery/Tests/Navigation/TabViewTests.cs +++ b/samples/XamlControlsGallery/Tests/Navigation/TabViewTests.cs @@ -3,7 +3,6 @@ namespace XamlControlsGallery.Tests.Navigation using Microsoft.VisualStudio.TestTools.UnitTesting; using XamlControlsGallery.Pages; - using XamlControlsGallery.Pages.Collections; using XamlControlsGallery.Pages.Navigation; [TestClass] diff --git a/samples/XamlControlsGallery/Tests/StatusAndInfo/InfoBarTests.cs b/samples/XamlControlsGallery/Tests/StatusAndInfo/InfoBarTests.cs new file mode 100644 index 00000000..b32c9c4f --- /dev/null +++ b/samples/XamlControlsGallery/Tests/StatusAndInfo/InfoBarTests.cs @@ -0,0 +1,25 @@ +namespace XamlControlsGallery.Tests.StatusAndInfo +{ + using Microsoft.VisualStudio.TestTools.UnitTesting; + using Pages; + using Pages.StatusAndInfo; + + [TestClass] + public class InfoBarTests : BaseTestClass + { + private static InfoBarPage InfoBarPage { get; set; } + + [TestInitialize] + public override void Initialize() + { + base.Initialize(); + InfoBarPage = new NavigationMenu().GoToInfoBarPage(); + } + + [TestMethod] + public void CloseClosableBarWithOptions() + { + InfoBarPage.CloseClosableBarWithOptions(); + } + } +} \ No newline at end of file diff --git a/samples/XamlControlsGallery/Tests/Text/AutoSuggestBoxTests.cs b/samples/XamlControlsGallery/Tests/Text/AutoSuggestBoxTests.cs index ee29c13b..d9fc690c 100644 --- a/samples/XamlControlsGallery/Tests/Text/AutoSuggestBoxTests.cs +++ b/samples/XamlControlsGallery/Tests/Text/AutoSuggestBoxTests.cs @@ -3,7 +3,6 @@ namespace XamlControlsGallery.Tests.Text using Microsoft.VisualStudio.TestTools.UnitTesting; using XamlControlsGallery.Pages; - using XamlControlsGallery.Pages.BasicInput; using XamlControlsGallery.Pages.Text; [TestClass] diff --git a/samples/XamlControlsGallery/Tests/Text/NumberBoxTests.cs b/samples/XamlControlsGallery/Tests/Text/NumberBoxTests.cs index 11e70a3d..5c2d48b3 100644 --- a/samples/XamlControlsGallery/Tests/Text/NumberBoxTests.cs +++ b/samples/XamlControlsGallery/Tests/Text/NumberBoxTests.cs @@ -3,7 +3,6 @@ namespace XamlControlsGallery.Tests.Text using Microsoft.VisualStudio.TestTools.UnitTesting; using XamlControlsGallery.Pages; - using XamlControlsGallery.Pages.BasicInput; using XamlControlsGallery.Pages.Text; [TestClass] diff --git a/src/Legerity.WinUI/InfoBar.cs b/src/Legerity.WinUI/InfoBar.cs new file mode 100644 index 00000000..ee32c0ce --- /dev/null +++ b/src/Legerity.WinUI/InfoBar.cs @@ -0,0 +1,90 @@ +namespace Legerity.Windows.Elements.WinUI +{ + using Core; + using Extensions; + using OpenQA.Selenium.Appium; + using OpenQA.Selenium.Appium.Windows; + + /// + /// Defines a wrapper for the WinUI InfoBar control. + /// + public class InfoBar : WindowsElementWrapper + { + /// + /// Initializes a new instance of the class. + /// + /// + /// The reference. + /// + public InfoBar(WindowsElement element) + : base(element) + { + } + + /// + /// Gets the title of the info bar. + /// + public string Title => this.TitleTextBlock.Text; + + /// + /// Gets the message of the info bar. + /// + public string Message => this.MessageTextBlock.Text; + + /// + /// Gets a value indicating whether the info bar is open. + /// + public bool IsOpen => !bool.Parse(this.Element.GetAttribute("IsOffscreen")); + + /// + /// Gets the element associated with the title . + /// + public TextBlock TitleTextBlock => this.FindElement(ByExtensions.AutomationId("Title")); + + /// + /// Gets the element associated with the message . + /// + public TextBlock MessageTextBlock => this.FindElement(ByExtensions.AutomationId("Message")); + + /// + /// Gets the element associated with the close . + /// + public Button CloseButton => this.FindElement(ByExtensions.AutomationId("CloseButton")); + + /// + /// Allows conversion of a to the without direct casting. + /// + /// + /// The . + /// + /// + /// The . + /// + public static implicit operator InfoBar(WindowsElement element) + { + return new InfoBar(element); + } + + /// + /// Allows conversion of a to the without direct casting. + /// + /// + /// The . + /// + /// + /// The . + /// + public static implicit operator InfoBar(AppiumWebElement element) + { + return new InfoBar(element as WindowsElement); + } + + /// + /// Closes the info bar. + /// + public void Close() + { + this.CloseButton.Click(); + } + } +} \ No newline at end of file diff --git a/src/Legerity/AppManager.cs b/src/Legerity/AppManager.cs index a07aa94b..8a61f12d 100644 --- a/src/Legerity/AppManager.cs +++ b/src/Legerity/AppManager.cs @@ -100,6 +100,11 @@ public static void StartApp(AppManagerOptions opts) winOpts.AppiumOptions); VerifyAppDriver(WindowsApp, winOpts); + + if (winOpts.Maximize) + { + WebApp.Manage().Window.Maximize(); + } break; } diff --git a/src/Legerity/ElementWrapper`1.cs b/src/Legerity/ElementWrapper`1.cs index 7ed289e3..f103c92a 100644 --- a/src/Legerity/ElementWrapper`1.cs +++ b/src/Legerity/ElementWrapper`1.cs @@ -41,6 +41,16 @@ protected ElementWrapper(TElement element) /// public bool IsVisible => this.Element.Displayed; + /// + /// Finds a child element by the specified query. + /// + /// The query to find a child element by. + /// The . + public AppiumWebElement FindElement(By by) + { + return this.Element.FindElement(by); + } + /// /// Determines whether the given element is shown. /// diff --git a/src/Legerity/Windows/WindowsAppManagerOptions.cs b/src/Legerity/Windows/WindowsAppManagerOptions.cs index 452eb0b7..4f9d59f7 100644 --- a/src/Legerity/Windows/WindowsAppManagerOptions.cs +++ b/src/Legerity/Windows/WindowsAppManagerOptions.cs @@ -44,6 +44,11 @@ public WindowsAppManagerOptions(string appId, params (string, object)[] addition /// public bool LaunchWinAppDriver { get; set; } + /// + /// Gets or sets whether to maximize the window for the application. + /// + public bool Maximize { get; set; } + /// /// Gets or sets the path to the WinAppDriver installation for launch. ///