예제 #1
0
        /// <summary>
        /// JavaScript method to scroll an element into the view
        /// </summary>
        /// <param name="element">Web element</param>
        /// <param name="x">Horizontal direction</param>
        /// <param name="y">Vertical direction</param>
        public static void ScrollIntoView(this IWebElement element, int x, int y)
        {
            var driver = SeleniumUtilities.SearchContextToWebDriver(element);

            ScrollIntoView(element);
            ExecuteScrolling(driver, x, y);
        }
예제 #2
0
        /// <summary>
        /// Drag and drop an item to a destination, plus or minus and X and Y offsets
        /// </summary>
        /// <param name="source">Element to drag and drop</param>
        /// <param name="destination">Where to drop the element, plus or minus the offsets</param>
        /// <param name="pixelsXOffset">Integer of pixels to be moved (Positive or negative) horizontally</param>
        /// <param name="pixelsYOffset">Integer of pixels to be moved (Positive or negative) vertically </param>
        public static void DragAndDropToOffset(IWebElement source, IWebElement destination, int pixelsXOffset, int pixelsYOffset)
        {
            Actions builder = new Actions(SeleniumUtilities.SearchContextToWebDriver(source));

            // Move to element goes to the top left corner so compensate for that
            int horizontalOffset = (destination.Size.Width / 2) + pixelsXOffset;
            int verticalOffset   = (destination.Size.Height / 2) + pixelsYOffset;

            builder.ClickAndHold(source).MoveToElement(destination, horizontalOffset, verticalOffset).Release().Build().Perform();
        }
예제 #3
0
        /// <summary>
        /// Drag and drop an element
        /// </summary>
        /// <param name="source">Element to drag and drop</param>
        /// <param name="destination">Where to drop the element</param>
        public static void DragAndDrop(this IWebElement source, IWebElement destination)
        {
            Actions builder = new Actions(SeleniumUtilities.SearchContextToWebDriver(source));

            builder.DragAndDrop(source, destination).Build().Perform();
        }
예제 #4
0
        /// <summary>
        /// Performs a hover over on an element
        /// </summary>
        /// <param name="element">The web element</param>
        public static void HoverOver(this IWebElement element)
        {
            Actions builder = new Actions(SeleniumUtilities.SearchContextToWebDriver(element));

            builder.MoveToElement(element).Build().Perform();
        }
예제 #5
0
        /// <summary>
        /// Performs a right-click on an element
        /// </summary>
        /// <param name="element">The web element</param>
        public static void DoubleClick(this IWebElement element)
        {
            Actions builder = new Actions(SeleniumUtilities.SearchContextToWebDriver(element));

            builder.DoubleClick(element).Build().Perform();
        }
예제 #6
0
        /// <summary>
        /// Drag and drop an element to an X and Y offsets
        /// </summary>
        /// <param name="source">Element to drag and drop</param>
        /// <param name="pixelsXOffset">Integer of pixels to be moved (Positive or negative) horizontally</param>
        /// <param name="pixelsYOffset">Integer of pixels to be moved (Positive or negative) vertically </param>
        public static void DragAndDropToOffset(this IWebElement source, int pixelsXOffset, int pixelsYOffset)
        {
            Actions builder = new Actions(SeleniumUtilities.SearchContextToWebDriver(source));

            builder.DragAndDropToOffset(source, pixelsXOffset, pixelsYOffset).Build().Perform();
        }
예제 #7
0
        /// <summary>
        /// JavaScript method to scroll an element into the view
        /// </summary>
        /// <param name="element">IWebElement</param>
        public static void ScrollIntoView(this IWebElement element)
        {
            var driver = SeleniumUtilities.SearchContextToWebDriver(element);

            driver.ScrollIntoView(element);
        }