public void ShouldNotAllowScrollingWhenOriginOffsetIsOutOfViewport() { driver.Url = scrollFrameInViewport; var scrollOrigin = new WheelInputDevice.ScrollOrigin { Viewport = true }; Assert.That(() => new Actions(driver).Scroll(-10, -10, 0, 200, scrollOrigin).Build().Perform(), Throws.InstanceOf <MoveTargetOutOfBoundsException>()); }
public void ShouldNotAllowScrollingWhenElementOriginOutOfViewport() { driver.Url = scrollFrameOutOfViewport; IWebElement footer = driver.FindElement(By.TagName("footer")); var scrollOrigin = new WheelInputDevice.ScrollOrigin { Element = footer }; Assert.That(() => new Actions(driver).Scroll(0, 50, 0, 0, scrollOrigin).Build().Perform(), Throws.InstanceOf <MoveTargetOutOfBoundsException>()); }
public void ShouldAllowScrollingFromViewportByGivenAmount() { driver.Url = scrollFrameOutOfViewport; IWebElement footer = driver.FindElement(By.TagName("footer")); int deltaY = footer.Location.Y; var scrollOrigin = new WheelInputDevice.ScrollOrigin { Viewport = true }; new Actions(driver).Scroll(0, 0, 0, deltaY, scrollOrigin).Build().Perform(); Assert.IsTrue(IsInViewport(footer)); }
public void ShouldAllowScrollingToAnElement() { driver.Url = scrollFrameOutOfViewport; IWebElement iframe = driver.FindElement(By.TagName("iframe")); Assert.IsFalse(IsInViewport(iframe)); var scrollOrigin = new WheelInputDevice.ScrollOrigin { Element = iframe }; new Actions(driver).Scroll(0, 0, 0, 0, scrollOrigin).Build().Perform(); Assert.IsTrue(IsInViewport(iframe)); }
public void ShouldScrollFromElementByGivenAmount() { driver.Url = scrollFrameOutOfViewport; IWebElement iframe = driver.FindElement(By.TagName("iframe")); WheelInputDevice.ScrollOrigin scrollOrigin = new WheelInputDevice.ScrollOrigin { Element = iframe }; new Actions(driver).ScrollFromOrigin(scrollOrigin, 0, 200).Build().Perform(); driver.SwitchTo().Frame(iframe); IWebElement checkbox = driver.FindElement(By.Name("scroll_checkbox")); Assert.IsTrue(IsInViewport(checkbox)); }
public void ShouldAllowScrollingFromViewportByGivenAmountFromOrigin() { driver.Url = scrollFrameInViewport; var scrollOrigin = new WheelInputDevice.ScrollOrigin { Viewport = true }; new Actions(driver).Scroll(10, 10, 0, 200, scrollOrigin).Build().Perform(); IWebElement iframe = driver.FindElement(By.TagName("iframe")); driver.SwitchTo().Frame(iframe); IWebElement checkbox = driver.FindElement(By.Name("scroll_checkbox")); Assert.IsTrue(IsInViewport(checkbox)); }
public void ShouldAllowScrollingFromElementByGivenAmountWithOffset() { driver.Url = scrollFrameOutOfViewport; IWebElement footer = driver.FindElement(By.TagName("footer")); var scrollOrigin = new WheelInputDevice.ScrollOrigin { Element = footer }; new Actions(driver).Scroll(0, -50, 0, 200, scrollOrigin).Build().Perform(); IWebElement iframe = driver.FindElement(By.TagName("iframe")); driver.SwitchTo().Frame(iframe); IWebElement checkbox = driver.FindElement(By.Name("scroll_checkbox")); Assert.IsTrue(IsInViewport(checkbox)); }
/// <summary> /// Scrolls by provided amount based on a provided origin. /// </summary> /// <remarks> /// The scroll origin is either the center of an element or the upper left of the viewport plus any offsets. /// If the origin is an element, and the element is not in the viewport, the bottom of the element will first /// be scrolled to the bottom of the viewport. /// </remarks> /// <param name="scrollOrigin">Where scroll originates (viewport or element center) plus provided offsets.</param> /// <param name="deltaX">Distance along X axis to scroll using the wheel. A negative value scrolls left.</param> /// <param name="deltaY">Distance along Y axis to scroll using the wheel. A negative value scrolls up.</param> /// <returns>A self-reference to this <see cref="Actions"/>.</returns> /// <exception cref="MoveTargetOutOfBoundsException">If the origin with offset is outside the viewport.</exception> public Actions ScrollFromOrigin(WheelInputDevice.ScrollOrigin scrollOrigin, int deltaX, int deltaY) { if (scrollOrigin.Viewport && scrollOrigin.Element != null) { throw new ArgumentException("viewport can not be true if an element is defined.", nameof(scrollOrigin)); } if (scrollOrigin.Viewport) { this.actionBuilder.AddAction(this.defaultWheel.CreateWheelScroll(CoordinateOrigin.Viewport, scrollOrigin.XOffset, scrollOrigin.YOffset, deltaX, deltaY, DefaultScrollDuration)); } else { this.actionBuilder.AddAction(this.defaultWheel.CreateWheelScroll(scrollOrigin.Element, scrollOrigin.XOffset, scrollOrigin.YOffset, deltaX, deltaY, DefaultScrollDuration)); } return(this); }