示例#1
0
        public static void Test2(IWebDriver webDriver, Eyes eyes)
        {
            try
            {
                // V1 URL
                //webDriver.Url = "https://demo.applitools.com/tlcHackathonMasterV1.html";

                // Dev URL
                //  webDriver.Url = "https://demo.applitools.com/tlcHackathonDev.html";

                // V2 URL
                webDriver.Url = "https://demo.applitools.com/tlcHackathonMasterV2.html";

                // Call Open on eyes to initialize a test session
                eyes.Open(webDriver, "AppliFashion", "Test 2", new Size(1200, 800));

                webDriver.FindElement(By.XPath("//label[text()='Black ']")).Click();
                webDriver.FindElement(By.Id("filterBtn")).Click();
                Thread.Sleep(3000);
                eyes.CheckRegion(By.Id("product_grid"), "filter by color", 3);

                eyes.CloseAsync();
            }
            catch (Exception e)
            {
                eyes.AbortAsync();
            }
        }
示例#2
0
        public static void Main(string[] args)
        {
            // Open a Chrome browser.
            driver = new ChromeDriver();
            driver.Manage().Window.Maximize();
            // Initialize the eyes SDK and set your private API key.
            var eyes = new Eyes();

            eyes.ApiKey = "TOLqDb0rgpHlNt111OXiJjHSDfZbM109ijaEQEtUWvmxgTY110";
            eyes.ForceFullPageScreenshot = true;
            //eyes.SaveNewTests = true;
            eyes.BaselineEnvName = "No stiky";
            eyes.MatchLevel      = Applitools.MatchLevel.Layout;

            try
            {
                // Start the test and set the browser's viewport size to 800x600.
                eyes.Open(driver, "Hello World!", "No stiky");

                // Navigate the browser to the "hello world!" web-site.
                driver.Url = "https://www.agoda.com?expuser=A";

                InjectJavascript(driver, JS_INJ_FREEZE_SEARCH_BAR_OLSB);

                // Visual checkpoint #1.
                eyes.CheckRegion(By.CssSelector("[data-selenium='tile-container-left']"));
                eyes.InRegion(By.CssSelector("[data-selenium='tile-container-right']"));



                eyes.CheckWindow("RESORT");
                // Click the "Click me!" button.
                driver.FindElement(By.XPath("//*[@data-selenium='homesTab']")).Click();

                //// Visual checkpoint #2.
                //eyes.CheckWindow("RESORT");

                // End the test.
                eyes.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                // Close the browser.
                driver.Quit();

                // If the test was aborted before eyes.Close was called, ends the test as aborted.
                eyes.AbortIfNotClosed();
            }
        }
示例#3
0
        public void MiniTest()
        {
            var viewMenu = UIMap.UICalculatorWindow.UIApplicationMenuBar.UIViewMenuItem;
            var eyes     = new Eyes();

            eyes.SetLogHandler(new StdoutLogHandler());
            eyes.BranchName = "demo";

            try
            {
                eyes.Open(UIMap.UICalculatorWindow, "Calculator", "MiniTest");
                eyes.CheckWindow("Standard");

                Mouse.Click(new System.Drawing.Point(viewMenu.Left + 100, viewMenu.Top + 200));

                var menu = UIMap.UICalculatorWindow.UIApplicationMenuBar;
                eyes.CheckRegion(menu, TimeSpan.FromSeconds(5), "Menu Bar!");

                Assert.AreEqual("View Edit Help", eyes.InRegion(menu).GetText());

                CollectionAssert.AreEqual(
                    new[] { "View Edit Help", "View Edit Help" },
                    eyes.InRegion(menu).And(menu).GetText());

                Mouse.Click(viewMenu);
                eyes.CheckWindow("Standard + View");

                Mouse.Click(viewMenu);
                eyes.CheckWindow("Standard");

                eyes.Close();
            }
            finally
            {
                eyes.AbortIfNotClosed();
            }
        }
示例#4
0
        static void Main(string[] args)
        {
            String     website      = "C:\\Users\\User\\Documents\\eyes-knowledgebase-source\\FlareProjects\\Content\\example-code\\fluentsnippets\\html\\fluentsnippets.html";
            Eyes       eyes         = new Eyes();
            IWebDriver innerDriver  = new ChromeDriver();
            Size       viewportSize = new Size(/*width*/ 1024, /*height*/ 800);
            String     appname      = "EKB examples";
            String     testname     = "snippets v1";

            IWebDriver driver = eyes.Open(innerDriver, appname, testname, viewportSize);

            try
            {
                driver.Url = website;
                Rectangle R1 = new Rectangle(10, 15, 20, 10);
                Rectangle R2 = new Rectangle(40, 20, 30, 15);
                Rectangle F3 = new Rectangle(80, 25, 40, 20);
                Rectangle F4 = new Rectangle(130, 30, 50, 25);
                int       up = 10, left = 30, down = 20, right = 40;
//%%%% start ex1
                eyes.Check("Example 1a",                        // the name of the checkpoint (and step)
                           Target.Window()                      // check the entire window
                           .Fully()                             // use scrolling and stitching
                           .Strict()                            // use a STRICT match level
                           .Ignore(R1, R2)                      // ignore the regions defined by R1 and R2
                           .Floating(F3, up, down, left, right) // handle the region F3 as a floating region
                           .Floating(F4, up, down, left, right) // handle the region F4 as a floating region
                           );
//%%%% stop ex1

//%%%% start ex2
                SeleniumCheckSettings t = Target.Window();
                t.Fully();
                t.Strict();
                t.Ignore(R1, R2);
                t.Floating(F3, up, down, left, right);
                t.Floating(F4, up, down, left, right);
                eyes.Check("Example 1b", t);
//%%%% stop ex2

//%%%% start ex3
                eyes.Check(
                    Target.Region(By.Id("mixed-area"))
                    .Layout()
                    .WithName("Example 2a")
                    );
                /*TBD Should be a single target call*/
                eyes.Check(
                    Target.Region(By.CssSelector("body table"))   // 2nd target
                    .Strict()
                    .WithName("Example 2b")
                    );
//%%%% stop ex3

//%%%% start ex3a
                eyes.Check("Example 3a", Target.Window());

                // this is equivalent to
                eyes.CheckWindow("Example 3a - non Fluent");
//%%%% stop ex3a

//%%%% start ex4a
                eyes.Check("Example 3b",
                           Target.Region(By.Id("mixed-area")));

                // this is equivalent to
                eyes.CheckRegion(By.Id("mixed-area"), "Example 3b - non fluent");

                IWebElement element = driver.FindElement(By.Id("mixed-area"));
                eyes.Check("Example 3c",
                           Target.Region(element));

                eyes.Check("Example 3d", Target.Region(new Rectangle(30, 50, 300, 620)));
//%%%% stop ex4a
//%%%% start ex4b
                eyes.Check("Example 3e",
                           Target.Frame("frame-outer"));

                eyes.Check("Example 3f",
                           Target.Frame("frame-outer")
                           .Frame("frame-inner")
                           );

                eyes.Check("Example 3g",
                           Target.Frame("frame-outer")
                           .Frame("frame-inner")
                           .Region(By.Id("inner-text"))
                           );


//%%%% stop ex4b
//%%%% start ex5
                eyes.Check("Example 5a",
                           Target.Window().Fully(true));

                eyes.Check("Example 5b",
                           Target.Region(By.Id("mixed-area")).Fully());

                // this is equivalent to
                eyes.CheckRegion(By.Id("mixed-area"), "Example 5b - non Fluent", true);

                eyes.Check("Example 5c",
                           Target.Frame("frame-outer")
                           .Frame("frame-inner")
                           .Region(By.Id("inner-text"))
                           .Fully()
                           );
//%%%% stop ex5

//%%%% start ex6
                // pass a match level value
                eyes.Check("Example6a",
                           Target.Region(By.Id("mixed-area")).MatchLevel(Applitools.MatchLevel.Layout));

                // or use one of the shortcut match level methods
                eyes.Check("Example6b",
                           Target.Region(By.Id("mixed-area")).Layout()); // matchLevel(MatchLevel.LAYOUT))

                eyes.Check("Example6c",
                           Target.Region(By.Id("mixed-area")).Strict()); // matchLevel(MatchLevel.STRICT))

                eyes.Check("Example6d",
                           Target.Region(By.Id("mixed-area")).Content()); // matchLevel(MatchLevel.CONTENT))
//%%%% stop ex6

//%%%% start ex7
                eyes.Check("Example 7",
                           Target.Window().Timeout(new TimeSpan(0, 0, 10)));
//%%%% stop ex7

//%%%% start ex8
                Boolean doIgnore = true;
                eyes.Check("Example 8",
                           Target.Window()
                           .IgnoreCaret(doIgnore));
//%%%% stop ex8

//%%%% start ex9
                eyes.Check("Example 9a", Target.Window());

                eyes.Check(
                    Target.Window().WithName("Example 9b"));

                eyes.Check(
                    Target.Region(By.Id("greeting"))
                    .Layout()
                    .WithName("Example 9c")
                    );
                /*tbd remove when multiple targbet allowed*/
                eyes.Check(
                    Target.Frame(By.Id("frame-outer"))
                    .Fully()
                    .WithName("Example 9d")
                    );
//%%%% stop ex9

//%%%% start ex10
                Rectangle ignoreArea = new Rectangle(10, 10, 50, 25);

                eyes.Check("Example 10a",
                           Target.Region(By.Id("greeting"))
                           .Ignore(By.Id("user-name"),
                                   By.Id("last-login"),
                                   By.Id("current-date"),
                                   By.Id("current-time"))
                           .Ignore(ignoreArea)
                           );
                By[] bylist =
                {
                    By.Id("user-name"),
                    By.Id("last-login"),
                    By.Id("current-date"),
                    By.Id("current-time")
                };
                eyes.Check("Example 10b",
                           Target.Region(By.Id("greeting"))
                           .Ignore(bylist)
                           .Ignore(ignoreArea)
                           );
                eyes.Check("Example 10c",
                           Target.Region(By.Id("greeting"))
                           .Ignore(By.CssSelector("[volatile]"))
                           .Ignore(ignoreArea)
                           );
                //%%%% stop ex10

                //%%%% start ex11
                int offset = 10;
                int upwards = 5, downwards = 12, toTheLeft = 20, toTheRight = 20;

                Rectangle   region1    = new Rectangle(10, 20, 50, 15);
                Rectangle   region2    = new Rectangle(10, 50, 100, 200);
                Rectangle   region3    = new Rectangle(upwards, 50, 100, 200);
                Rectangle[] regionList = { region1, region2, region3 };

                eyes.Check("Example 11a",
                           Target.Window()
                           .Floating(region1, upwards, downwards, toTheLeft, toTheRight)
                           .Floating(region2, upwards, downwards, toTheLeft, toTheRight)
                           .Floating(region3, upwards, downwards, toTheLeft, toTheRight)
                           );
                eyes.Check("Example 11b",
                           Target.Window()
                           .Floating(offset, regionList)
                           );
                eyes.Check("Example 11c",
                           Target.Window()
                           .Floating(offset, region1, region2, region3)
                           );
                //%%%% stop ex11

                //%%%% start ex12
                IWebElement username = driver.FindElement(By.Id("userid"));
                username.SendKeys("JDoe");
                IWebElement password = driver.FindElement(By.Id("password"));
                password.SendKeys("myPassword!");
                eyes.Check("Example 12a",
                           Target.Region(By.Id("loginform"))
                           .Layout(username, password)
                           .Strict(By.Id("instructions"))
                           .MatchLevel(Applitools.MatchLevel.Content) /* define a strict match level for the entire target */
                           );

//%%%% stop ex12
                eyes.Close(false);
            }
            finally
            {
                eyes.AbortIfNotClosed();
                innerDriver.Quit();
            }
        }
示例#5
0
        public void TestJustEat()
        {
            VisualGridRunner runner = new VisualGridRunner(10);
            IWebDriver       driver = SeleniumUtils.CreateChromeDriver();
            Eyes             eyes   = InitEyesWithLogger(runner, verbose: true, writeResources: true);

            //ConfigureSingleBrowser(eyes);
            ConfigureMultipleBrowsers(eyes);
            OpenEyes(driver, "https://www.just-eat.co.uk/", eyes, 1000, 700);
            try
            {
                //Close the cookie notification footer
                driver.FindElement(By.XPath("//*[@data-test-id='cookieBanner-close-button']")).Click();
                IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
                //Driver for Uber ad shows randomly. Remove this element so it doesn't affect our tests
                //IWebElement uberContainer = _driver.FindElementByClassName("ex1140 l-container");

                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
                //IWebElement element = wait.Until(ExpectedConditions.ElementExists(By.CssSelector("div.ex1140.l-container")));

                js.ExecuteScript("var e = document.querySelector('div.ex1140.l-container'); if (e) e.hidden = true;");

                eyes.CheckWindow("Homepage");
                eyes.CheckWindow("another test");

                //Search by Postal Code
                driver.FindElement(By.Name("postcode")).SendKeys("EC4M7RA");
                driver.FindElement(By.XPath("//button[@data-test-id='find-restaurants-button']")).Click();

                //Deal with time of day issues -- Sometimes it asks if you want take away
                driver.FindElement(By.ClassName("closeButton")).Click();

                //Narrow the search to just first in the list (helps when running before the restaurant is open
                wait.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("div.c-searchFilterSection-filterList  span:nth-child(1)"))).Click();

                wait.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("div[data-test-id=searchresults] section:nth-child(1)"))).Click();

                //Open the Show More link
                IList <IWebElement> showMoreLink = driver.FindElements(By.Id("showMoreText"));
                if (showMoreLink.Count > 0)
                {
                    Actions actions = new Actions(driver);
                    actions.MoveToElement(showMoreLink[0]).Click().Perform();
                }

                eyes.CheckWindow();
                eyes.CheckRegion(By.ClassName("menuDescription"), "Menu Description");

                //eyes.ForceFullPageScreenshot = false;

                //Check the top Food Allergy link
                driver.FindElement(By.XPath("//div[@id='basket']//button[contains(text(), 'If you or someone')]")).Click();
                eyes.CheckWindow("last");

                eyes.CheckRegion(By.XPath("//div[@data-ft='allergenModalDefault']"), "Food Allergy - Top", false);
                driver.FindElement(By.XPath("//button[text()='Close']")).Click();

                //Scroll to the bottom of the page to check the second Food Allergy link
                js.ExecuteScript("window.scrollTo(0, document.body.scrollHeight)");

                //retryingFindClick(By.XPath("//div[@id='menu']//button[contains(text(), 'If you or someone')]"));
                //eyes.CheckElement(By.XPath("//div[@data-ft='allergenModalDefault']"), "Food Allergy - Bottom");
                //eyes.CheckRegion(By.XPath("//div[@data-ft='allergenModalDefault']"), "Food Allergy - Bottom", false);
                //eyes.CheckWindow("Food Allergy - Bottom");
                //driver.FindElement(By.XPath("//button[text()='Close']")).Click();/**/
                eyes.CloseAsync();
                runner.GetAllTestResults();
            }
            finally
            {
                eyes.Abort();
                driver.Quit();
            }
        }