private static void RunOnAndroid_(Eyes eyes) { AppiumOptions options = new AppiumOptions(); options.AddAdditionalCapability("name", "Open Check Close X2 (A)"); options.AddAdditionalCapability("username", TestDataProvider.SAUCE_USERNAME); options.AddAdditionalCapability("accesskey", TestDataProvider.SAUCE_ACCESS_KEY); options.AddAdditionalCapability("deviceName", "Samsung Galaxy Tab S3 GoogleAPI Emulator"); options.AddAdditionalCapability("deviceOrientation", "landscape"); options.AddAdditionalCapability("platformName", "Android"); options.AddAdditionalCapability("platformVersion", "8.1"); options.AddAdditionalCapability("browserName", "Chrome"); RemoteWebDriver driver = new RemoteWebDriver(new Uri(TestDataProvider.SAUCE_SELENIUM_URL), options.ToCapabilities(), TimeSpan.FromMinutes(3)); //************* try { IWebDriver eyesDriver = eyes.Open(driver, "Applitools", "Open Check Close X2 SauceLabs (A)"); eyesDriver.Url = "https://www.applitools.com"; eyes.Check("Test Android", Target.Window().SendDom(false)); eyes.Close(false); } finally { // Close the browser. driver.Quit(); // If the test was aborted before eyes.Close was called, ends the test as aborted. eyes.Abort(); } }
//Skipped since the page is not available. //[TestCaseSource(nameof(TestMethodDriver))] //[Parallelizable] public void CustomTooltipsTest(DriverOptions driverOptions) { IWebDriver driver = SeleniumUtils.CreateWebDriver(driverOptions); driver.Url = "https://d1q3vzvnjy4w20.cloudfront.net/"; Eyes eyes = new Eyes(); TestUtils.SetupLogging(eyes); eyes.Batch = TestDataProvider.BatchInfo; eyes.HideScrollbars = false; eyes.Open(driver, nameof(TestCustomTooltips), nameof(CustomTooltipsTest), new System.Drawing.Size(800, 600)); driver.FindElement(By.Id("coxkit-tooltip")).Click(); Actions action = new Actions(driver); action.MoveToElement(driver.FindElement(By.Id("warningHover"))).Perform(); By tooltipSelector = By.CssSelector("div[content ^= 'I want to tell you']"); WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); wait.Until(ExpectedConditions.ElementIsVisible(tooltipSelector)); try { eyes.Check(Target.Region(tooltipSelector).WithName(nameof(CustomTooltipsTest))); eyes.Close(); } finally { eyes.Abort(); driver.Quit(); } }
private static void RunOnIos_(Eyes eyes) { AppiumOptions options = new AppiumOptions(); options.AddAdditionalCapability("name", "Open Check Close X2 (B)"); options.AddAdditionalCapability("username", TestDataProvider.SAUCE_USERNAME); options.AddAdditionalCapability("accessKey", TestDataProvider.SAUCE_ACCESS_KEY); options.AddAdditionalCapability("deviceName", "iPad Simulator"); options.AddAdditionalCapability("deviceOrientation", "portrait"); options.AddAdditionalCapability("platformName", "iOS"); options.AddAdditionalCapability("platformVersion", "12.2"); options.AddAdditionalCapability("browserName", "Safari"); RemoteWebDriver driver = new RemoteWebDriver(new Uri(TestDataProvider.SAUCE_SELENIUM_URL), options.ToCapabilities(), TimeSpan.FromMinutes(3)); try { IWebDriver eyesDriver = eyes.Open(driver, "Applitools", "Open Check Close X2 SauceLabs (B)"); driver.Url = "https://www.google.com"; eyes.Check("Test iOS", Target.Window().SendDom(false)); eyes.Close(false); } finally { // Close the browser. driver.Quit(); // If the test was aborted before eyes.Close was called, ends the test as aborted. eyes.Abort(); } }
public void TestVanguard() { VisualGridRunner runner = new VisualGridRunner(10); IWebDriver driver = SeleniumUtils.CreateChromeDriver(); Eyes eyes = InitEyes(driver, runner, "https://investor.vanguard.com/home/", 1000, 700, false); Thread.Sleep(2000); try { eyes.Check("Vanguard", Target .Window() .Fully() .Strict() .SendDom(false) .Layout(By.ClassName("vgc-feedbackLink")) ); eyes.CloseAsync(); runner.GetAllTestResults(); } finally { eyes.Abort(); driver.Quit(); } }
//[Test] public void TestSendDOM_Simple_HTML() { IWebDriver webDriver = SeleniumUtils.CreateChromeDriver(); webDriver.Url = "https://applitools-dom-capture-origin-1.surge.sh/test.html"; Eyes eyes = new Eyes(); try { EyesWebDriver eyesWebDriver = (EyesWebDriver)eyes.Open(webDriver, "Test Send DOM", "Test DomCapture method", new Size(1200, 1000)); Logger logger = new Logger(); logger.SetLogHandler(TestUtils.InitLogHandler()); DomCapture domCapture = new DomCapture(logger, eyesWebDriver); string actualDomJsonString = domCapture.GetFullWindowDom(); string actualDomJson = JsonUtility.NormalizeJsonString(actualDomJsonString); string expectedDomJson = GetExpectedDomFromUrl_("https://applitools-dom-capture-origin-1.surge.sh/test.dom.json"); eyes.Close(false); Assert.AreEqual(expectedDomJson, actualDomJson); } finally { eyes.Abort(); webDriver.Quit(); } }
public void Trello_1676_LoopNet_32073() { var driver = new ChromeDriver(); var eyes = new Eyes(); TestUtils.SetupLogging(eyes); try { eyes.Open(driver, "Ticket32073", "region", new Size(1200, 500)); driver.Url = "https://www.loopnet.com"; WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60)); wait.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("#top > section > header > nav > ul > li:nth-child(1) > a"))).Click(); wait.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("#login > section > div > div.column-06.divide-east > div.field-group.margin-top-lg > input"))).SendKeys("*****@*****.**"); driver.FindElement(By.CssSelector("#login > section > div > div.column-06.divide-east > div:nth-child(5) > input")).SendKeys("Loopnet123"); driver.FindElement(By.CssSelector("#login > section > div > div.column-06.divide-east > div:nth-child(7) > div > button")).Click(); wait.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("#top > section > header > nav > ul > li:nth-child(1) > div > button"))); wait.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector(".master > .main-header #csgp-menu-icon"))).Click(); //wait.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("#ListingManager_LN_Lister_enUS > a"))).Click(); //menuIcon.Click(); //eyes.Check(Target.Region(By.ClassName("top-menu"))); eyes.Check(Target.Region(By.Id("csgp-nav-menu-options")).Fully().WithName("side menu")); eyes.Close(false); } finally { driver.Quit(); eyes.Abort(); } }
public void TestWebsiteThatRequireScrolling(string website, string name) { VisualGridRunner runner = new VisualGridRunner(10); IWebDriver driver = SeleniumUtils.CreateChromeDriver(); Eyes eyes = InitEyesWithLogger(runner, writeResources: true, verbose: true, testMethod: name); ConfigureMultipleBrowsers(eyes); try { EyesWebDriver eyesWebDriver = (EyesWebDriver)OpenEyes(driver, website, eyes, 1000, 700, name);; EyesRemoteWebElement html = (EyesRemoteWebElement)eyesWebDriver.FindElement(By.TagName("html")); eyesWebDriver.ExecuteAsyncScript(@"var currScrollPosition = 0; let cb = arguments[arguments.length - 1] var interval = setInterval(function() { let scrollPosition = document.documentElement.scrollTop; currScrollPosition += 300; window.scrollTo(0, currScrollPosition); if (scrollPosition === document.documentElement.scrollTop) { clearInterval(interval); window.scrollTo(0, 0); cb() } }, 100); "); eyes.Check(name, Target.Window().Fully()); eyes.CloseAsync(); runner.GetAllTestResults(); } finally { eyes.Abort(); driver.Quit(); } }
public void TestPandalytics() { VisualGridRunner runner = new VisualGridRunner(10); IWebDriver driver = SeleniumUtils.CreateChromeDriver(); Eyes eyes = InitEyesWithLogger(runner, verbose: true, writeResources: true); //ConfigureSingleBrowser(eyes); ConfigureMultipleBrowsers(eyes); try { EyesWebDriver eyesWebDriver = (EyesWebDriver)OpenEyes(driver, "https://pandalytics-sandbox.instructure.com", eyes, 1000, 700); driver.FindElement(By.Id("pseudonym_session_unique_id")).SendKeys("*****@*****.**"); driver.FindElement(By.Id("pseudonym_session_password")).SendKeys("password"); driver.FindElement(By.ClassName("Button--login")).Click(); eyes.Check("Dashboard page", Target.Window().Fully()); driver.Url = "https://pandalytics-sandbox.instructure.com/courses/17/external_tools/63"; Thread.Sleep(1000); eyes.Check("LTI tool", Target.Frame("tool_content").Fully()); eyes.CloseAsync(); runner.GetAllTestResults(); } finally { eyes.Abort(); driver.Quit(); } }
public void TestEyesDifferentRunners(string testedUrl, MatchLevel matchLevel) { IWebDriver webDriver = SeleniumUtils.CreateChromeDriver(); Logger logger = null; Eyes eyes = null; try { webDriver.Url = testedUrl; eyes = InitEyes(webDriver, testedUrl); eyes.SaveNewTests = false; logger = eyes.Logger; logger.Log("running check for url " + testedUrl); ICheckSettings checkSettings = GetCheckSettings(); eyes.MatchLevel = matchLevel; eyes.Check(checkSettings.WithName("Step1 - " + testedUrl)); eyes.Check(checkSettings.Fully().WithName("Step2 - " + testedUrl)); logger.Verbose("calling eyes_.Close() (test: {0})", testedUrl); TestResults results = eyes.Close(false); ValidateResults(eyes, results); } finally { eyes?.Abort(); webDriver.Quit(); } }
public void BeatsByDre_HoverElement(bool bCheckHover) { string testName = "Hover Element (viewport)"; if (bCheckHover == true) { testName += " - On"; } else { testName += " - Off"; } Eyes eyes = new Eyes(); IWebDriver driver = SeleniumUtils.CreateChromeDriver(); string logPath = TestUtils.InitLogPath(); eyes.DebugScreenshotProvider = new FileDebugScreenshotProvider() { Path = logPath }; try { IWebDriver eyesDriver = eyes.Open(driver, testName, testName, new Size(1200, 600)); driver.Url = "https://www.beatsbydre.com/support/headphones/studio3-wireless"; ((ChromeDriver)driver).ExecuteScript("window.scrollBy(0,400)"); By selector = By.CssSelector( "#maincontent > div:nth-child(1) > div.supportContent.parbase.section > div > div > div.selector.topics > div.boxes > a:nth-child(1) > div > div.content"); eyes.CheckWindow("Window", false); //eyes.StitchMode = StitchModes.CSS; // Hover effect if (bCheckHover) { IWebElement we = eyesDriver.FindElement(selector); Actions action = new Actions(eyesDriver); action.MoveToElement(we).Perform(); } // End eyes.CheckWindow("Window 2", false); eyes.Check("Region", Target.Region(selector)); eyes.Close(); } finally { eyes.Abort(); driver.Quit(); } }
//[TestCase(true), TestCase(false)] public void HelloWorldTest(bool useVisualGrid) { IWebDriver webDriver = SeleniumUtils.CreateChromeDriver(); webDriver.Url = "https://applitools.com/helloworld"; EyesRunner runner = useVisualGrid ? (EyesRunner) new VisualGridRunner(10) : new ClassicRunner(); runner.SetLogHandler(TestUtils.InitLogHandler()); Eyes eyes = new Eyes(runner); Configuration sconf = eyes.GetConfiguration(); string suffix = useVisualGrid ? "_VG" : ""; // Set test name sconf.SetTestName("Hello World Demo" + suffix); // Set app name sconf.SetAppName("Hello World Demo"); // Add browsers sconf.AddBrowser(800, 600, BrowserType.CHROME); sconf.AddBrowser(700, 500, BrowserType.FIREFOX); sconf.AddBrowser(1200, 800, BrowserType.IE_10); sconf.AddBrowser(1200, 800, BrowserType.IE_11); sconf.AddBrowser(1600, 1200, BrowserType.EDGE); // Set the configuration object to eyes eyes.SetConfiguration(sconf); try { // Call Open on eyes to initialize a test session eyes.Open(webDriver); // Add 2 checks eyes.Check(Target.Window().WithName("Step 1 - Viewport").Ignore(By.CssSelector(".primary"))); eyes.Check(Target.Window().Fully().WithName("Step 1 - Full Page") .Floating(By.CssSelector(".primary"), 10, 20, 30, 40) .Floating(By.TagName("button"), 1, 2, 3, 4)); webDriver.FindElement(By.TagName("button")).Click(); // Add 2 checks eyes.Check(Target.Window().WithName("Step 2 - Viewport")); eyes.Check(Target.Window().Fully().WithName("Step 2 - Full Page")); // Close eyes and collect results eyes.Close(); } finally { eyes.Abort(); webDriver.Quit(); } }
public void Teardown(Eyes eyes) { try { TestResults results = eyes.Close(); eyes.Logger.Log("Mismatches: " + results.Mismatches); } finally { eyes.Abort(); } }
public void AfterEachTest() { if (eyes.IsOpen) { eyes.Close(false); } else { eyes.Abort(); } webDriver.Quit(); }
public void TestHome() { //FirefoxOptions options = new FirefoxOptions(); //if (TestSetup.RUN_HEADLESS) //{ // options.AddArgument("--headless"); //} //IWebDriver webdriver = new FirefoxDriver(options); ChromeOptions options = new ChromeOptions(); if (SeleniumUtils.RUN_HEADLESS) { options.AddArgument("headless"); } IWebDriver webdriver = new ChromeDriver(options); var eyes = new Eyes(); eyes.BranchName = "demo"; eyes.StitchMode = StitchModes.CSS; SetupLogging(eyes, nameof(TestHome)); try { IWebDriver driver = eyes.Open(webdriver, "www.applitools.com", "Home", new Size(1006, 677)); driver.Url = "https://www.applitools.com"; //eyes.Check("Home (window)", Target.Window().ScrollRootElement(By.CssSelector("div.horizontal-page")).Fully()); eyes.Check("Home (region)", Target.Region(By.CssSelector("div.page")).Fully()); //eyes.Check("Home", Target.Window().ScrollRootElement(By.CssSelector("div.page")).Fully()); eyes.Close(); driver.FindElement(By.LinkText("Features")).Click(); eyes.Check("Features", Target.Window().ScrollRootElement(By.CssSelector("div.page")).Fully().Timeout(TimeSpan.FromSeconds(5))); CollectionAssert.AreEqual( new[] { "Features", "CUSTOMERS" }, eyes.InRegion(By.TagName("h1")).And(By.LinkText("Customers")).GetText()); driver.FindElement(By.LinkText("Free Trial")).Click(); eyes.Check("Sign Up", Target.Window().Fully()); eyes.Close(); /**/ } finally { eyes.Abort(); webdriver.Quit(); } }
public void McKinsey() { var driver = new ChromeDriver(); var eyes = new Eyes(); eyes.SendDom = false; eyes.SetLogHandler(TestUtils.InitLogHandler()); driver.Url = "https://www.mckinsey.com/"; try { IWebDriver eyesDriver = eyes.Open(driver, "McKinsey", "McKinsey");//, new Size(1200, 800)); var ccDismiss = driver.FindElements(By.CssSelector(".cc-dismiss")); if (ccDismiss.Count > 0) { ccDismiss[0].Click(); } IList <IWebElement> sections = driver.FindElements(By.CssSelector(".pager>a[data-section]")); sections[0].Click(); Thread.Sleep(300); eyes.Check(Target.Window()); sections[1].Click(); Thread.Sleep(300); eyes.Check(Target.Window()); sections[2].Click(); Thread.Sleep(300); eyes.Check(Target.Window()); ((IJavaScriptExecutor)eyesDriver).ExecuteScript( "document.querySelector('#skipToMain').removeChild(document.querySelector('#sectionScroll'));" + "document.querySelector('#form1').removeChild(document.querySelector('header'));" + "document.querySelector('body').style.overflow='auto';"); eyes.Check(Target.Window().Fully() //.ScrollRootElement(By.TagName("body")) ); eyes.Close(); } finally { driver.Quit(); eyes.Abort(); } }
public void TestFailure() { VisualGridRunner visualGridRunner = new VisualGridRunner(10); visualGridRunner.SetLogHandler(TestUtils.InitLogHandler()); Size[] ViewportList = { new Size(800, 600), new Size(700, 500), new Size(1200, 800), new Size(1600, 1200) }; IWebDriver webDriver = SeleniumUtils.CreateChromeDriver(); webDriver.Url = "https://applitools.com/helloworld"; Eyes eyes = null; try { int resultsTotal = 0; foreach (Size viewport in ViewportList) { eyes = InitEyes_(null, webDriver, viewport); eyes.Check(Target.Window().Fully()); eyes.Close(); eyes = InitEyes_(visualGridRunner, webDriver, viewport); eyes.Check(Target.Window().Fully()); eyes.Close(); TestResultsSummary results = visualGridRunner.GetAllTestResults(); resultsTotal += results.Count; } Assert.AreEqual(4, resultsTotal); } catch (InvalidOperationException e) { if (e.Message.Equals("Eyes not open")) { Assert.Pass(); } } finally { webDriver?.Quit(); eyes?.Abort(); } }
public void TestSessionSummary_Status_Failed() { Eyes eyes = new Eyes(); eyes.Batch = TestDataProvider.BatchInfo; eyes.SaveNewTests = true; IWebDriver webDriver = SeleniumUtils.CreateChromeDriver(); string guid = "_" + Guid.NewGuid(); eyes.Open(webDriver, nameof(TestServerStatus) + guid, nameof(TestServerStatus) + guid, new Size(800, 600)); webDriver.Url = "https://applitools.github.io/demo/TestPages/DynamicResolution/mobile.html"; try { eyes.Check(nameof(TestSessionSummary_Status_Failed) + guid, Target.Window().Fully(false)); eyes.Close(false); } finally { eyes.Abort(); } eyes.Open(webDriver, nameof(TestServerStatus) + guid, nameof(TestServerStatus) + guid, new Size(800, 600)); webDriver.Url = "https://applitools.github.io/demo/TestPages/DynamicResolution/desktop.html"; try { eyes.Check(nameof(TestSessionSummary_Status_Failed) + guid, Target.Window().Fully(false)); TestResults results = eyes.Close(false); Assert.IsTrue(results.IsDifferent); } finally { eyes.Abort(); webDriver.Quit(); } }
public void Attentia() { // Open a Chrome browser. var driver = new ChromeDriver(); // Initialize the eyes SDK and set your private API key. var eyes = new Eyes(); eyes.SendDom = false; eyes.SetLogHandler(TestUtils.InitLogHandler()); //Navigate to the URL driver.Url = "https://uat-dots.attentia.be"; try { //Start the test var eyesDriver = eyes.Open(driver, "Attentia", "#29053", new Size(1200, 800)); WebDriverWait wait = new WebDriverWait(eyesDriver, TimeSpan.FromSeconds(30)); IWebElement userName = wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("#userNameInput"))); eyes.CheckWindow("step 1", true); userName.SendKeys("*****@*****.**"); eyes.CheckWindow("step 2", true); wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("#passwordInput"))).SendKeys("Azerty_03"); eyes.CheckWindow("step 3", true); wait.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("#submitButton"))).Click(); eyes.CheckWindow("step 4", true); //eyes.Check(Target.Frame("appFrame").Fully()); //Close the test eyes.Close(); } catch (Exception e) { eyes.Logger.Log("Error: " + e); } finally { // Close the browser. driver.Quit(); // If the test was aborted before eyes.Close was called, ends the test as aborted. eyes.Abort(); } }
private static TestResults RunTest_(bool fully, Eyes eyes, string testName, IWebDriver driver, string page) { try { driver.Url = $"https://applitools.github.io/demo/TestPages/DynamicResolution/{page}.html"; eyes.Open(driver, "Eyes Selenium SDK - iOS Safari Cropping", testName); //eyes.Check("Initial view", Target.Region(By.CssSelector("div.page")).Fully(fully).SendDom(false)); eyes.Check(Target.Window().Fully(fully)); TestResults result = eyes.Close(); return(result); } finally { eyes.Abort(); driver.Quit(); } }
public void TestDefaultRenderingOfMultipleTargets() { IWebDriver driver = SeleniumUtils.CreateChromeDriver(); driver.Url = "https://applitools.com/helloworld"; VisualGridRunner runner = new VisualGridRunner(10); Eyes eyes = new Eyes(runner); Configuration config = eyes.GetConfiguration(); config.AddBrowser(800, 600, BrowserType.CHROME); config.AddBrowser(800, 600, BrowserType.FIREFOX); config.AddBrowser(1200, 800, BrowserType.CHROME); config.AddBrowser(1200, 800, BrowserType.FIREFOX); config.SetAppName(nameof(TestDefaultRendering)).SetTestName(nameof(TestDefaultRenderingOfMultipleTargets)); eyes.SetConfiguration(config); try { eyes.Open(driver); eyes.Check(Target.Window()); eyes.Close(); } finally { eyes.Abort(); driver.Quit(); } TestResultsSummary allTestResults = runner.GetAllTestResults(); string batchId = null; string batchName = null; foreach (TestResultContainer trc in allTestResults) { if (batchId == null) { batchId = trc.TestResults.BatchId; } if (batchName == null) { batchName = trc.TestResults.BatchName; } Assert.AreEqual(batchId, trc.TestResults.BatchId); Assert.AreEqual(batchName, trc.TestResults.BatchName); } }
public void TestWebsite(string website, string name) { VisualGridRunner runner = new VisualGridRunner(10); IWebDriver driver = SeleniumUtils.CreateChromeDriver(); Eyes eyes = InitEyes(driver, runner, website, 1000, 700, writeResources: true, verbose: true, testMethod: name); //Thread.Sleep(3000); try { eyes.Check(name, Target.Window().Fully()); eyes.CloseAsync(); runner.GetAllTestResults(); } finally { eyes.Abort(); driver.Quit(); } }
public void TestDelete() { IWebDriver driver = SeleniumUtils.CreateChromeDriver(); Eyes eyes = new Eyes(); eyes.Batch = TestDataProvider.BatchInfo; try { driver = eyes.Open(driver, "TestSessionConnector", "TestSessionConnector", new Size(800, 600)); driver.Url = "https://applitools.com/helloworld"; eyes.Check("Hello!", Target.Window()); TestResults results = eyes.Close(); results.Delete(); } finally { driver.Quit(); eyes.Abort(); } }
public void TestPNC() { VisualGridRunner runner = new VisualGridRunner(10); IWebDriver driver = SeleniumUtils.CreateChromeDriver(); Eyes eyes = InitEyes(driver, runner, "https://www.pnc.com/", 1000, 700, false); try { eyes.Check("PNC", Target.Window().Fully().SendDom() .Layout(By.CssSelector("#main-header > div.highlighted-topics-tout-container-parsys.limited-parsys")) .Layout(By.CssSelector("#main-header > div.promo-parsys.limited-parsys")) .Ignore(By.CssSelector("#oo-feedback > img"))); eyes.CloseAsync(); runner.GetAllTestResults(); } finally { eyes.Abort(); driver.Quit(); } }
public void TestSuccess() { VisualGridRunner visualGridRunner = new VisualGridRunner(10); visualGridRunner.SetLogHandler(TestUtils.InitLogHandler()); Size[] ViewportList = { new Size(800, 600), new Size(700, 500), new Size(1200, 800), new Size(1600, 1200) }; IWebDriver webDriver = SeleniumUtils.CreateChromeDriver(); webDriver.Url = "https://applitools.com/helloworld"; Eyes eyes = null; try { foreach (Size viewport in ViewportList) { eyes = InitEyes_(null, webDriver, viewport); eyes.Check(Target.Window().Fully()); eyes.CloseAsync(); eyes = InitEyes_(visualGridRunner, webDriver, viewport); eyes.Check(Target.Window().Fully()); eyes.CloseAsync(); } TestResultsSummary results = visualGridRunner.GetAllTestResults(); Assert.AreEqual(ViewportList.Length, results?.Count); } finally { webDriver?.Quit(); eyes?.Abort(); } }
public void TestCloseAsync() { EyesRunner runner = new VisualGridRunner(10); Eyes eyes = new Eyes(runner); IWebDriver driver = SeleniumUtils.CreateChromeDriver(); TestUtils.SetupLogging(eyes); driver.Url = "https://applitools.com/helloworld"; try { Configuration config = new Configuration(); config.SetAppName("Visual Grid Tests").SetTestName("Test CloseAsync").SetBatch(TestDataProvider.BatchInfo); foreach (BrowserType b in Enum.GetValues(typeof(BrowserType))) { if (b == BrowserType.EDGE || b == BrowserType.EDGE_LEGACY) { continue; } config.AddBrowser(800, 600, b); } eyes.SetConfiguration(config); var combinations = config.GetBrowsersInfo(); Assert.Greater(combinations.Count, 1); eyes.Open(driver); eyes.CheckWindow(); driver.Quit(); driver = null; ICollection <Task <TestResultContainer> > closeTasks = eyes.CloseAsync_(); Assert.AreEqual(combinations.Count, closeTasks.Count); runner.GetAllTestResults(); } finally { if (driver != null) { driver.Quit(); } eyes.Abort(); } }
public void TestIE11(StitchModes stitchMode) { Eyes eyes = new Eyes(); TestUtils.SetupLogging(eyes); InternetExplorerOptions options = new InternetExplorerOptions(); options.BrowserVersion = "11.0"; options.AddAdditionalCapability("resolution", "1024x768"); Dictionary <string, object> browserstackOptions = new Dictionary <string, object>(); browserstackOptions.Add("os", "Windows"); browserstackOptions.Add("osVersion", "10"); browserstackOptions.Add("userName", TestDataProvider.BROWSERSTACK_USERNAME); browserstackOptions.Add("accessKey", TestDataProvider.BROWSERSTACK_ACCESS_KEY); options.AddAdditionalCapability("bstack:options", browserstackOptions, true); IWebDriver driver = null; try { driver = new RemoteWebDriver(new Uri(TestDataProvider.BROWSERSTACK_SELENIUM_URL), options); driver.Url = "https://applitools.github.io/demo/TestPages/FramesTestPage/"; eyes.StitchMode = stitchMode; eyes.Batch = TestDataProvider.BatchInfo; eyes.Open(driver, "TestBrowserStack", "TesIE11_" + stitchMode.ToString().ToUpper(), new Size(800, 600)); eyes.Check("viewport", Target.Window().Fully(false).SendDom(false)); eyes.Check("full page", Target.Window().Fully(true).SendDom(false)); eyes.Close(); } finally { driver?.Quit(); eyes.Abort(); } }
public void TestEyesExceptions_VG() { IWebDriver driver = SeleniumUtils.CreateChromeDriver(); VisualGridRunner runner = new VisualGridRunner(10); Eyes eyes = new Eyes(runner); try { runner.ApiKey = null; eyes.ApiKey = ""; Assert.That(() => { eyes.Open(driver); }, Throws.Exception.With.InstanceOf <EyesException>().With.Property("Message").EqualTo("API key not set! Log in to https://applitools.com to obtain your API key and use the 'Eyes.ApiKey' property to set it.")); eyes.ApiKey = "someAPIkey"; Assert.That(() => { eyes.Open(driver); }, Throws.ArgumentNullException.With.Property("ParamName").EqualTo("appName")); Configuration conf = new Configuration(); conf.SetAppName(""); eyes.SetConfiguration(conf); Assert.That(() => { eyes.Open(driver); }, Throws.ArgumentException.With.Property("ParamName").EqualTo("appName")); conf.SetAppName("app"); eyes.SetConfiguration(conf); Assert.That(() => { eyes.Open(driver); }, Throws.ArgumentNullException.With.Property("ParamName").EqualTo("testName")); conf.SetTestName(""); eyes.SetConfiguration(conf); Assert.That(() => { eyes.Open(driver); }, Throws.ArgumentException.With.Property("ParamName").EqualTo("testName")); conf.SetTestName("test"); eyes.SetConfiguration(conf); eyes.Open(driver); Assert.That(() => { TestResults results = eyes.Close(); results?.Delete(); runner.GetAllTestResults(); }, Throws.InvalidOperationException.With.Property("Message").EqualTo("Eyes not open")); } finally { eyes.Abort(); driver.Quit(); } }
public void TestSendDOM_Selector() { IWebDriver webDriver = SeleniumUtils.CreateChromeDriver(); webDriver.Url = "https://applitools.github.io/demo/TestPages/DomTest/dom_capture.html"; Eyes eyes = new Eyes(); eyes.Batch = TestDataProvider.BatchInfo; try { eyes.Open(webDriver, "Test SendDom", "Test SendDom", new Size(1000, 700)); eyes.Check("region", Target.Region(By.CssSelector("#scroll1"))); TestResults results = eyes.Close(false); bool hasDom = GetHasDom_(eyes, results); Assert.IsTrue(hasDom); } finally { eyes.Abort(); webDriver.Quit(); } }
private static void CaptureDom(string url, Action <IWebDriver> initCode = null, [CallerMemberName] string testName = null) { IWebDriver webDriver = SeleniumUtils.CreateChromeDriver(); webDriver.Url = url; Logger logger = new Logger(); logger.SetLogHandler(TestUtils.InitLogHandler(testName)); initCode?.Invoke(webDriver); Eyes eyes = new Eyes(); try { eyes.Batch = TestDataProvider.BatchInfo; eyes.AppName = "Test Send DOM"; eyes.TestName = testName; EyesWebDriver eyesWebDriver = (EyesWebDriver)eyes.Open(webDriver); //DomCapture domCapture = new DomCapture(logger, eyesWebDriver); eyes.CheckWindow(); TestResults results = eyes.Close(false); bool hasDom = GetHasDom_(eyes, results); Assert.IsTrue(hasDom); //string actualDomJsonString = domCapture.GetFullWindowDom(); //WriteDomJson(logger, actualDomJsonString); } catch (Exception ex) { CommonUtils.LogExceptionStackTrace(logger, Stage.TestFramework, StageType.Failed, ex, nameof(TestSendDom)); throw; } finally { eyes.Abort(); webDriver.Quit(); } }
public void TestDomSerialization() { string expectedDomJson = CommonUtils.ReadResourceFile("Test.Eyes.Selenium.DotNet.Resources.ExpectedDom_CorsCssTestPage.json"); IWebDriver driver = SeleniumUtils.CreateChromeDriver(); Eyes eyes = new Eyes(); Configuration conf = new Configuration(); conf.SetAppName("app"); conf.SetTestName("test"); conf.SetViewportSize(800, 600); conf.SetHideScrollbars(true); conf.SetBatch(TestDataProvider.BatchInfo); eyes.SetConfiguration(conf); eyes.SetLogHandler(TestUtils.InitLogHandler(nameof(TestDom))); EyesWebDriver eyesWebDriver = (EyesWebDriver)eyes.Open(driver); driver.Url = "https://applitools.github.io/demo/TestPages/CorsCssTestPage/"; try { UserAgent ua = eyes.seleniumEyes_.userAgent_; DomCapture domCapture = new DomCapture(eyes.Logger, eyesWebDriver, ua); string json = domCapture.GetFullWindowDom(); object expectedJsonObj = JsonConvert.DeserializeObject(expectedDomJson); object jsonObj = JsonConvert.DeserializeObject(json); expectedDomJson = JsonConvert.SerializeObject(expectedJsonObj, Formatting.Indented); json = JsonConvert.SerializeObject(jsonObj, Formatting.Indented); Assert.AreEqual(expectedDomJson, json); } finally { eyes.Abort(); driver.Quit(); } }