Пример #1
0
        public void SavePageSourceNoExistingDirectory()
        {
            string pageSourcePath = AppiumUtilities.SavePageSource(this.AppiumDriver, this.TestObject, "TempTestDirectory", "SavePSNoDir");

            Assert.IsTrue(File.Exists(pageSourcePath), "Fail to find Page Source");
            File.Delete(pageSourcePath);
        }
Пример #2
0
        public void SavedPageSourceTestObjectAssociation()
        {
            string pageSourcePath = AppiumUtilities.SavePageSource(this.AppiumDriver, this.TestObject, "TempTestDirectory", "TestObjAssoc");

            Assert.IsTrue(this.TestObject.ContainsAssociatedFile(pageSourcePath), "Failed to find page source");
            File.Delete(pageSourcePath);
        }
        public void IntializeTest()
        {
            AppiumUtilities au = new AppiumUtilities();

            AndroidContext = au.InitializeAndrioidApp();
            ScenarioContext.Current["andriotContext"] = AndroidContext;
        }
Пример #4
0
        public void CaptureScreenshotTest()
        {
            AppiumUtilities.CaptureScreenshot(this.TestObject.AppiumDriver, this.TestObject);
            string filePath = Path.ChangeExtension(((FileLogger)this.Log).FilePath, ".png");

            Assert.IsTrue(File.Exists(filePath), "Fail to find screenshot");
            File.Delete(filePath);
        }
Пример #5
0
        public void SavePageSourceNoExistingDirectoryDeprecated()
        {
#pragma warning disable CS0618 // Type or member is obsolete
            string pageSourcePath = AppiumUtilities.SavePageSource(this.AppiumDriver, "TempTestDirectory", "OldSavePSNoDir");
#pragma warning restore CS0618 // Type or member is obsolete
            Assert.IsTrue(File.Exists(pageSourcePath), "Fail to find Page Source");
            File.Delete(pageSourcePath);
        }
Пример #6
0
        public void CaptureScreenshotTestObjectAssociation()
        {
            AppiumUtilities.CaptureScreenshot(this.TestObject.AppiumDriver, this.TestObject);
            string filePath = Path.ChangeExtension(((FileLogger)this.Log).FilePath, ".Png");

            Assert.IsTrue(this.TestObject.ContainsAssociatedFile(filePath), "Failed to find screenshot");
            File.Delete(filePath);
        }
Пример #7
0
        public void SavePageSourceTest()
        {
            AppiumUtilities.SavePageSource(this.TestObject.AppiumDriver, this.TestObject);
            string logLocation            = ((FileLogger)this.Log).FilePath;
            string pageSourceFilelocation = $"{logLocation.Substring(0, logLocation.LastIndexOf('.'))}_PS.txt";

            Assert.IsTrue(File.Exists(pageSourceFilelocation), "Failed to find page source");
            File.Delete(pageSourceFilelocation);
        }
Пример #8
0
        public void CaptureScreenshotTestDeprecated()
        {
#pragma warning disable CS0618 // Type or member is obsolete
            AppiumUtilities.CaptureScreenshot(this.TestObject.AppiumDriver, this.Log);
#pragma warning restore CS0618 // Type or member is obsolete
            string filePath = Path.ChangeExtension(((FileLogger)this.Log).FilePath, ".png");
            Assert.IsTrue(File.Exists(filePath), "Fail to find screenshot");
            File.Delete(filePath);
        }
Пример #9
0
        public void SavePageSourceThrownException()
        {
            FileLogger tempLogger = new FileLogger();

            tempLogger.FilePath = "<>"; // illegal file path
            this.TestObject.Log = tempLogger;
            bool successfullyCaptured = AppiumUtilities.SavePageSource(this.AppiumDriver, this.TestObject);

            Assert.IsFalse(successfullyCaptured);
        }
Пример #10
0
        public void SavePageSourceThrownExceptionDeprecated()
        {
            FileLogger tempLogger = new FileLogger();

            tempLogger.FilePath = "<>"; // illegal file path
#pragma warning disable CS0618          // Type or member is obsolete
            bool successfullyCaptured = AppiumUtilities.SavePageSource(this.AppiumDriver, tempLogger);
#pragma warning restore CS0618          // Type or member is obsolete

            Assert.IsFalse(successfullyCaptured);
        }
Пример #11
0
        public void SavePageSourceTestDeprecated()
        {
#pragma warning disable CS0618 // Type or member is obsolete
            AppiumUtilities.SavePageSource(this.TestObject.AppiumDriver, this.Log);
#pragma warning restore CS0618 // Type or member is obsolete
            string logLocation            = ((FileLogger)this.Log).FilePath;
            string pageSourceFilelocation = logLocation.Substring(0, logLocation.LastIndexOf('.')) + "_PS.txt";

            Assert.IsTrue(File.Exists(pageSourceFilelocation), "Failed to find page source");
            File.Delete(pageSourceFilelocation);
        }
Пример #12
0
        public void CaptureScreenshotThrownException()
        {
            FileLogger tempLogger = new FileLogger
            {
                FilePath = "\\<>/" // illegal file path
            };

            this.TestObject.Log = tempLogger;
            bool successfullyCaptured = AppiumUtilities.CaptureScreenshot(this.TestObject.AppiumDriver, this.TestObject);

            Assert.IsFalse(successfullyCaptured);
        }
Пример #13
0
        public void CaptureScreenshotThrownExceptionDeprecated()
        {
            FileLogger tempLogger = new FileLogger
            {
                FilePath = "<>" // illegal file path
            };

#pragma warning disable CS0618 // Type or member is obsolete
            bool successfullyCaptured = AppiumUtilities.CaptureScreenshot(TestObject.AppiumDriver, tempLogger);
#pragma warning restore CS0618 // Type or member is obsolete
            Assert.IsFalse(successfullyCaptured);
        }
Пример #14
0
        public void CaptureScreenshotWithConsoleLoggerTest()
        {
            // Create a console logger and calculate the file location
            ConsoleLogger consoleLogger = new ConsoleLogger();

            this.TestObject.Log = consoleLogger;

            // Take a screenshot
            bool success = AppiumUtilities.CaptureScreenshot(this.TestObject.AppiumDriver, this.TestObject, "Delete");

            // Make sure we didn't take the screenshot
            Assert.IsFalse(success, "Screenshot taken with console logger");
        }
Пример #15
0
        public void CaptureScreenshotWithConsoleLoggerTestDeprecated()
        {
            // Create a console logger and calculate the file location
            ConsoleLogger consoleLogger = new ConsoleLogger();

            // Take a screenshot
#pragma warning disable CS0618 // Type or member is obsolete
            bool success = AppiumUtilities.CaptureScreenshot(TestObject.AppiumDriver, consoleLogger, "Delete");
#pragma warning restore CS0618 // Type or member is obsolete

            // Make sure we didn't take the screenshot
            Assert.IsFalse(success, "Screenshot taken with console logger");
        }
Пример #16
0
        public void GetWaitDriverTest()
        {
            AppiumDriver <IWebElement> driver = AppiumDriverFactory.GetDefaultMobileDriver();
            WebDriverWait wait = AppiumUtilities.GetDefaultWaitDriver(driver);

            try
            {
                Assert.IsNotNull(wait);
            }
            finally
            {
                driver.Quit();
                driver.Dispose();
            }
        }
Пример #17
0
        public void CapturePageSourceWithConsoleLoggerTest()
        {
            string name = Guid.NewGuid().ToString();
            string path = Path.Combine(Path.GetDirectoryName((this.Log as FileLogger).FilePath), $"PageSource{name}.txt");

            // Create a console logger and calculate the file location
            ConsoleLogger consoleLogger = new ConsoleLogger();

            this.TestObject.Log = consoleLogger;

            // Capture page source
            bool success = AppiumUtilities.SavePageSource(this.TestObject.AppiumDriver, this.TestObject, name);

            // Make sure we can save the page source
            Assert.IsTrue(success, "Page source file should have been saved");
            Assert.IsTrue(File.Exists(path));
        }
Пример #18
0
        public void CleanUp()
        {
            var end = jsonFile("platfromOS");

            switch (end)
            {
            case "android":
                AppiumUtilities.CloseMobileApp();
                break;

            case "ios":
                AppiumUtilities.CloseMobileApp();
                break;

            case "chrome":
                driver.Quit();
                break;

            default:
                break;
            }

            ExtentClose();
        }