public void Should_BePossibleTo_WorkWithTwoWindows()
        {
            ProcessManager.Start(ApplicationPath);

            AqualityServices.SetWindowHandleApplicationFactory(rootSession => new CoreChromeWindow(rootSession).NativeWindowHandle);
            var navigationPanel = new ChromeNavigationPanel();

            Assert.IsTrue(navigationPanel.IsDisplayed);
            var firstTabName = AqualityServices.Application.Driver.Title;
            var firstWindow  = new ChromeWindow(firstTabName);

            Assert.IsTrue(firstWindow.IsDisplayed, $"{firstWindow.Name} window is not displayed");
            firstWindow.Click();
            navigationPanel.OpenDownloads();
            firstWindow = new ChromeWindow(DownloadsTabName);
            Assert.IsTrue(firstWindow.IsDisplayed, $"First window is not displayed with the new name {firstWindow.Name}");
            navigationPanel.OpenNewTab();
            var secondWindow = new ChromeWindow(NewTabName);

            Assert.IsTrue(secondWindow.IsDisplayed, $"Second window with the name {secondWindow.Name} is not displayed");
            secondWindow.Click();
            secondWindow.Close();
            Assert.IsFalse(secondWindow.IsDisplayed, "Second window is not closed");
            Assert.IsTrue(firstWindow.IsDisplayed, "First window is closed but should not");
        }
Beispiel #2
0
        public void Should_GetCurrentApplication_AfterSetApplication()
        {
            IApplication firstApplication;

            using (var scope = AqualityServices.Get <IServiceProvider>().CreateScope())
            {
                firstApplication = scope.ServiceProvider.GetRequiredService <IWindowsApplication>().Launch();
            }

            // Creating a second instance of Application
            AqualityServices.Application = AqualityServices.ApplicationFactory.Application;

            using (var scope = AqualityServices.Get <IServiceProvider>().CreateScope())
            {
                var secondApplication = scope.ServiceProvider.GetRequiredService <IWindowsApplication>().Launch();
                Assert.AreNotSame(firstApplication, secondApplication);
                secondApplication.Driver.Quit();
            }

            // Switching back to a first instance of Application
            AqualityServices.Application = firstApplication as IWindowsApplication;

            using (var scope = AqualityServices.Get <IServiceProvider>().CreateScope())
            {
                Assert.AreSame(firstApplication, scope.ServiceProvider.GetRequiredService <IWindowsApplication>().Launch());
            }
        }
Beispiel #3
0
        public void Should_BePossibleTo_ExecuteAsyncJavaScript_WithScriptTimeoutException()
        {
            new DynamicContentForm().Open();
            var expectedDurationInSeconds = AqualityServices.Get <ITimeoutConfiguration>().Script.TotalSeconds + 1;

            Assert.Throws <WebDriverTimeoutException>(() => AqualityServices.Browser.ExecuteAsyncScript(GetAsyncTimeoutJavaScript(expectedDurationInSeconds)));
        }
Beispiel #4
0
 public void TearDown()
 {
     Environment.SetEnvironmentVariable(PlatformNamePropertyKey, null);
     Environment.SetEnvironmentVariable(DevicesProfilePropertyKey, null);
     Environment.SetEnvironmentVariable(DevicesKeyPropertyKey, null);
     AqualityServices.SetStartup(new MobileStartup());
 }
        protected void PerformTouchAction(Func <ITouchAction, ITouchAction> function, Point endPoint)
        {
            var actionRetrier = AqualityServices.Get <IElementActionRetrier>();
            var touchAction   = new TouchAction(AqualityServices.Application.Driver);

            actionRetrier.DoWithRetry(() =>
                                      function(touchAction).MoveTo(endPoint.X, endPoint.Y).Release().Perform());
        }
Beispiel #6
0
        public void Should_BeAbleGetBrowser_WithStartArguments(string startArguments)
        {
            var currentBrowser = AqualityServices.Get <IBrowserProfile>().BrowserName;

            Environment.SetEnvironmentVariable("isRemote", "false");
            Environment.SetEnvironmentVariable($"driverSettings.{currentBrowser.ToString().ToLowerInvariant()}.startArguments", startArguments);
            Assert.DoesNotThrow(() => AqualityServices.Browser.WaitForPageToLoad());
        }
Beispiel #7
0
        public void Should_BePossible_ToGetDefaultDeviceSettingsForAndroidPlatform()
        {
            Environment.SetEnvironmentVariable(PlatformNamePropertyKey, "android");
            Environment.SetEnvironmentVariable(DevicesKeyPropertyKey, "Nexus");
            var options = AqualityServices.Get <IApplicationProfile>().DriverSettings.AppiumOptions;

            Assert.AreEqual("Nexus", options.ToDictionary()["deviceName"]);
        }
Beispiel #8
0
        public void Should_BePossible_ToOverrideDefaultDevice()
        {
            Environment.SetEnvironmentVariable(PlatformNamePropertyKey, "android");
            Environment.SetEnvironmentVariable(DevicesKeyPropertyKey, "Samsung_Galaxy");
            var options = AqualityServices.Get <IApplicationProfile>().DriverSettings.AppiumOptions;

            Assert.AreEqual("Samsung Galaxy", options.ToDictionary()["deviceName"]);
        }
Beispiel #9
0
        public override void CleanUp()
        {
            base.CleanUp();
            AqualityServices.SetDefaultFactory();
            var executableName = ApplicationPath.Contains('\\') ? ApplicationPath.Substring(ApplicationPath.LastIndexOf('\\') + 1) : ApplicationPath;

            ProcessManager.TryToStopExecutables(executableName);
        }
Beispiel #10
0
 public virtual void CleanUp()
 {
     if (AqualityServices.IsApplicationStarted)
     {
         AqualityServices.Application.Quit();
     }
     AqualityServices.TryToStopAppiumLocalService();
 }
 public void Should_BePossibleTo_PerformActions()
 {
     // website automationpractice.com is out of resources and unable to proceed operations sometimes
     Assert.DoesNotThrow(() =>
     {
         AqualityServices.Get <IActionRetrier>().DoWithRetry(ActionsOnAutomationPractice,
                                                             new[] { typeof(NoSuchElementException), typeof(WebDriverTimeoutException), typeof(AssertionException) });
     }, "Shopping cart actions should actually work");
 }
Beispiel #12
0
 public void CloseApplication()
 {
     if (AqualityServices.IsApplicationStarted)
     {
         AqualityServices.Application.Quit();
         AqualityServices.ProcessManager.TryToStopProcesses(Configuration.Configuration.ProcessName);
     }
     AqualityServices.TryToStopAppiumLocalService();
 }
        public static void DeleteFileIfExist(string filePath)
        {
            var file = new FileInfo(filePath);

            if (file.Exists && !AqualityServices.Get <IBrowserProfile>().IsRemote)
            {
                file.Delete();
            }
        }
Beispiel #14
0
        public void Should_WorkWithCalculator_ViaElementFinder()
        {
            AqualityServices.Get <IElementFinder>().FindElement(calculatorForm.OneButton.Locator).Click();
            AqualityServices.Get <IElementFinder>().FindElement(calculatorForm.PlusButton.Locator).Click();
            AqualityServices.Get <IElementFinder>().FindElement(calculatorForm.TwoButton.Locator).Click();
            AqualityServices.Get <IElementFinder>().FindElement(calculatorForm.EqualsButton.Locator).Click();
            var result = AqualityServices.Get <IElementFinder>().FindElement(calculatorForm.ResultsLabel.Locator).Text;

            StringAssert.Contains("3", result);
        }
        public static void CreateDownloadDirectoryIfNotExist()
        {
            var browserProfile = AqualityServices.Get <IBrowserProfile>();
            var downloadDir    = browserProfile.DriverSettings.DownloadDir;

            if (!Directory.Exists(downloadDir) && !browserProfile.IsRemote)
            {
                Directory.CreateDirectory(downloadDir);
            }
        }
Beispiel #16
0
        public void Should_GetCurrentApplicationFactory_AfterSetDefaultFactory()
        {
            var firstFactory = AqualityServices.Get <IApplicationFactory>();

            AqualityServices.SetDefaultFactory();
            var secondFactory = AqualityServices.Get <IApplicationFactory>();

            Assert.AreNotSame(firstFactory, secondFactory);
            AqualityServices.ApplicationFactory = firstFactory;
            Assert.AreSame(firstFactory, AqualityServices.Get <IApplicationFactory>());
            Assert.AreNotSame(secondFactory, AqualityServices.Get <IApplicationFactory>());
        }
 public static bool IsFileDownloaded(string filePath, ILabel lblFileContent)
 {
     try
     {
         AqualityServices.Browser.GoTo($"file://{filePath}");
         return(lblFileContent.State.IsDisplayed);
     }
     catch (WebDriverException exception)
     {
         AqualityServices.Get <Logger>().Warn(exception.Message);
         return(false);
     }
 }
Beispiel #18
0
        public virtual void CleanUp()
        {
            if (AqualityServices.IsApplicationStarted)
            {
                if (TestContext.CurrentContext.Result.Outcome.Status != TestStatus.Passed)
                {
                    TestContext.AddTestAttachment(new ScreenshotProvider(AqualityServices.Application).TakeScreenshot());
                }

                AqualityServices.Application.Quit();
            }
            AqualityServices.TryToStopAppiumLocalService();
        }
Beispiel #19
0
        public void Should_GetCurrentApplication_AfterQuit()
        {
            var firstApplication = AqualityServices.Application;

            firstApplication.Launch().Quit();
            var secondApplication = AqualityServices.Application.Launch();

            Assert.AreNotSame(firstApplication, secondApplication);
            using (var scope = AqualityServices.Get <IServiceProvider>().CreateScope())
            {
                var secondApplicationFromServiceProvider = scope.ServiceProvider.GetRequiredService <IApplication>();
                Assert.AreNotSame(firstApplication, secondApplicationFromServiceProvider);
                Assert.AreSame(secondApplication, secondApplicationFromServiceProvider);
            }
        }
Beispiel #20
0
        public void RunTest()
        {
            var browser = AqualityServices.Browser;

            browser.Maximize();
            browser.GoTo(Config.Get(ConfigString.BaseUrl));
            browser.WaitForPageToLoad();

            var searchTextBox = AqualityServices.Get <IElementFactory>().GetTextBox(By.Name("search"), "Search");

            searchTextBox.SendKeys("Selenium" + Keys.Enter);
            browser.WaitForPageToLoad();

            var heading = AqualityServices.Get <IElementFactory>().GetLabel(By.Id("firstHeading"), "Heading");

            Assert.AreEqual("Selenium", heading.GetText(), "Heading should be as expected");

            browser.Quit();
        }
        public void Should_BePossibleTo_DownloadTextFile()
        {
            var browser        = AqualityServices.Browser;
            var downloaderForm = new FileDownloaderForm();
            var fileName       = downloaderForm.FileName;
            var filePath       = FileDownloadHelper.GetTargetFilePath(fileName);

            FileDownloadHelper.CreateDownloadDirectoryIfNotExist();
            FileDownloadHelper.DeleteFileIfExist(filePath);

            var lblFileContent = AqualityServices.Get <IElementFactory>().GetLabel(By.XPath("//pre"), "text file content");

            Assert.False(FileDownloadHelper.IsFileDownloaded(filePath, lblFileContent), $"file {filePath} should not exist before downloading");

            browser.ExecuteScriptFromFile("Resources.OpenUrlInNewWindow.js", downloaderForm.Url);
            var tabs = new List <string>(AqualityServices.Browser.Driver.WindowHandles);

            browser.Driver.SwitchTo().Window(tabs[1]);
            downloaderForm.Open();
            downloaderForm.GetDownloadLink(fileName).JsActions.ClickAndWait();
            browser.Driver.SwitchTo().Window(tabs[0]);
            bool condition() => FileDownloadHelper.IsFileDownloaded(filePath, lblFileContent);

            var message = $"file {filePath} was not downloaded";

            try
            {
                AqualityServices.ConditionalWait.WaitForTrue(condition, message: message);
            }
            catch (TimeoutException)
            {
                if (browser.BrowserName == BrowserName.Safari)
                {
                    browser.Quit();
                    AqualityServices.ConditionalWait.WaitForTrue(condition, message: message);
                }
                else
                {
                    throw;
                }
            }
        }
 public void Should_BeAbleGet_DefaultService()
 {
     Assert.AreEqual(DefaultCommandTimeout, AqualityServices.Get <ITimeoutConfiguration>().Command, "Default service value should have default value");
 }
Beispiel #23
0
 public void Should_BeAbleToGet_ServiceProvider()
 {
     Assert.DoesNotThrow(() => AqualityServices.Get <IServiceProvider>(), "ServiceProvider should not be null");
 }
 public static void TearDown()
 {
     AqualityServices.SetStartup(new ApplicationStartup());
 }
Beispiel #25
0
 public void CleanUp()
 {
     Environment.SetEnvironmentVariable("profile", null);
     AqualityServices.SetStartup(new MobileStartup());
 }
Beispiel #26
0
 public void SetUp()
 {
     Environment.SetEnvironmentVariable("profile", "androidwebsession");
     AqualityServices.SetStartup(new MobileStartup());
 }
 public void Should_BePossibleTo_GetIOSScreenViaFactory()
 {
     Environment.SetEnvironmentVariable(PlatformNameVariableName, "ios");
     AqualityServices.SetStartup(new MobileStartup());
     Assert.That(AqualityServices.ScreenFactory.GetScreen <LoginScreen>() is IOSLoginScreen);
 }
        private long GetLongSwipeDuration()
        {
            var swipeDuration = AqualityServices.Get <ITouchActionsSettings>().SwipeDuration;

            return(Convert.ToInt64(swipeDuration.TotalMilliseconds));
        }
 public void Should_ThrowInvalidOperationException_OnNotValidAssemblyNameWithScreensValue()
 {
     Environment.SetEnvironmentVariable(ScreensLocationVariableName, "Aquality.Fake.Assembly.Tests");
     AqualityServices.SetStartup(new MobileStartup());
     Assert.Throws <InvalidOperationException>(() => AqualityServices.ScreenFactory.GetScreen <LoginScreen>());
 }
 public void CleanUp()
 {
     Environment.SetEnvironmentVariable(PlatformNameVariableName, null);
     Environment.SetEnvironmentVariable(ScreensLocationVariableName, "Aquality.Appium.Mobile.Tests");
     AqualityServices.SetStartup(new MobileStartup());
 }