Beispiel #1
0
        static void Main(string[] args)
        {
            try
            {
                var cla = new CommandLineArguments(args);
                if (cla.ErrorMessage != null)
                {
                    Console.Error.WriteLine(cla.GetUsageMessage());
                    Environment.Exit(1);
                }

                var resultsFactory = new TestResultFactory();
                var results        = resultsFactory.CreateResultsFromTestFiles(cla.TestFiles);

                var outputCreator = new ParsedDataOutputter();
                outputCreator.OutputResults(results, cla);
            }
            catch (Exception ex)
            {
                // Handy to put a breakpoint here :-)
                string msg = ex.Message;
                Console.Error.WriteLine(msg);
                Console.Error.WriteLine();
                Console.Error.WriteLine(ex.StackTrace);
                Environment.Exit(1);
            }
        }
Beispiel #2
0
        public void afterTest()
        {
            try
            {
                var status = TestContext.CurrentContext.Result.Outcome.Status.ToString();

                //test success, generates successful reporting
                if (status.Equals("Passed"))
                {
                    reportiumClient.testStop(TestResultFactory.createSuccess());
                }
                //test fail, generates failure repostiung
                else
                {
                    var Message = TestContext.CurrentContext.Result.Message;
                    var trace   = TestContext.CurrentContext.Result.StackTrace;
                    Message = Message + ". Stack Trace:" + trace;
                    reportiumClient.testStop(TestResultFactory.createFailure(Message, null));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }
Beispiel #3
0
        public AssemblyTestDetailedSummary GetDetailSummary(string assemblyFileName)
        {
            var testfiles = Directory.GetFiles(m_testLogFolder, "*.trx");

            var resultsFactory = new TestResultFactory();
            var results        = resultsFactory.CreateResultsFromTestFiles(testfiles);

            var assenblyTestInfo = results.SummaryByAssembly.SummaryLines.FirstOrDefault(s => s.AssemblyFileName == assemblyFileName);

            var classInAssemblyTestSummary =
                results.SummaryByClass.SummaryLines.Where(s => s.AssemblyFileName == assemblyFileName).Select(x => new ClassTestSummary()
            {
                ClassName         = x.ClassName,
                Passed            = x.TotalPassed,
                Failed            = x.TotalTests - x.TotalPassed,
                DurationInSeconds = x.TotalDurationInSecondsHuman,
                PercentagePassed  = x.PercentPassed
            });

            return(new AssemblyTestDetailedSummary()
            {
                AssemblyName = assenblyTestInfo.AssemblyFileName,
                ClassSummaries = classInAssemblyTestSummary
            });
        }
        public TestResultFactory GetTestResultFactory(Mock <IErrorProvider> errorProviderMock = null, Mock <ITestUndefinedMessageFactory> testUndefinedMessageFactoryMock = null)
        {
            var testResultFactory = new TestResultFactory(
                new TestErrorMessageFactory(),
                new TestPendingMessageFactory(errorProviderMock?.Object ?? GetErrorProviderMock().Object),
                new TestAmbiguousMessageFactory(),
                testUndefinedMessageFactoryMock?.Object ?? GetTestUndefinedMessageFactoryMock().Object);

            return(testResultFactory);
        }
 /// <summary>
 /// This function initialises this class(important)
 /// </summary>
 /// <param name="dbCon"></param>
 public void InitClass(DBConnection dbCon)
 {
     this.dbCon          = dbCon;
     medicalNote         = new MedicalNoteFactory(dbCon);
     infoFac             = new PatientFactory(dbCon);
     prescriptionFactory = new PrescriptionFactory(dbCon);
     test = new TestResultFactory(dbCon);
     medicationFactory = new MedicineInFactory(dbCon);
     appointmentClass  = new AppointmentSort(dbCon);
 }
        public void BuildFromContext_FailedScenario_TestResultPartFactoryBuildPassedResultIsCalled()
        {
            // ARRANGE
            var testResultPartsFactoryMock = new Mock <ITestResultPartsFactory>();
            var testResultFactory          = new TestResultFactory(testResultPartsFactoryMock.Object);

            // ACT
            var actualTestResult = testResultFactory.BuildFromContext(CreateScenarioContext(ScenarioExecutionStatus.OK), null);

            // ASSERT
            testResultPartsFactoryMock.Verify(m => m.BuildPassedResult(It.IsAny <ulong>()), Times.Once);
        }
        public void BuildFromContext_PassedScenario_TestResultPartFactoryBuildPassedResultIsCalled(ScenarioExecutionStatus scenarioExecutionStatus, Expression <Action <ITestResultPartsFactory> > expression)
        {
            // ARRANGE
            var testResultPartsFactoryMock = new Mock <ITestResultPartsFactory>();
            var testResultFactory          = new TestResultFactory(testResultPartsFactoryMock.Object);

            // ACT
            var actualTestResult = testResultFactory.BuildFromContext(CreateScenarioContext(scenarioExecutionStatus), null);

            // ASSERT
            testResultPartsFactoryMock.Verify(expression, Times.Once);
        }
        public void BuildFromScenarioContext_Null_ShouldReturnFailureWithArgumentNullException()
        {
            // ARRANGE
            var testResultFactory = new TestResultFactory(new Mock <ITestResultPartsFactory>().Object);

            // ACT
            var actualTestResult = testResultFactory.BuildFromContext(null, null);

            // ASSERT
            actualTestResult.Should().BeAssignableTo <ExceptionFailure>().Which
            .Exception.Should().BeOfType <ArgumentNullException>();
        }
Beispiel #9
0
        public static void afterScenario()
        {
            Exception scenarioExpection = ScenarioContext.Current.TestError;

            if (scenarioExpection == null)
            {
                reportingClient.testStop(TestResultFactory.createSuccess());
            }
            else
            {
                reportingClient.testStop(TestResultFactory.createFailure(scenarioExpection.Message, scenarioExpection));
            }
        }
        public void WebDriverTestMethod()
        {
            Dictionary <String, Object> pars = new Dictionary <String, Object>();

            try
            {
                reportiumClient.testStart("Wikipedia sample", new TestContextTags("sample1", "apples"));

                // write your code here
                reportiumClient.stepStart("Open Wikipedia");
                driver.Navigate().GoToUrl("www.wikipedia.org");
                pars.Clear();
                pars.Add("content", "The Free Encyclopedia");
                pars.Add("timeout", 20);
                String res = (String)driver.ExecuteScript("mobile:checkpoint:text", pars);

                if (!res.ToLower().Equals("true"))
                {
                    reportiumClient.reportiumAssert("homepage loaded", false);
                }
                reportiumClient.stepEnd();

                reportiumClient.stepStart("Looking for term");
                driver.FindElementByXPath("//*[@id='searchInput']").SendKeys("apple");
                System.Threading.Thread.Sleep(2000);

                driver.FindElementByXPath("//*[@class=\"pure-button pure-button-primary-progressive\"]").Click();
                reportiumClient.stepEnd();

                reportiumClient.stepStart("Visual Analysis to verify on right page");
                pars.Clear();
                pars.Add("content", "fruit");
                pars.Add("timeout", 20);
                res = (String)driver.ExecuteScript("mobile:checkpoint:text", pars);
                if (!res.ToLower().Equals("true"))
                {
                    reportiumClient.reportiumAssert("search term loaded", false);
                }
                reportiumClient.stepEnd();

                reportiumClient.testStop(TestResultFactory.createSuccess());
            }
            catch (Exception e)
            {
                reportiumClient.testStop(TestResultFactory.createFailure(e.Message, e));
                Trace.Write(e.StackTrace);
                Trace.WriteLine(" ");
            }
        }
Beispiel #11
0
        //private const string TestResultFolder = @"D:\Temp\TestResults20170301";
        //private const string TestResultFolder = @"..\TestResultsExample";

        public IEnumerable <AssemblyTestSummary> GetAssemblySummary()
        {
            var testfiles = Directory.GetFiles(m_testLogFolder, "*.trx");

            var resultsFactory = new TestResultFactory();
            var results        = resultsFactory.CreateResultsFromTestFiles(testfiles);


            return(results.SummaryByAssembly.SummaryLines.Select(s => new AssemblyTestSummary()
            {
                AssemblyName = s.AssemblyFileName,
                Passed = s.TotalPassed,
                Failed = s.TotalTests - s.TotalPassed,
                DurationInSeconds = s.TotalDurationInSecondsHuman,
                PercentagePassed = s.PercentPassed
            }).OrderByDescending(x => x.Failed));
        }
Beispiel #12
0
        public void WebDriverTestMethod()
        {
            //Write your test here
            reportClient.testStart("User Agent test", new TestContextTags("assignment2", "training"));

            Dictionary <String, Object> pars = new Dictionary <String, Object>();

            try
            {
                reportClient.stepStart("Open the website");
                driver.Navigate().GoToUrl("https://training.perfecto.io");
                pars.Clear();
                pars.Add("content", "Training Website");
                pars.Add("timeout", 20);
                String res = (String)driver.ExecuteScript("mobile:checkpoint:text", pars);

                if (!res.ToLower().Equals("true"))
                {
                    reportClient.reportiumAssert("homepage loaded", false);
                }
                reportClient.stepEnd();

                reportClient.stepStart("navigate to agent page");
                driver.FindElementByXPath("//*[@class=\"mobile-menu\"]").Click();

                pars.Clear();
                pars.Add("label", "Agent");
                pars.Add("timeout", 20);
                driver.ExecuteScript("mobile:button-text:click", pars);

                String result = (String)driver.FindElementByXPath("//*[text()=\"The User Agent\"]").Text;
                Trace.WriteLine(result);

                reportClient.testStop(TestResultFactory.createSuccess());
            }
            catch (Exception e)
            {
                reportClient.testStop(TestResultFactory.createFailure(e.Message, e));
                Trace.Write(e.StackTrace);
                Trace.WriteLine(" ");
            }
        }
Beispiel #13
0
 public void afterTest()
 {
     try
     {
         //test success, generates successful reporting
         if (testContextInstance.CurrentTestOutcome == UnitTestOutcome.Passed)
         {
             reportiumClient.testStop(TestResultFactory.createSuccess());
         }
         //test fail, generates failure repostiung
         else
         {
             reportiumClient.testStop(TestResultFactory.createFailure("Test Failed", null));
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
     }
 }
Beispiel #14
0
        public void WebDriverTestMethod()
        {
            try
            {
                reportiumClient.testStart("My test mame", new TestContextTags("tag2", "tag3"));

                // write your code here

                // reportiumClient.testStep("step1"); // this is a logical step for reporting
                // add commands...
                // reportiumClient.testStep("step2");
                // add commands...

                reportiumClient.testStop(TestResultFactory.createSuccess());
            }
            catch (Exception e)
            {
                reportiumClient.testStop(TestResultFactory.createFailure(e.Message, e));
            }
        }
Beispiel #15
0
        public TestSummary GetTestSummary()
        {
            var testfiles = Directory.GetFiles(m_testLogFolder, "*.trx");

            var resultsFactory = new TestResultFactory();
            var results        = resultsFactory.CreateResultsFromTestFiles(testfiles);


            return(new TestSummary()
            {
                TotalPassed = results.SummaryByAssembly.TotalPassed,
                TotalTests = results.SummaryByAssembly.TotalTests,
                PercentagePassed = results.SummaryByAssembly.PercentPassed,
                TotalDuration = results.SummaryByAssembly.TotalDurationInSecondsHuman,
                SlowestTest = results.SlowestTests.Select(x => new TestWithTime()
                {
                    Name = x.TestName,
                    Duration = x.DurationHuman
                })
            });
        }
        private TestResultsViewModel GetTestResults(string trxPath)
        {
            var resultsFactory = new TestResultFactory();

            var parsedResults = resultsFactory.CreateResultsFromTestFiles(new List <string>()
            {
                trxPath
            });

            return(new TestResultsViewModel()
            {
                FailedTestCount = parsedResults.ResultLines.Count(rl => rl.Outcome == "Failed"),
                NotExecutedTestCount = parsedResults.ResultLines.Count(rl => rl.Outcome == "NotExecuted"),
                PassedTestCount = parsedResults.ResultLines.Count(rl => rl.Outcome == "Passed"),
                FailedTests = parsedResults.ResultLines.SortedByFailedOtherPassed.TakeWhile(t => t.Outcome == "Failed").Select(t => new TestResultViewModel()
                {
                    TestName = t.TestName,
                    ErrorMessage = t.ErrorMessage,
                    StackTrace = t.StackTrace
                }).ToList()
            });
        }
Beispiel #17
0
        public void AndroidTest()
        {
            DesiredCapabilities capabilities = new DesiredCapabilities();

            // 1. Replace <<cloud name>> with your perfecto cloud name (e.g. demo is the cloudName of demo.perfectomobile.com).
            String cloudName = "<<cloud name>>";

            // 2. Replace <<security token>> with your perfecto security token.
            String securityToken = "<<security token>>";

            capabilities.SetCapability("securityToken", securityToken);

            // 3. Set web capabilities.
            capabilities.SetCapability("platformName", "Android");
            capabilities.SetCapability("model", "Galaxy S.*");
            capabilities.SetCapability("browserName", "Chrome");
            capabilities.SetCapability("useAppiumForWeb", true);
            capabilities.SetCapability("openDeviceTimeout", 5);


            // Initialize the  driver
            RemoteWebDriver driver = new RemoteWebDriver(
                new Uri("https://" + cloudName.Replace(".perfectomobile.com", "")
                        + ".perfectomobile.com/nexperience/perfectomobile/wd/hub"),
                capabilities);

            // Setting implicit wait
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);

            PerfectoExecutionContext perfectoExecutionContext;

            if (System.Environment.GetEnvironmentVariable("jobName") != null)
            {
                perfectoExecutionContext = new PerfectoExecutionContext.PerfectoExecutionContextBuilder()
                                           .WithProject(new Project("My Project", "1.0"))
                                           .WithJob(new Job(System.Environment.GetEnvironmentVariable("jobName"),
                                                            int.Parse(System.Environment.GetEnvironmentVariable("jobNumber"))))
                                           .WithWebDriver(driver).Build();
            }
            else
            {
                perfectoExecutionContext = new PerfectoExecutionContext.PerfectoExecutionContextBuilder()
                                           .WithProject(new Project("My Project", "1.0"))
                                           .WithWebDriver(driver).Build();
            }
            ReportiumClient reportiumClient = PerfectoClientFactory.CreatePerfectoReportiumClient(perfectoExecutionContext);

            reportiumClient.TestStart("Selenium C# Android Sample", new Reportium.Test.TestContext("selenium", "android"));

            try
            {
                WebDriverWait wait   = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
                String        search = "perfectomobile";
                reportiumClient.StepStart("Navigate to Google");
                Dictionary <String, Object> pars = new Dictionary <String, Object>();
                driver.Url = "https://www.google.com";
                reportiumClient.StepEnd();

                reportiumClient.StepStart("Search for Perfecto");
                IWebElement searchbox = wait.Until(ExpectedConditions.ElementToBeClickable(driver.FindElement(By.XPath("//*[@name='q']"))));
                searchbox.SendKeys(search);
                searchbox.SendKeys(Keys.Enter);
                reportiumClient.StepEnd();

                reportiumClient.StepStart("Verify Title");
                String expectedText = "perfectomobile - Google Search";
                Console.WriteLine(driver.Title);
                // Adding assertions to the Execution Report. This method will not fail the test
                reportiumClient.ReportiumAssert(expectedText, driver.Title.Contains(expectedText));
                reportiumClient.StepEnd();

                reportiumClient.TestStop(TestResultFactory.CreateSuccess());
            }
            catch (Exception e)
            {
                reportiumClient.TestStop(TestResultFactory.CreateFailure(e));
            }

            // Prints the Smart Reporting URL
            String reportURL = reportiumClient.GetReportUrl();

            Console.WriteLine("Report url - " + reportURL);

            // Quits the driver
            driver.Quit();
        }
Beispiel #18
0
        public void AppiumTestMethod()
        {
            Dictionary <String, Object> pars = new Dictionary <String, Object>();
            String res;

            try
            {
                reportiumClient.testStart("Image Injection Assignment", new TestContextTags("assignment4", "image"));

                // write your code here

                reportiumClient.stepStart("Start the app and upload the image");

                try
                {
                    // close the calendar if open to verify that starting from fresh app
                    pars.Add("name", "RealTimeFilter");
                    driver.ExecuteScript("mobile:application:close", pars);
                }
                catch (Exception e)
                {
                    Trace.Write(e.StackTrace);
                    Trace.WriteLine(" ");
                }
                try
                {
                    pars.Clear();
                    pars.Add("name", "RealTimeFilter");
                    driver.ExecuteScript("mobile:application:open", pars);
                }
                catch (Exception e)
                {
                    // unable to start the app, probably because it isn't installed
                    pars.Clear();
                    pars.Add("file", "PUBLIC:ImageInjection\\RealTimeFilter.ipa");
                    pars.Add("sensorInstrument", "sensor");
                    driver.ExecuteScript("mobile:application:install", pars);

                    pars.Clear();
                    pars.Add("name", "RealTimeFilter");
                    driver.ExecuteScript("mobile:application:open", pars);
                }

                driver.Context = "NATIVE_APP";
                reportiumClient.stepEnd();

                reportiumClient.stepStart("inject the image");

                pars.Clear();
                pars.Add("repositoryFile", "PRIVATE:perfectoL.png");
                pars.Add("identifier", "Victor.RealTimeFilter");
                driver.ExecuteScript("mobile:image.injection:start", pars);
                reportiumClient.stepEnd();

                reportiumClient.stepStart("dismiss popup if it appears");
                // rotate the image (device) to show in landscape
                pars.Clear();
                pars.Add("content", "Access the Camera");
                pars.Add("timeout", 20);
                res = (String)driver.ExecuteScript("mobile:checkpoint:text", pars);

                if (res.ToLower().Equals("true"))
                {
                    pars.Clear();
                    pars.Add("label", "OK");
                    pars.Add("timeout", 10);

                    res = (String)driver.ExecuteScript("mobile:button-text:click", pars);
                }
                reportiumClient.stepEnd();

                reportiumClient.stepStart("verify the image is displayed");
                // rotate the image (device) to show in landscape
                pars.Clear();
                pars.Add("state", "landscape");
                driver.ExecuteScript("mobile:device:rotate", pars);

                pars.Clear();
                pars.Add("content", "Perfection");
                pars.Add("timeout", 20);

                res = (String)driver.ExecuteScript("mobile:checkpoint:text", pars);

                if (res.ToLower().Equals("true"))
                {
                    reportiumClient.testStop(TestResultFactory.createSuccess());
                }
                else
                {
                    pars.Clear();
                    pars.Add("tail", 50);
                    String logStr = (String)driver.ExecuteScript("mobile:device:log", pars);
                    reportiumClient.reportiumAssert("Failed to view image", false);
                    reportiumClient.testStop(TestResultFactory.createFailure("Failed to view image", null));
                }
            }
            catch (Exception e)
            {
                reportiumClient.testStop(TestResultFactory.createFailure(e.Message, e));
            }
        }
Beispiel #19
0
        public void AppiumTestMethod()
        {
            //Write your test here
            // Notify Reporting Server that test is starting
            reportClient.testStart("Wikipedia assignment", new TestContextTags("assignment1", "apple entry"));

            Dictionary <String, Object> pars = new Dictionary <String, Object>();

            try
            {
                reportClient.stepStart("Open YouTube");
                try
                {
                    // close the calendar if open to verify that starting from fresh app
                    pars.Add("name", "YouTube");
                    driver.ExecuteScript("mobile:application:close", pars);
                }
                catch (Exception e)
                {
                    Trace.Write(e.StackTrace);
                    Trace.WriteLine(" ");
                }
                pars.Clear();
                pars.Add("name", "YouTube");
                driver.ExecuteScript("mobile:application:open", pars);
                driver.Context = "NATIVE_APP";

                reportClient.stepEnd();

                reportClient.stepStart("Adjust Volume");
                MaxVolume(driver);
                reportClient.stepEnd();

                reportClient.stepStart("Activate the audio search");
                driver.FindElementByXPath("//*[@content-desc=\"Search\"]").Click();
                driver.FindElementByXPath("//*[@resource-id=\"com.google.android.youtube:id/voice_search\"]").Click();
                reportClient.stepEnd();

                reportClient.stepStart("Play name for audio search");
                // Create audio file from String
                String key = "PRIVATE:mysong.wav";
                pars.Clear();
                pars.Add("text", "Metallica Master of Puppets");
                pars.Add("repositoryFile", key);
                driver.ExecuteScript("mobile:text:audio", pars);
                // inject Audio to device
                pars.Clear();
                pars.Add("key", key);
                pars.Add("wait", "wait");
                driver.ExecuteScript("mobile:audio:inject", pars);
                reportClient.stepEnd();

                reportClient.stepStart("Play the music clip and validate");
                driver.FindElementByXPath("//*[@content-desc=\"Play album\"]").Click();

                pars.Clear();
                pars.Add("timeout", 30);
                pars.Add("duration", 1);
                String audioR = (String)driver.ExecuteScript("mobile:checkpoint:audio", pars);
                reportClient.stepEnd();

                reportClient.stepStart("Close the app");
                // inject Audio to device
                pars.Clear();
                pars.Add("name", "YouTube");
                driver.ExecuteScript("mobile:application:close", pars);
                reportClient.stepEnd();

                if (audioR.ToLower().Equals("true"))
                {
                    reportClient.reportiumAssert("Audio is playing", true);
                    reportClient.testStop(TestResultFactory.createSuccess());
                }
                else
                {
                    reportClient.reportiumAssert("Audio failed", false);
                    reportClient.testStop(TestResultFactory.createFailure("Audio failed", null));
                }
            }
            catch (Exception e)
            {
                reportClient.testStop(TestResultFactory.createFailure(e.Message, e));
                Trace.Write(e.StackTrace);
                Trace.WriteLine(" ");
            }
        }
        public void WebDriverTestMethod()
        {
            try
            {
                reportiumClient.testStart("Location assignment", new TestContextTags("assignment2", "location"));
                Dictionary <String, Object> pars = new Dictionary <String, Object>();
                String res;
                IJavaScriptExecutor jse = (IJavaScriptExecutor)driver;

                // write your code here

                reportiumClient.stepStart("navigate to web page");
                driver.Navigate().GoToUrl("https://training.perfecto.io");

                // Verification of website is dependent on the environment
                // Branching needed as desktop does not support image analysis
                if (os.ToLower().Equals("windows"))
                {
                    pars.Clear();
                    pars.Add("content", "taking the first step");
                    pars.Add("timeout", 20);
                    res = (String)driver.ExecuteScript("mobile:checkpoint:text", pars);
                }
                else
                {
                    pars.Clear();
                    pars.Add("content", "PRIVATE:trainingHomepage.png");                     //remember, this image needs to be created!
                    pars.Add("timeout", 30);
                    Object result1 = driver.ExecuteScript("mobile:checkpoint:image", pars);

                    // clicking on hamburger icon, required only for mobile
                    driver.FindElementByXPath("//*[@class=\"mobile-menu\"]").Click();
                }
                reportiumClient.stepEnd();

                reportiumClient.stepStart("location page");
                pars.Clear();
                pars.Add("label", "location");
                pars.Add("timeout", 20);
                res = (String)driver.ExecuteScript("mobile:button-text:click", pars);

                // The location page SOMETIMES asks for approval to share location, in a popup. We need to click allow to approve
                try
                {
                    pars.Clear();
                    pars.Add("label", "Allow location");
                    pars.Add("timeout", 20);
                    res = (String)driver.ExecuteScript("mobile:button-text:click", pars);
                }
                catch (Exception e)
                {
                    // if not found then just print a note and continue
                    Trace.WriteLine("Popup to allow location not displayed");
                }

                reportiumClient.stepStart("Visual Analysis to verify on right page");
                pars.Clear();
                pars.Add("content", "peek");
                pars.Add("timeout", 20);
                res = (String)driver.ExecuteScript("mobile:checkpoint:text", pars);

                if (os.ToLower().Equals("android"))
                {
                    pars.Clear();
                    pars.Add("content", "you are within");
                    pars.Add("scrolling", "scroll");
                    res = (String)driver.ExecuteScript("mobile:checkpoint:text", pars);
                }
                else
                {
                    for (int i = 0; i < 5; i++)
                    {
                        pars.Clear();
                        pars.Add("content", "You are within");
                        pars.Add("timeout", 10);
                        res = (String)driver.ExecuteScript("mobile:checkpoint:text", pars);

                        if (res.ToLower().Equals("false"))
                        {
                            // scroll down
                            jse.ExecuteScript("window.scrollBy(0, 200)");
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                reportiumClient.stepEnd();

                if (res.ToLower().Equals("true"))
                {
                    reportiumClient.testStop(TestResultFactory.createSuccess());
                }
                else
                {
                    reportiumClient.testStop(TestResultFactory.createFailure("test failed", null));
                }
            }
            catch (Exception e)
            {
                reportiumClient.testStop(TestResultFactory.createFailure(e.Message, e));
                Trace.Write(e.StackTrace);
                Trace.WriteLine(" ");
            }
        }
        public void AppiumTestMethod()
        {
            try
            {
                reportiumClient.testStart("Calendar assignment", new TestContextTags("assignment3", "calendarApp"));

                // write your code here

                reportiumClient.stepStart("Open the Calendar app");
                Dictionary <String, Object> pars = new Dictionary <String, Object>();
                try
                {
                    // close the calendar if open to verify that starting from fresh app
                    pars.Add("name", "Calendar");
                    driver.ExecuteScript("mobile:application:close", pars);
                }
                catch (Exception e)
                {
                    Trace.Write(e.StackTrace);
                    Trace.WriteLine(" ");
                }
                pars.Clear();
                pars.Add("name", "Calendar");
                driver.ExecuteScript("mobile:application:open", pars);
                reportiumClient.stepEnd();

                // Check for What's New Screen and dismiss
                reportiumClient.stepStart("Dismiss popup");
                pars.Clear();
                pars.Add("content", "What's New");
                pars.Add("timeout", 10);
                String result = (String)driver.ExecuteScript("mobile:checkpoint:text", pars);
                if (result.ToLower().Equals("true"))
                {
                    pars.Clear();
                    pars.Add("label", "Continue");
                    pars.Add("threshold", 80);
                    pars.Add("ignorecase", "nocase");
                    driver.ExecuteScript("mobile:button-text:click", pars);
                }
                pars.Clear();
                pars.Add("content", "Access");
                pars.Add("timeout", 10);
                result = (String)driver.ExecuteScript("mobile:checkpoint:text", pars);
                if (result.ToLower().Equals("true"))
                {
                    pars.Clear();
                    pars.Add("label", "Don't Allow");
                    pars.Add("threshold", 80);
                    pars.Add("ignorecase", "nocase");
                    driver.ExecuteScript("mobile:button-text:click", pars);
                }
                reportiumClient.stepEnd();

                // Go to add the event screen
                reportiumClient.stepStart("Open the event add screen");
                driver.Context = "NATIVE_APP";
                driver.FindElementByName("Add").Click();

                // use a checkpoint to visually check that we are on the correct screen
                pars.Clear();
                pars.Add("content", "new event");
                pars.Add("timeout", 20);
                result = (String)driver.ExecuteScript("mobile:checkpoint:text", pars);

                reportiumClient.stepEnd();

                reportiumClient.stepStart("Add location & title");
                IWebElement inField = driver.FindElementsByClassName("XCUIElementTypeTextField").ElementAt(1);
                inField.SendKeys("fun day");
                System.Threading.Thread.Sleep(2000);
                inField = driver.FindElementByName("Location");
                inField.SendKeys("London");
                driver.FindElementByName("Done").Click();

                reportiumClient.stepEnd();

                reportiumClient.stepStart("Set start time");
                driver.FindElementByName("Starts").Click();
                System.Threading.Thread.Sleep(1000);
                IWebElement hour = driver.FindElementsByClassName("XCUIElementTypePickerWheel").ElementAt(1);
                String      hr   = hour.GetAttribute("value");
                hour.SendKeys("9");
                IWebElement mins = driver.FindElementsByClassName("XCUIElementTypePickerWheel").ElementAt(2);
                String      min  = mins.GetAttribute("value");
                mins.SendKeys("45");
                Trace.WriteLine("old time: " + hr + ':' + min);
                hr  = hour.GetAttribute("value");
                min = mins.GetAttribute("value");
                Trace.WriteLine("new time: " + hr + ':' + min);
                reportiumClient.stepEnd();

                reportiumClient.stepStart("Set End Time");
                driver.FindElementByName("Ends").Click();
                System.Threading.Thread.Sleep(2000);
                hour = driver.FindElementsByClassName("XCUIElementTypePickerWheel").ElementAt(1);
                hr   = hour.GetAttribute("value");
                hour.SendKeys("11");
                mins = driver.FindElementsByClassName("XCUIElementTypePickerWheel").ElementAt(2);
                min  = mins.GetAttribute("value");
                mins.SendKeys("15");
                Trace.WriteLine("old end time: " + hr + ':' + min);
                hr  = hour.GetAttribute("value");
                min = mins.GetAttribute("value");
                Trace.WriteLine("new end time: " + hr + ':' + min);
                driver.FindElementByName("Ends").Click();
                reportiumClient.stepEnd();

                reportiumClient.stepStart("Recurring Event");
                driver.FindElementByName("Repeat").Click();
                driver.FindElementByName("Every Month").Click();
                driver.FindElementByName("End Repeat").Click();
                driver.FindElementByName("On Date").Click();
                System.Threading.Thread.Sleep(3000);
                IWebElement month    = driver.FindElementsByClassName("XCUIElementTypePickerWheel").ElementAt(0);
                String      endMonth = month.GetAttribute("value");
                month.SendKeys("December");
                IWebElement day     = driver.FindElementsByClassName("XCUIElementTypePickerWheel").ElementAt(1);
                String      endDate = day.GetAttribute("value");
                day.SendKeys("5");
                IWebElement year    = driver.FindElementsByClassName("XCUIElementTypePickerWheel").ElementAt(2);
                String      endYear = year.GetAttribute("value");
                year.SendKeys("2020");
                Trace.WriteLine("old end date: " + endMonth + ' ' + endDate + ", " + endYear);
                endMonth = month.GetAttribute("value");
                endDate  = day.GetAttribute("value");
                endYear  = year.GetAttribute("value");
                Trace.WriteLine("new end date: " + endMonth + ' ' + endDate + ", " + endYear);

                // go back to Event definition screen
                driver.FindElementByName("New Event").Click();
                reportiumClient.stepEnd();

                reportiumClient.stepStart("Add Travel time");
                driver.FindElementByName("Travel Time").Click();
                IWebElement travelToggle = driver.FindElementsByClassName("XCUIElementTypeSwitch").ElementAt(0);
                travelToggle.Click();
                driver.FindElementByName("2 hours").Click();
                // go back to Event definition screen
                driver.FindElementByName("New Event").Click();

                reportiumClient.stepEnd();

                reportiumClient.stepStart("Close application");
                pars.Clear();
                pars.Add("name", "Calendar");
                driver.ExecuteScript("mobile:application:close", pars);

                reportiumClient.stepEnd();
                reportiumClient.testStop(TestResultFactory.createSuccess());
            }
            catch (Exception e)
            {
                reportiumClient.testStop(TestResultFactory.createFailure(e.Message, e));
                Trace.Write(e.StackTrace);
                Trace.WriteLine(" ");
            }
        }