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);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: relanr/ApplitoolsHackathon
        public static void SetUp(Eyes eyes)
        {
            // Initialize eyes Configuration
            Configuration config = new Configuration();

            config.SetApiKey("3xHYsqXjxBhhuNRDcDpQHcaMaUgYU111MBD0fXq5QNxMo110");

            config.SetBatch(new BatchInfo("Holiday Shopping"));
            config.SetViewportSize(1200, 800);
            config.AddBrowser(1200, 800, BrowserType.CHROME);
            config.AddBrowser(1200, 800, BrowserType.FIREFOX);
            config.AddBrowser(1200, 800, BrowserType.EDGE_CHROMIUM);
            config.AddBrowser(1200, 800, BrowserType.SAFARI);
            config.AddDeviceEmulation(DeviceName.iPhone_X);
            eyes.SetConfiguration(config);
            eyes.ForceFullPageScreenshot = true;
            eyes.StitchMode = StitchModes.CSS;
        }
コード例 #3
0
        public void Initialize()
        {
            //Initialize the Runner for your test.
            runner = new VisualGridRunner(10);

            // Initialize the eyes SDK (IMPORTANT: make sure your API key is set in the APPLITOOLS_API_KEY env variable).
            _eyes = new Eyes(runner);


            // Initialize eyes Configuration
            config = new Configuration();
            config.SetApiKey("TlTMI102RD5Kl0PGlP1SLRTb6x5Idiomwl5YuF79ibDBs110");
            config.SetBatch(new BatchInfo("UFG Hackathon"));
            // Add browsers with different viewports
            config.AddBrowser(1200, 700, BrowserType.CHROME);
            config.AddBrowser(1200, 700, BrowserType.FIREFOX);
            config.AddBrowser(1200, 700, BrowserType.EDGE_CHROMIUM);
            config.AddBrowser(768, 700, BrowserType.CHROME);
            config.AddBrowser(768, 700, BrowserType.FIREFOX);
            config.AddBrowser(768, 700, BrowserType.EDGE_CHROMIUM);

            // Add mobile emulation devices in Portrait mode
            config.AddDeviceEmulation(DeviceName.iPhone_X, ScreenOrientation.Portrait);
            config.AddDeviceEmulation(DeviceName.Pixel_2, ScreenOrientation.Portrait);

            // Set the configuration object to eyes
            _eyes.SetConfiguration(config);
        }
コード例 #4
0
        public void Initialize()
        {
            //Initialize the Runner for your test.
            runner = new VisualGridRunner(10);

            // Initialize the eyes SDK
            _eyes = new Eyes(runner);

            // Initialize eyes Configuration
            config = new Configuration();
            config.SetApiKey("AS876OwEVY3qDFEAlB4NERfld2wrXCbSDVxewhHgn5E110");
            config.SetBatch(new BatchInfo("Holiday Shopping"));
            config.AddBrowser(1200, 800, BrowserType.CHROME);

            // Add browsers with different viewports
            //Uncomment these to run in multiple browsers
            //config.AddBrowser(1200, 800, BrowserType.FIREFOX);
            //config.AddBrowser(1200, 800, BrowserType.EDGE_CHROMIUM);
            //config.AddBrowser(1200, 800, BrowserType.SAFARI);
            //config.AddDeviceEmulation(DeviceName.iPhone_X);

            _eyes.SetConfiguration(config);
        }
コード例 #5
0
        public void Initialize()
        {
            //Initialize the Runner the test.
            runner = new VisualGridRunner(10);

            // Initialize the eyes SDK
            _eyes = new Eyes(runner);

            // Initialize eyes Configuration
            config = new Configuration();
            config.SetApiKey("80t00102Dxj9FBzQ7UWU1031n4MRH109Vvc5JoceMwbA79Q110 ");
            config.SetBatch(new BatchInfo("Holiday Shopping"));
            config.AddBrowser(1200, 800, BrowserType.CHROME);

            //Adding configuration for cross-browsers testing
            //Uncomment the following to run across multiple browsers
            //config.AddBrowser(1200, 800, BrowserType.FIREFOX);
            //config.AddBrowser(1200, 800, BrowserType.EDGE_CHROMIUM);
            //config.AddBrowser(1200, 800, BrowserType.SAFARI);
            //config.AddDeviceEmulation(DeviceName.iPhone_X);

            _eyes.SetConfiguration(config);
        }
コード例 #6
0
        public void BeforeTestSuite()
        {
            runner = new VisualGridRunner(concurrentSessions);
            // Create a configuration object, we will use this when setting up each test
            suiteConfig = new Configuration();
            IConfiguration newsuiteConfg = new Configuration();

            suiteConfig.AddBrowser(1200, 700, BrowserType.CHROME);
            suiteConfig.AddBrowser(1200, 700, BrowserType.FIREFOX);
            suiteConfig.AddBrowser(1200, 700, BrowserType.EDGE_CHROMIUM);
            suiteConfig.AddBrowser(768, 700, BrowserType.CHROME);
            suiteConfig.AddBrowser(768, 700, BrowserType.FIREFOX);
            suiteConfig.AddBrowser(768, 700, BrowserType.EDGE_CHROMIUM);
            suiteConfig.AddDeviceEmulation(DeviceName.iPhone_X, Applitools.VisualGrid.ScreenOrientation.Portrait);

            suiteConfig
            .SetApiKey(apiKey)
            .SetAppName(appName)
            .SetBatch(new BatchInfo(batchName))
            ;
        }
コード例 #7
0
        public static void ClassInitializeMethod(TestContext testContext)
        {
            _testContext = testContext;
            suiteConfig  = new Configuration();
            suiteConfig.SetApiKey("xIWisbt6NECuLEfxj99i7tQD5MTm2fwXlK3X8Xwek578110");
            suiteConfig.SetBatch(new BatchInfo(batchName));

            // Visual Grid configurations
            suiteConfig.AddBrowser(1200, 700, BrowserType.CHROME);
            suiteConfig.AddBrowser(1200, 700, BrowserType.FIREFOX);
            suiteConfig.AddBrowser(1200, 700, BrowserType.EDGE_CHROMIUM);
            suiteConfig.AddBrowser(768, 700, BrowserType.CHROME);
            suiteConfig.AddBrowser(768, 700, BrowserType.FIREFOX);
            suiteConfig.AddBrowser(768, 700, BrowserType.EDGE_CHROMIUM);
            suiteConfig.AddDeviceEmulation(DeviceName.iPhone_X, Applitools.VisualGrid.ScreenOrientation.Portrait);

            string projectPath = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName;
            string eyesLogFile = Path.Combine(projectPath, "eyesLogFile.txt");
            //eyes = new Eyes(runner);
            //eyes.SetConfiguration(suiteConfig);
            //eyes.SetLogHandler(new FileLogHandler(eyesLogFile, true, true));
        }
コード例 #8
0
        public void TestMethod2()
        {
            String shouldBreakSiteStr = Environment.GetEnvironmentVariable("INJECT_BUG");

            bool shouldBreakSite = false;

            if (shouldBreakSiteStr != null && shouldBreakSiteStr.Length > 0)
            {
                shouldBreakSite = bool.Parse(shouldBreakSiteStr);
            }

            String testName = "Functional VS Visual";

            VisualGridRunner runner = new VisualGridRunner(10);
            Eyes             eyes   = new Eyes(runner);
            ChromeDriver     driver = new ChromeDriver();

            Configuration sconf = eyes.GetConfiguration();

            sconf.SetAppName(testName);

            sconf.SetTestName(testName);

            eyes.ApiKey = Environment.GetEnvironmentVariable("APPLITOOLS_API_KEY");

            var batchName = Environment.GetEnvironmentVariable("APPLITOOLS_BATCH_NAME");
            var batchId   = Environment.GetEnvironmentVariable("APPLITOOLS_BATCH_ID");

            BatchInfo batchInfo = new Applitools.BatchInfo(batchName);

            batchInfo.Id = batchId;

            sconf.SetBatch(batchInfo);

            sconf.AddBrowser(1200, 800, BrowserType.CHROME);
            sconf.AddBrowser(1200, 800, BrowserType.FIREFOX);
            sconf.AddBrowser(1200, 800, BrowserType.SAFARI);
            sconf.AddBrowser(1200, 800, BrowserType.IE_11);
            sconf.AddBrowser(1200, 800, BrowserType.EDGE);


            //sconf.AddDeviceEmulation(DeviceName.iPad, ScreenOrientation.Portrait);
            //sconf.AddDeviceEmulation(DeviceName.iPad_Pro, ScreenOrientation.Portrait);
            //sconf.AddDeviceEmulation(DeviceName.iPhone_6_7_8_Plus, ScreenOrientation.Portrait);
            //sconf.AddDeviceEmulation(DeviceName.iPhone_X, ScreenOrientation.Portrait);
            //sconf.AddDeviceEmulation(DeviceName.Galaxy_Note_3, ScreenOrientation.Portrait);
            //sconf.AddDeviceEmulation(DeviceName.Nexus_10, ScreenOrientation.Portrait);

            eyes.SetLogHandler(new FileLogHandler(@"C:\Users\user\Desktop\appli.log", false, true));

            sconf.SetViewportSize(1000, 600);

            eyes.SetConfiguration(sconf);

            Console.WriteLine("Open conection to Eyes");
            eyes.Open(driver);

            driver.Url = "https://github.com/login";

            Console.WriteLine("Visual Assertion #1");
            eyes.Check(Target.Window().Fully().WithName("Login page"));

            Console.WriteLine("Click Login");
            driver.FindElement(By.CssSelector("#login > form > div.auth-form-body.mt-3 > input.btn.btn-primary.btn-block"))
            .Click();

            if (shouldBreakSite)
            {
                Console.WriteLine("Breaking Site");
                BreakSite(driver);
            }

            Console.WriteLine("Begin Functional Assertions");

            // validate sign in button
            String buttonText = driver
                                .FindElement(
                By.CssSelector("#login > form > div.auth-form-body.mt-3 > input.btn.btn-primary.btn-block"))
                                .GetAttribute("value");

            Assert.IsTrue(buttonText.CompareTo("Sign in") == 0, "wrong button");

            // validate error message
            String errorMessage = driver.FindElement(By.CssSelector("#js-flash-container > div > div")).Text;

            Assert.IsTrue(errorMessage.Contains("Incorrect username or password."), "wrong label");

            String usernameTextbox = driver
                                     .FindElement(By.CssSelector("#login > form > div.auth-form-body.mt-3 > label:nth-child(1)")).Text;

            Assert.IsTrue(usernameTextbox.Contains("Username or email address"), "wrong label");

            String passwordTextbox = driver
                                     .FindElement(By.CssSelector("#login > form > div.auth-form-body.mt-3 > label:nth-child(3)")).Text;

            Assert.IsTrue(passwordTextbox.Contains("Password"), "wrong label");

            Console.WriteLine("Completed Functional Assertions");

            Console.WriteLine("Visual Assertion #2");
            eyes.Check(Target.Window().Fully().WithName("Error Message"));

            Console.WriteLine("Close connection to Eyes");
            eyes.CloseAsync();

            System.Diagnostics.Debug.WriteLine("Waiting for visual test to complete");
            TestResultsSummary results = runner.GetAllTestResults();

            System.Diagnostics.Debug.WriteLine(results);

            driver.Quit();
        }