public void TestSimpleCodedRegions() { IWebDriver webDriver = SeleniumUtils.CreateChromeDriver(); webDriver.Manage().Window.Size = new Size(740, 600); webDriver.Url = "data:text/html,<!DOCTYPE html><html><body><header style='height: 50px'>header</header><main style='position: relative;'><section><div style='position: relative; border: 3px blue solid; height: 30px;'>box</div></section></main></body></html>"; try { IWebElement headerElement = webDriver.FindElement(By.CssSelector("header")); IWebElement mainElement = webDriver.FindElement(By.CssSelector("main")); IWebElement boxElement = webDriver.FindElement(By.CssSelector("div")); IJavaScriptExecutor jsExecutor = (IJavaScriptExecutor)webDriver; Rectangle headerRect = EyesRemoteWebElement.GetVisibleElementRect(headerElement, jsExecutor); Rectangle mainRect = EyesRemoteWebElement.GetVisibleElementRect(mainElement, jsExecutor); Rectangle boxRect = EyesRemoteWebElement.GetVisibleElementRect(boxElement, jsExecutor); Assert.AreEqual(new Rectangle(8, 8, 724, 50), headerRect); Assert.AreEqual(new Rectangle(8, 58, 724, 36), mainRect); Assert.AreEqual(new Rectangle(8, 58, 724, 36), boxRect); } finally { webDriver.Quit(); } }
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 IList <IMutableRegion> GetRegions(IEyesBase eyesBase, IEyesScreenshot screenshot) { if (!(element_ is EyesRemoteWebElement eyesElement)) { eyesElement = new EyesRemoteWebElement(eyesBase.Logger, ((SeleniumEyes)eyesBase).GetDriver(), element_); } Rectangle r = EyesSeleniumUtils.GetVisibleElementBounds(eyesElement); Point pTag = screenshot.ConvertLocation(r.Location, CoordinatesTypeEnum.CONTEXT_RELATIVE, CoordinatesTypeEnum.SCREENSHOT_AS_IS); return(new MutableRegion[] { new MutableRegion(pTag.X, pTag.Y, r.Width, r.Height) }); }
public void TestSarinePartialScroll() { TestedPageUrl = "http://api.sarine.com/viewer/v1/9NUKVEJ568E/NWPZMUVJVRX"; GetEyes().HideScrollbars = false; GetDriver().FindElement(By.Id("menu-item-carousel")).Click(); WebDriverWait wait = new WebDriverWait(GetDriver(), TimeSpan.FromSeconds(30)); IWebElement frame = wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("#stl > iframe"))); EyesRemoteWebElement eyesFrame = new EyesRemoteWebElement(GetEyes().Logger, (EyesWebDriver)GetDriver(), frame); Rectangle region = eyesFrame.GetClientBounds(); Thread.Sleep(1000); GetEyes().Check(Target.Window().WithName("sarine partial scroll").Fully(false).Ignore(region)); }
/// <returns>The entire size of the current context.</returns> public Size GetEntireSize() { Size size = EyesRemoteWebElement.GetEntireSize(ScrolledElement, executor_, logger_); return(size); }