Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Starting work on UI Testing * Working test * More work getting UI tests rolling. * Working base test * Work on startup to make it more robust * Starting work to coding demo app. * Updates with pipeline starting WinAppDriver and output * Turning off winapp driver starting. * Automatically start and stop SUT application * WIP * Getting UI Tests running from UITestCases App * Updated UITestCases to load tests via reflection DialogTests properly reset each time they are used. * Updating build configuration. * Fixing arguments to dotnet test * Updating timeout * Clean up of UI tests to perform explicit waits * Switching back to managing the process * Waiting for condition to be true rather than a single assert. * Adding screenshot. * Attempted publishing of UI tests results. * Increasing timeouts on failing tests * Fixing overload resolution. * Fixing screen resolution to avoid clicking in the wrong spot. * Renaming solution Creating a solution filter for backwards compatibility * Adding automatic saving of screenshots Updating build pipeline to only run UI tests on merges to master * Removing un-used test project * Fixing colors unit test project * Warnings cleanup
- Loading branch information
Showing
35 changed files
with
1,001 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 3 additions & 6 deletions
9
MaterialDesignColors.Wpf.Tests/MaterialDesignColors.Wpf.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
MaterialDesignThemes.MahApps.Tests/MaterialDesignThemes.MahApps.Tests.csproj
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.IO; | ||
using Xunit; | ||
|
||
[assembly: CollectionBehavior(DisableTestParallelization = true)] | ||
|
||
namespace MaterialDesignThemes.UITests | ||
{ | ||
public static class App | ||
{ | ||
#if DEBUG | ||
private const string Configuration = "Debug"; | ||
#else | ||
private const string Configuration = "Release"; | ||
#endif | ||
|
||
public static string DemoAppPath => Path.GetFullPath(@$"..\..\..\..\MainDemo.Wpf\bin\{Configuration}\netcoreapp3.1\MaterialDesignDemo.exe"); | ||
|
||
public static string UITestsAppPath => Path.GetFullPath(@$"..\..\..\..\UITestCases\bin\{Configuration}\netcoreapp3.1\UITestCases.exe"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
using System; | ||
using OpenQA.Selenium; | ||
using OpenQA.Selenium.Appium.Windows; | ||
using OpenQA.Selenium.Support.UI; | ||
using Xunit; | ||
using Xunit.Sdk; | ||
using DefaultWait = OpenQA.Selenium.Support.UI.DefaultWait<OpenQA.Selenium.Appium.Windows.WindowsDriver<OpenQA.Selenium.Appium.Windows.WindowsElement>>; | ||
|
||
namespace MaterialDesignThemes.UITests | ||
{ | ||
public static class AppiumHelpers | ||
{ | ||
private static IClock Clock { get; } = new SystemClock(); | ||
|
||
public static WindowsElement GetElementByAccessibilityId( | ||
this WindowsDriver<WindowsElement> driver, | ||
string selector, | ||
TimeSpan? timeout = null, | ||
TimeSpan? pollingInterval = null) | ||
{ | ||
if (driver is null) | ||
{ | ||
throw new ArgumentNullException(nameof(driver)); | ||
} | ||
|
||
if (string.IsNullOrEmpty(selector)) | ||
{ | ||
throw new ArgumentException($"'{nameof(selector)}' cannot be null or empty", nameof(selector)); | ||
} | ||
|
||
DefaultWait wait = GetWait(driver, timeout, pollingInterval); | ||
wait.IgnoreExceptionTypes(typeof(WebDriverException)); | ||
return wait.Until(driver => driver.FindElementByAccessibilityId(selector)!); | ||
} | ||
|
||
public static void WaitFor(this WindowsDriver<WindowsElement> driver, | ||
Func<bool> condition, | ||
TimeSpan? timeout = null, | ||
TimeSpan? pollingInterval = null) | ||
=> driver.WaitUntil(_ => | ||
{ | ||
Assert.True(condition()); | ||
return true; | ||
}, timeout, pollingInterval); | ||
|
||
public static void WaitUntil( | ||
this WindowsDriver<WindowsElement> driver, | ||
Action condition, | ||
TimeSpan? timeout = null, | ||
TimeSpan? pollingInterval = null) | ||
=> driver.WaitUntil(_ => | ||
{ | ||
condition(); | ||
return true; | ||
}, timeout, pollingInterval); | ||
|
||
public static void WaitUntil( | ||
this WindowsDriver<WindowsElement> driver, | ||
Action<WindowsDriver<WindowsElement>> condition, | ||
TimeSpan? timeout = null, | ||
TimeSpan? pollingInterval = null) | ||
=> driver.WaitUntil<bool>(driver => | ||
{ | ||
condition(driver); | ||
return true; | ||
}, timeout, pollingInterval); | ||
|
||
public static TResult WaitUntil<TResult>( | ||
this WindowsDriver<WindowsElement> driver, | ||
Func<TResult> condition, | ||
TimeSpan? timeout = null, | ||
TimeSpan? pollingInterval = null) | ||
=> driver.WaitUntil(_ => condition(), timeout, pollingInterval); | ||
|
||
public static TResult WaitUntil<TResult>( | ||
this WindowsDriver<WindowsElement> driver, | ||
Func<WindowsDriver<WindowsElement>, TResult> condition, | ||
TimeSpan? timeout = null, | ||
TimeSpan? pollingInterval = null) | ||
{ | ||
if (driver is null) | ||
{ | ||
throw new ArgumentNullException(nameof(driver)); | ||
} | ||
|
||
if (condition is null) | ||
{ | ||
throw new ArgumentNullException(nameof(condition)); | ||
} | ||
|
||
DefaultWait wait = GetWait(driver, timeout, pollingInterval); | ||
wait.IgnoreExceptionTypes( | ||
typeof(WebDriverException), | ||
typeof(XunitException) | ||
); | ||
return wait.Until(condition); | ||
} | ||
|
||
private static DefaultWait GetWait( | ||
WindowsDriver<WindowsElement> driver, | ||
TimeSpan? timeout, | ||
TimeSpan? pollingInterval = null) | ||
{ | ||
TimeSpan timeoutValue = timeout ?? TimeSpan.FromSeconds(3); | ||
TimeSpan interval = pollingInterval ?? TimeSpan.FromMilliseconds(timeoutValue.TotalMilliseconds / 10); | ||
var wait = new DefaultWait(driver, Clock) | ||
{ | ||
Timeout = timeoutValue, | ||
PollingInterval = interval | ||
}; | ||
return wait; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using OpenQA.Selenium.Appium; | ||
using OpenQA.Selenium.Appium.Windows; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace MaterialDesignThemes.UITests.DemoApp | ||
{ | ||
public class DemoAppTests : TestBase | ||
{ | ||
public DemoAppTests(ITestOutputHelper output) | ||
: base(output, App.DemoAppPath) | ||
{ | ||
WindowsElement? element = Driver.FindElementByName("Material Design In XAML Toolkit"); | ||
Assert.NotNull(element); | ||
} | ||
|
||
[Fact] | ||
public void CanOpenAllPagesOnTheDemoApp() | ||
{ | ||
using var recorder = new TestRecorder(Driver, Output); | ||
|
||
var mainWindow = new MainWindow(Driver); | ||
|
||
foreach (AppiumWebElement? listItem in mainWindow.PageListItems) | ||
{ | ||
var rect = mainWindow.PagesListBox.Rect; | ||
Driver.WaitFor(() => mainWindow.PagesListBox.Rect.Right <= 1); | ||
Driver.WaitFor(() => mainWindow.HamburgerToggleButton.Displayed); | ||
mainWindow.HamburgerToggleButton.Click(); | ||
|
||
Driver.WaitFor(() => listItem.Location.X >= 0); | ||
listItem.Click(); | ||
} | ||
|
||
recorder.Success(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using OpenQA.Selenium; | ||
using OpenQA.Selenium.Appium; | ||
using OpenQA.Selenium.Appium.Windows; | ||
|
||
namespace MaterialDesignThemes.UITests.DemoApp | ||
{ | ||
public class MainWindow | ||
{ | ||
private WindowsDriver<WindowsElement> Driver { get; } | ||
|
||
public MainWindow(WindowsDriver<WindowsElement> driver) | ||
=> Driver = driver ?? throw new ArgumentNullException(nameof(driver)); | ||
|
||
public WindowsElement PagesListBox | ||
=> Driver.FindElementByName("DemoPagesListBox")!; | ||
|
||
public IList<AppiumWebElement> PageListItems | ||
=> PagesListBox.FindElements(By.XPath("//ListItem"))!; | ||
|
||
public WindowsElement HamburgerToggleButton | ||
=> Driver.FindElementByName("HamburgerToggleButton")!; | ||
} | ||
} |
Oops, something went wrong.