Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        public void TestConfiguration()
        {
            ChromeOptions options = new ChromeOptions();

            options.AddArgument("--headless");
            IWebDriver driver = new ChromeDriver(options);
            Eyes       eyes   = new Eyes();

            try
            {
                Configuration conf = new Configuration();
                conf.SetServerUrl("https://testeyes.applitools.com").SetApiKey("HSNghRv9zMtkhcmwj99injSggnd2a8zUY390OiyNRWoQ110");
                eyes.Open(driver, "test configuration", "test server url 1", new Size(800, 600));
                TestResults results1 = eyes.Close();
                eyes.SetConfiguration(conf);
                eyes.Open(driver, "test configuration", "test server url 2", new Size(800, 600));
                TestResults results2 = eyes.Close();

                StringAssert.DoesNotStartWith("https://testeyesapi.applitools.com", results1.ApiUrls.Session);
                StringAssert.StartsWith("https://testeyesapi.applitools.com", results2.ApiUrls.Session);
            }
            finally
            {
                driver.Quit();
            }
        }
        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);
        }
Ejemplo n.º 4
0
        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;
        }
        private static void SetUp(Eyes eyes)
        {
            // Initialize the eyes configuration.
            Configuration config = new Configuration();

            // Add this configuration if your tested page includes fixed elements.
            //config.setStitchMode(StitchMode.CSS);


            // You can get your api key from the Applitools dashboard
            //config.SetApiKey("APPLITOOLS_API_KEY");

            // set new batch
            config.SetBatch(new BatchInfo("Demo batch"));

            // set the configuration to eyes
            eyes.SetConfiguration(config);
        }
Ejemplo n.º 6
0
            private void SetUp(Eyes eyes)
            {
                // Initialize the eyes configuration.
                Applitools.Selenium.Configuration config = new Applitools.Selenium.Configuration();

                // Add this configuration if your tested page includes fixed elements.
                //config.setStitchMode(StitchMode.CSS);


                // You can get your api key from the Applitools dashboard
                //config.ApiKey = "APPLITOOLS_API_KEY";
                config.ApiKey = "Mn5kDOQ104eSgP496VDEulT6gpQGWzykAdb9ZbtHMutuc110";

                // set new batch
                config.SetBatch(new BatchInfo("Demo batch"));

                // set the configuration to eyes
                eyes.SetConfiguration(config);
            }
Ejemplo n.º 7
0
        private void SetUp(Eyes eyes, string AppilToolServerUrl, string AppilToolsApiKey, eBrowserType BrowserType, string Environment)
        {
            Applitools.Selenium.Configuration config = new Applitools.Selenium.Configuration();
            if (WorkSpace.Instance.RunsetExecutor.RunSetConfig != null && WorkSpace.Instance.RunsetExecutor.RunSetConfig.GingerRunners.Any() && ((GingerExecutionEngine)WorkSpace.Instance.RunsetExecutor.RunSetConfig.GingerRunners[0].Executor).ExecutedFrom == eExecutedFrom.Run)
            {
                BatchInfo batchInfo = new BatchInfo(WorkSpace.Instance.RunsetExecutor.RunSetConfig.ItemName);

                batchInfo.Id = WorkSpace.Instance.RunsetExecutor.RunSetConfig.ExecutionID.ToString();
                config.SetBatch(batchInfo);
            }

            config.SetApiKey(AppilToolsApiKey);
            config.SetServerUrl(AppilToolServerUrl);
            OperatingSystem Os_info = System.Environment.OSVersion;

            config.SetHostOS(Os_info.VersionString);
            config.SetHostApp(BrowserType.ToString());
            eyes.AddProperty("Environment ID", !String.IsNullOrEmpty(Environment) ? Environment : "Default");
            eyes.SetConfiguration(config);
        }
        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))
            ;
        }
        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));
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
0
        public void Demo_Applitool()
        {
            EyesRunner runner = new ClassicRunner();
            Eyes       eye    = new Eyes(runner);

            var suiteConfig = new Applitools.Selenium.Configuration();

            suiteConfig
            // Test suite configurations
            .SetApiKey("KgPPOMrJBHbsgzaZ1oJ5A18sNMPiZEXpiRSGqOv6qmk110")
            .SetBatch(new BatchInfo("Demo Regression 001"));

            eye.SetConfiguration(suiteConfig);

            DriverProperty property = new DriverProperty();

            property.DriverType = DriverType.Chrome;
            WebDriver.InitDriverManager(property);
            WebDriver.AddNewDriver(property);
            eye.Open(WebDriver.Driver, "DEMO", "Demo Test 001");
            WebDriver.GoToUrl("http://google.com.vn");

            WebDriver.Sleep(5);

            eye.CheckWindow("Google home page 1");
            eye.Check(Target.Window().Layout(By.XPath("")).Region(By.XPath("")));

            WebDriver.Sleep(5);

            eye.CheckWindow("Google home page 2");

            eye.CloseAsync();

            WebDriver.QuitAllDriver();

            runner.GetAllTestResults(true);
        }
Ejemplo n.º 13
0
        public void TestSetup()
        {
            driver = new ChromeDriver();

            //Original App URL
            driver.Navigate().GoToUrl(originalAppURL);

            //New App URL
            //driver.Navigate().GoToUrl(newAppURL);


            eyes = new Eyes(runner);
            Configuration conf = eyes.GetConfiguration();

            conf.SetStitchMode(StitchModes.CSS);
            conf.SetBatch(batchInfo);

            //conf.SetApiKey("SET_YOUR_API_KEY_HERE");
            //conf.setServerUrl("SET_YOUR_DEDICATED_CLOUD_URL");

            eyes.SetConfiguration(conf);
            eyes.SetLogHandler(new StdoutLogHandler(true));
            eyes.Open(driver, "VisualTest", TestContext.CurrentContext.Test.Name, new RectangleSize(1000, 600));
        }
Ejemplo n.º 14
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();
        }