Example #1
0
        public TestResultSummaryViewModel(TestResultSummary summary, PipelineConfiguration pipelineConfiguration, bool includeOthersInTotal)
        {
            PassedTests = 0;
            FailedTests = 0;

            if (summary.AggregatedResultsAnalysis.ResultsByOutcome.ContainsKey(TestOutcome.Passed))
            {
                PassedTests = summary.AggregatedResultsAnalysis.ResultsByOutcome[TestOutcome.Passed].Count;
            }
            if (summary.AggregatedResultsAnalysis.ResultsByOutcome.ContainsKey(TestOutcome.Failed))
            {
                FailedTests = summary.AggregatedResultsAnalysis.ResultsByOutcome[TestOutcome.Failed].Count;
            }

            TotalTests = summary.AggregatedResultsAnalysis.TotalTests;
            OtherTests = TotalTests - PassedTests - FailedTests;

            if (!includeOthersInTotal)
            {
                TotalTests -= OtherTests;
            }

            PassingRate = TestResultsHelper.GetTestOutcomePercentageString(PassedTests, TotalTests);
            Duration    = TimeSpanFormatter.FormatDurationWithUnit(summary.AggregatedResultsAnalysis.Duration);
            Url         = pipelineConfiguration.TestTabLink;
        }
        private void Run()
        {
            // Create a new webdriver
            IWebDriver webDriver = new ChromeDriver();

            // Navigate to the url we want to test
            webDriver.Url = "https://demo.applitools.com";

            // ⭐️ Note to see visual bugs, run the test using the above URL for the 1st run.
            //but then change the above URL to https://demo.applitools.com/index_v2.html (for the 2nd run)

            // Create a runner with concurrency of 10
            VisualGridRunner runner = new VisualGridRunner(10);

            // Create Eyes object with the runner, meaning it'll be a Visual Grid eyes.
            Eyes eyes = new Eyes(runner);

            // Create configuration object
            Configuration conf = new Configuration();



            //conf.SetApiKey("APPLITOOLS_API_KEY");    // Set the Applitools API KEY here or as an environment variable "APPLITOOLS_API_KEY"
            conf.SetTestName("C# VisualGrid demo")   // Set test name
            .SetAppName("Demo app");                 // Set app name

            // Add browsers with different viewports
            conf.AddBrowser(800, 600, BrowserType.CHROME);
            conf.AddBrowser(700, 500, BrowserType.FIREFOX);
            conf.AddBrowser(1200, 800, BrowserType.IE_10);
            conf.AddBrowser(1600, 1200, BrowserType.IE_11);
            conf.AddBrowser(1024, 768, BrowserType.EDGE);

            // Add iPhone 4 device emulation in Portrait mode
            conf.AddDeviceEmulation(DeviceName.iPhone_4, ScreenOrientation.Portrait);


            // Set the configuration object to eyes
            eyes.SetConfiguration(conf);

            // Call Open on eyes to initialize a test session
            eyes.Open(webDriver);

            // check the login page
            eyes.Check(Target.Window().Fully().WithName("Login page"));
            webDriver.FindElement(By.Id("log-in")).Click();

            // Check the app page
            eyes.Check(Target.Window().Fully().WithName("App page"));

            // Close the browser
            webDriver.Quit();

            eyes.CloseAsync();

            //Wait and collect all test results
            TestResultSummary allTestResults = runner.GetAllTestResults();

            System.Console.WriteLine(allTestResults);
        }
Example #3
0
        public void AfterEach()
        {
            // Close the browser.
            driver.Quit();

            // If the test was aborted before eyes.close was called, ends the test as aborted.
            eyes.AbortIfNotClosed();

            //Wait and collect all test results
            TestResultSummary allTestResults = runner.GetAllTestResults();
        }
Example #4
0
        private void RunVisualGridDemo()
        {
            // Create a runner with concurrency of 10
            VisualGridRunner runner = new VisualGridRunner(10);

            // Create a file logger with default file ('eyes.log', verbose, in current directory).
            FileLogHandler logHandler = new FileLogHandler();

            // Set the log handler.
            runner.SetLogHandler(logHandler);

            // Create Eyes object with the runner, meaning it'll be a Visual Grid eyes.
            Eyes eyes = new Eyes(runner);

            // Create Selenium Configuration.
            Configuration sconf = new Configuration();

            // Set app name
            sconf.AppName = "Visual Grid Demo App";

            // Set test name
            sconf.TestName = "Visual Grid Demo Test";

            // Add browsers
            sconf.AddBrowser(800, 600, Configuration.BrowserType.CHROME);
            sconf.AddBrowser(700, 500, Configuration.BrowserType.FIREFOX);
            sconf.AddBrowser(1200, 800, Configuration.BrowserType.IE10);
            sconf.AddBrowser(1200, 800, Configuration.BrowserType.IE11);
            sconf.AddBrowser(1600, 1200, Configuration.BrowserType.EDGE);

            // Add iPhone 4 device emulation
            EmulationInfo iphone4 = new EmulationInfo(EmulationInfo.DeviceNameEnum.iPhone_4, ScreenOrientation.Portrait);

            sconf.AddDeviceEmulation(iphone4);

            // Add custom mobile device emulation
            EmulationDevice customMobile = new EmulationDevice(width: 1024, height: 768, deviceScaleFactor: 2);

            sconf.AddDeviceEmulation(customMobile);

            sconf.AddDeviceEmulation(EmulationInfo.DeviceNameEnum.iPhone_5SE, ScreenOrientation.Landscape);
            sconf.AddDeviceEmulation(EmulationInfo.DeviceNameEnum.Galaxy_S5);

            sconf.AddDeviceEmulation(800, 640);

            RunTest(eyes, sconf);

            TestResultSummary allTestResults = runner.GetAllTestResults();
        }
Example #5
0
 private static int GetFailureCountFromSummary(TestResultSummary testResultSummary)
 {
     return((testResultSummary.AggregatedResultsAnalysis.ResultsByOutcome.ContainsKey(TestOutcome.Failed))
         ? testResultSummary.AggregatedResultsAnalysis.ResultsByOutcome[TestOutcome.Failed].Count : 0);
 }