diff --git a/samples/W3SchoolsWebTests/Tools/Edge/MicrosoftWebDriver.exe b/samples/W3SchoolsWebTests/Tools/Edge/MicrosoftWebDriver.exe index d0435a37..bb9ec598 100644 Binary files a/samples/W3SchoolsWebTests/Tools/Edge/MicrosoftWebDriver.exe and b/samples/W3SchoolsWebTests/Tools/Edge/MicrosoftWebDriver.exe differ diff --git a/samples/WebTests/Tools/Edge/MicrosoftWebDriver.exe b/samples/WebTests/Tools/Edge/MicrosoftWebDriver.exe index d0435a37..bb9ec598 100644 Binary files a/samples/WebTests/Tools/Edge/MicrosoftWebDriver.exe and b/samples/WebTests/Tools/Edge/MicrosoftWebDriver.exe differ diff --git a/src/Legerity.Core/AppManager.cs b/src/Legerity.Core/AppManager.cs index 05d551bd..07ce235d 100644 --- a/src/Legerity.Core/AppManager.cs +++ b/src/Legerity.Core/AppManager.cs @@ -26,22 +26,30 @@ public static class AppManager /// /// Gets the instance of the started Windows application. /// - public static WindowsDriver WindowsApp => WebApp as WindowsDriver; + public static WindowsDriver WindowsApp => App as WindowsDriver; /// /// Gets the instance of the started Android application. /// - public static AndroidDriver AndroidApp => WebApp as AndroidDriver; + public static AndroidDriver AndroidApp => App as AndroidDriver; /// /// Gets the instance of the started iOS application. /// - public static IOSDriver IOSApp => WebApp as IOSDriver; + public static IOSDriver IOSApp => App as IOSDriver; /// /// Get the instance of the started web application. /// - public static RemoteWebDriver WebApp { get; set; } + public static RemoteWebDriver WebApp => App; + + /// + /// Gets the instance of the started application. + /// + /// This could be a , , , or web driver. + /// + /// + public static RemoteWebDriver App { get; set; } /// /// Starts the application ready for testing. @@ -62,7 +70,7 @@ public static void StartApp(AppManagerOptions opts) { case WebAppManagerOptions webOpts: { - WebApp = webOpts.DriverType switch + App = webOpts.DriverType switch { WebAppDriverType.Chrome => new ChromeDriver(webOpts.DriverUri), WebAppDriverType.Firefox => new FirefoxDriver(webOpts.DriverUri), @@ -70,21 +78,21 @@ public static void StartApp(AppManagerOptions opts) WebAppDriverType.Safari => new SafariDriver(webOpts.DriverUri), WebAppDriverType.Edge => new EdgeDriver(webOpts.DriverUri), WebAppDriverType.InternetExplorer => new InternetExplorerDriver(webOpts.DriverUri), - _ => WebApp + _ => App }; - VerifyAppDriver(WebApp, webOpts); + VerifyAppDriver(App, webOpts); if (webOpts.Maximize) { - WebApp.Manage().Window.Maximize(); + App.Manage().Window.Maximize(); } else { - WebApp.Manage().Window.Size = webOpts.DesiredSize; + App.Manage().Window.Size = webOpts.DesiredSize; } - WebApp.Url = webOpts.Url; + App.Url = webOpts.Url; break; } case WindowsAppManagerOptions winOpts: @@ -94,7 +102,7 @@ public static void StartApp(AppManagerOptions opts) WinAppDriverHelper.Run(); } - WebApp = new WindowsDriver( + App = new WindowsDriver( new Uri(winOpts.DriverUri), winOpts.AppiumOptions); @@ -102,14 +110,15 @@ public static void StartApp(AppManagerOptions opts) if (winOpts.Maximize) { - WebApp.Manage().Window.Maximize(); + App.Manage().Window.Maximize(); } + break; } case AndroidAppManagerOptions androidOpts: { - WebApp = new AndroidDriver( + App = new AndroidDriver( new Uri(androidOpts.DriverUri), androidOpts.AppiumOptions); @@ -119,7 +128,7 @@ public static void StartApp(AppManagerOptions opts) case IOSAppManagerOptions iosOpts: { - WebApp = new IOSDriver(new Uri(iosOpts.DriverUri), iosOpts.AppiumOptions); + App = new IOSDriver(new Uri(iosOpts.DriverUri), iosOpts.AppiumOptions); VerifyAppDriver(IOSApp, iosOpts); break; @@ -132,10 +141,10 @@ public static void StartApp(AppManagerOptions opts) /// public static void StopApp() { - if (WebApp != null) + if (App != null) { - WebApp.Quit(); - WebApp = null; + App.Quit(); + App = null; } WinAppDriverHelper.Stop(); diff --git a/src/Legerity.Core/Pages/BasePage.cs b/src/Legerity.Core/Pages/BasePage.cs index b86e483a..6e2646e8 100644 --- a/src/Legerity.Core/Pages/BasePage.cs +++ b/src/Legerity.Core/Pages/BasePage.cs @@ -1,6 +1,7 @@ namespace Legerity.Pages { using System; + using Legerity.Exceptions; using OpenQA.Selenium; @@ -42,11 +43,19 @@ protected BasePage() /// /// Gets the instance of the started web application. + /// + protected RemoteWebDriver WebApp => AppManager.WebApp; + + /// + /// Gets the instance of the started application. + /// + /// The instance serves as base for the drivers and can be referenced for basic Selenium functions. + /// /// - /// The instance also serves as base for the Appium drivers and can be referenced for basic Selenium functions. + /// This could be a , , , or web driver. /// /// - protected RemoteWebDriver WebApp => AppManager.WebApp; + protected RemoteWebDriver App => AppManager.App; /// /// Gets a given trait of the page to verify that the page is in view. @@ -73,7 +82,7 @@ public void VerifyPageShown() /// Thrown if the page is not shown. public void VerifyPageShown(TimeSpan? timeout) { - if (this.WebApp == null) + if (this.App == null) { throw new DriverNotInitializedException( $"An app driver has not been initialized. Call 'AppManager.StartApp()' with an instance of an {nameof(AppManagerOptions)} to setup for testing."); @@ -81,16 +90,16 @@ public void VerifyPageShown(TimeSpan? timeout) if (timeout == null) { - if (this.WebApp != null && this.WebApp.FindElement(this.Trait) == null) + if (this.App != null && this.App.FindElement(this.Trait) == null) { throw new PageNotShownException(this.GetType().Name); } } else { - if (this.WebApp != null) + if (this.App != null) { - AttemptWaitForDriverElement(this.Trait, timeout.Value, this.WebApp); + AttemptWaitForDriverElement(this.Trait, timeout.Value, this.App); } } } @@ -121,7 +130,7 @@ public void VerifyElementShown(By by) /// Thrown if the element is not shown. public void VerifyElementShown(By by, TimeSpan? timeout) { - if (this.WebApp == null) + if (this.App == null) { throw new DriverNotInitializedException( $"An app driver has not been initialized. Call 'AppManager.StartApp()' with an instance of an {nameof(AppManagerOptions)} to setup for testing."); @@ -129,16 +138,16 @@ public void VerifyElementShown(By by, TimeSpan? timeout) if (timeout == null) { - if (this.WebApp != null && this.WebApp.FindElement(by) == null) + if (this.App != null && this.App.FindElement(by) == null) { throw new ElementNotShownException(by.ToString()); } } else { - if (this.WebApp != null) + if (this.App != null) { - AttemptWaitForDriverElement(by, timeout.Value, this.WebApp); + AttemptWaitForDriverElement(by, timeout.Value, this.App); } } } @@ -152,7 +161,7 @@ public void VerifyElementShown(By by, TimeSpan? timeout) /// Thrown if AppManager.StartApp() has not been called. public void VerifyElementNotShown(By by) { - if (this.WebApp == null) + if (this.App == null) { throw new DriverNotInitializedException( $"An app driver has not been initialized. Call 'AppManager.StartApp()' with an instance of an {nameof(AppManagerOptions)} to setup for testing.");