public void TestCreateDomSnapshotCollectsCookiesWhenDisabledUsingFluentApi() { IWebDriver driver = SeleniumUtils.CreateChromeDriver(); driver.Url = "http://applitools.github.io/demo/TestPages/CookiesTestPage/"; Eyes eyes = Setup(driver); VisualGridRunner runner = (VisualGridRunner)eyes.runner_; try { Configuration config = eyes.GetConfiguration(); config .SetAppName("test app").SetTestName("test name") .SetBatch(TestDataProvider.BatchInfo); eyes.SetConfiguration(config); EyesWebDriver eyesDriver = (EyesWebDriver)eyes.Open(driver); EyesWebDriverTargetLocator switchTo = (EyesWebDriverTargetLocator)eyesDriver.SwitchTo(); UserAgent userAgent = UserAgent.ParseUserAgentString(eyesDriver.GetUserAgent()); FrameData scriptResult = VisualGridEyes.CaptureDomSnapshot_( switchTo, userAgent, config, Target.Window().UseCookies(false), runner, eyesDriver, runner.Logger); Assert.IsNull(scriptResult.Cookies); Assert.IsNull(scriptResult.Frames[0].Cookies); Assert.IsNull(scriptResult.Frames[0].Frames[0].Cookies); } finally { driver.Quit(); eyes.AbortIfNotClosed(); runner.StopServiceRunner(); } }
private Dictionary <string, string> RecurseFrames_(List <string> missingFramesList) { logger_.Verbose("enter"); Dictionary <string, string> framesData = new Dictionary <string, string>(); EyesWebDriverTargetLocator switchTo = (EyesWebDriverTargetLocator)webDriver_.SwitchTo(); FrameChain fc = webDriver_.GetFrameChain().Clone(); foreach (string missingFrameLine in missingFramesList) { try { logger_.Verbose("handling frame xpath: {0}", missingFrameLine); string originLocation = (string)webDriver_.ExecuteScript("return document.location.href"); string[] missingFrameXpaths = missingFrameLine.Split(','); foreach (string missingFrameXpath in missingFrameXpaths) { IWebElement frame = webDriver_.FindElement(By.XPath(missingFrameXpath)); switchTo.Frame(frame); } string locationAfterSwitch = (string)webDriver_.ExecuteScript("return document.location.href"); if (locationAfterSwitch.Equals(originLocation, StringComparison.OrdinalIgnoreCase)) { logger_.Log("WARNING! Failed switching into frame. HREF: {0}", locationAfterSwitch); framesData.Add(missingFrameLine, string.Empty); continue; } string result = GetFrameDom_(); framesData.Add(missingFrameLine, result); } catch (Exception e) { logger_.Log("Error: " + e); framesData.Add(missingFrameLine, string.Empty); } finally { switchTo.Frames(fc); } } logger_.Verbose("exit"); return(framesData); }
private Dictionary <string, string> RecurseFrames_(List <string> missingFramesList, string[] testIds) { Dictionary <string, string> framesData = new Dictionary <string, string>(); EyesWebDriverTargetLocator switchTo = (EyesWebDriverTargetLocator)webDriver_.SwitchTo(); FrameChain fc = webDriver_.GetFrameChain().Clone(); foreach (string missingFrameLine in missingFramesList) { try { string originLocation = (string)webDriver_.ExecuteScript("return document.location.href"); string[] missingFrameXpaths = missingFrameLine.Split(','); foreach (string missingFrameXpath in missingFrameXpaths) { IWebElement frame = webDriver_.FindElement(By.XPath(missingFrameXpath)); switchTo.Frame(frame); } string locationAfterSwitch = (string)webDriver_.ExecuteScript("return document.location.href"); if (locationAfterSwitch.Equals(originLocation, StringComparison.OrdinalIgnoreCase)) { logger_.Log(TraceLevel.Warn, testIds, Stage.Check, StageType.DomScript, new { message = "Failed switching into frame.", locationAfterSwitch }); framesData.Add(missingFrameLine, string.Empty); continue; } string result = GetFrameDom_(testIds); framesData.Add(missingFrameLine, result); } catch (Exception e) { CommonUtils.LogExceptionStackTrace(logger_, Stage.Check, e, testIds); framesData.Add(missingFrameLine, string.Empty); } finally { switchTo.Frames(fc); } } return(framesData); }
public void TestCreateDomSnapshotCollectsCookiesWhenNotHandlingCorsFrames() { IWebDriver driver = SeleniumUtils.CreateChromeDriver(); driver.Url = "http://applitools.github.io/demo/TestPages/CookiesTestPage/"; Eyes eyes = Setup(driver); VisualGridRunner runner = (VisualGridRunner)eyes.runner_; try { Configuration config = eyes.GetConfiguration(); config .SetAppName("test app").SetTestName("test name") .SetBatch(TestDataProvider.BatchInfo) .SetUseCookies(true); eyes.SetConfiguration(config); EyesWebDriver eyesDriver = (EyesWebDriver)eyes.Open(driver); EyesWebDriverTargetLocator switchTo = (EyesWebDriverTargetLocator)eyesDriver.SwitchTo(); UserAgent userAgent = UserAgent.ParseUserAgentString(eyesDriver.GetUserAgent()); FrameData scriptResult = VisualGridEyes.CaptureDomSnapshot_( switchTo, userAgent, config, Target.Window(), runner, eyesDriver, runner.Logger); CollectionAssert.AreEquivalent(new Cookie[] { new Cookie("frame1", "1", "/demo/TestPages/CookiesTestPage", "applitools.github.io") { HttpOnly = false, Secure = false }, new Cookie("index", "1", "/demo/TestPages/CookiesTestPage", "applitools.github.io") { HttpOnly = false, Secure = false } }, scriptResult.Cookies); CollectionAssert.AreEquivalent(new Cookie[] { new Cookie("frame1", "1", "/demo/TestPages/CookiesTestPage", "applitools.github.io") { HttpOnly = false, Secure = false }, new Cookie("index", "1", "/demo/TestPages/CookiesTestPage", "applitools.github.io") { HttpOnly = false, Secure = false } }, scriptResult.Frames[0].Cookies); CollectionAssert.AreEquivalent(new Cookie[] { new Cookie("frame1", "1", "/demo/TestPages/CookiesTestPage", "applitools.github.io") { HttpOnly = false, Secure = false }, new Cookie("index", "1", "/demo/TestPages/CookiesTestPage", "applitools.github.io") { HttpOnly = false, Secure = false }, new Cookie("frame2", "1", "/demo/TestPages/CookiesTestPage/subdir", "applitools.github.io") { HttpOnly = false, Secure = false } }, scriptResult.Frames[0].Frames[0].Cookies); } finally { driver.Quit(); eyes.AbortIfNotClosed(); runner.StopServiceRunner(); } }
//[Test] public void TestVisualGridSkipList() { VisualGridRunner runner = new VisualGridRunner(10); Eyes eyes = new Eyes(runner); TestUtils.SetupLogging(eyes); //eyes.visualGridEyes_.EyesConnectorFactory = new MockEyesConnectorFactory(); Configuration config = eyes.GetConfiguration(); config.AddBrowser(1050, 600, BrowserType.CHROME); config.SetBatch(TestDataProvider.BatchInfo); eyes.SetConfiguration(config); AutoResetEvent waitHandle = new AutoResetEvent(false); runner.debugLock_ = waitHandle; IWebDriver driver = SeleniumUtils.CreateChromeDriver(); //driver.Url = "https://applitools.github.io/demo/DomSnapshot/test-iframe.html"; driver.Url = "https://applitools.github.io/demo/TestPages/VisualGridTestPage/"; try { MockEyesConnector mockEyesConnector = OpenEyesAndGetConnector_(eyes, config, driver, out IWebDriver eyesDriver); eyes.Check(Target.Window()); string[] expectedUrls = new string[] { "https://applitools.github.io/demo/TestPages/VisualGridTestPage/AbrilFatface-Regular.woff2", "https://applitools.github.io/demo/TestPages/VisualGridTestPage/applitools_logo_combined.svg", "https://applitools.github.io/demo/TestPages/VisualGridTestPage/company_name.png", "https://applitools.github.io/demo/TestPages/VisualGridTestPage/frame.html", "https://applitools.github.io/demo/TestPages/VisualGridTestPage/innerstyle0.css", "https://applitools.github.io/demo/TestPages/VisualGridTestPage/innerstyle1.css", "https://applitools.github.io/demo/TestPages/VisualGridTestPage/innerstyle2.css", "https://applitools.github.io/demo/TestPages/VisualGridTestPage/logo.svg", "https://applitools.github.io/demo/TestPages/VisualGridTestPage/minions-800x500_green_sideways.png", "https://applitools.github.io/demo/TestPages/VisualGridTestPage/minions-800x500.jpg", "https://applitools.github.io/demo/TestPages/VisualGridTestPage/slogan.svg", "https://applitools.github.io/demo/TestPages/VisualGridTestPage/style0.css", "https://applitools.github.io/demo/TestPages/VisualGridTestPage/style1.css", "https://fonts.googleapis.com/css?family=Raleway", "https://fonts.googleapis.com/css?family=Unlock", "https://fonts.gstatic.com/s/raleway/v18/1Ptxg8zYS_SKggPN4iEgvnHyvveLxVvaorCFPrEHJA.woff2", "https://fonts.gstatic.com/s/raleway/v18/1Ptxg8zYS_SKggPN4iEgvnHyvveLxVvaorCGPrEHJA.woff2", "https://fonts.gstatic.com/s/raleway/v18/1Ptxg8zYS_SKggPN4iEgvnHyvveLxVvaorCHPrEHJA.woff2", "https://fonts.gstatic.com/s/raleway/v18/1Ptxg8zYS_SKggPN4iEgvnHyvveLxVvaorCIPrE.woff2", "https://fonts.gstatic.com/s/raleway/v18/1Ptxg8zYS_SKggPN4iEgvnHyvveLxVvaorCMPrEHJA.woff2", "https://fonts.gstatic.com/s/unlock/v10/7Au-p_8ykD-cDl72LwLT.woff2", "https://use.fontawesome.com/releases/v5.8.2/css/all.css", "https://use.fontawesome.com/releases/v5.8.2/webfonts/fa-brands-400.eot", "https://use.fontawesome.com/releases/v5.8.2/webfonts/fa-brands-400.svg", "https://use.fontawesome.com/releases/v5.8.2/webfonts/fa-brands-400.ttf", "https://use.fontawesome.com/releases/v5.8.2/webfonts/fa-brands-400.woff", "https://use.fontawesome.com/releases/v5.8.2/webfonts/fa-brands-400.woff2", "https://use.fontawesome.com/releases/v5.8.2/webfonts/fa-regular-400.eot", "https://use.fontawesome.com/releases/v5.8.2/webfonts/fa-regular-400.svg", "https://use.fontawesome.com/releases/v5.8.2/webfonts/fa-regular-400.ttf", "https://use.fontawesome.com/releases/v5.8.2/webfonts/fa-regular-400.woff", "https://use.fontawesome.com/releases/v5.8.2/webfonts/fa-regular-400.woff2", "https://use.fontawesome.com/releases/v5.8.2/webfonts/fa-solid-900.eot", "https://use.fontawesome.com/releases/v5.8.2/webfonts/fa-solid-900.svg", "https://use.fontawesome.com/releases/v5.8.2/webfonts/fa-solid-900.ttf", "https://use.fontawesome.com/releases/v5.8.2/webfonts/fa-solid-900.woff", "https://use.fontawesome.com/releases/v5.8.2/webfonts/fa-solid-900.woff2" }; waitHandle.WaitOne(TimeSpan.FromSeconds(5)); CollectionAssert.AreEquivalent(expectedUrls, ((IVisualGridRunner)runner).CachedBlobsURLs.Keys); UserAgent userAgent = eyes.visualGridEyes_.userAgent_; EyesWebDriverTargetLocator switchTo = (EyesWebDriverTargetLocator)eyesDriver.SwitchTo(); FrameData domData = VisualGridEyes.CaptureDomSnapshot_( switchTo, userAgent, config, runner, (EyesWebDriver)eyesDriver, eyes.Logger); //DomAnalyzer domAnalyzer = new DomAnalyzer(runner, // domData, // eyes.visualGridEyes_.eyesConnector_, // userAgent, // eyes.visualGridEyes_.debugResourceWriter_); //IDictionary<string, RGridResource> resourceMap = domAnalyzer.Analyze(); //CollectionAssert.AreEquivalent(expectedUrls, resourceMap.Keys); //eyes.Check(Target.Window()); eyes.Close(); runner.GetAllTestResults(); } finally { eyes.AbortIfNotClosed(); driver.Close(); } }