Пример #1
0
        public void How_To_Automate_Slider()
        {
            IWebElement slider            = chromedriver.FindElement(By.Id("slider"));
            IWebElement sliderEndPosition = chromedriver.FindElement(By.Id("slider"));

            //Oneway
            OpenQA.Selenium.Interactions.Actions action = new OpenQA.Selenium.Interactions.Actions(chromedriver);
            action.DragAndDropToOffset(slider, 30, 30)
            .Build()
            .Perform();

            //Another way
            action.DragAndDrop(slider, sliderEndPosition)
            .Build()
            .Perform();
            //Anotherway(loop by how many times you want to shift)
            slider.SendKeys(Keys.Right);

            //One more way
            action.MoveToElement(slider)
            .ClickAndHold()
            .MoveByOffset(0, 250)
            .Release()
            .Perform();
        }
Пример #2
0
 /// <summary>Holds down the left mouse button on the source element, then moves to the target element and releases the mouse button.</summary>
 /// <param name="webelement_source">The element to mouse down.</param>
 /// <param name="offset_x">X offset to move to.</param>
 /// <param name="offset_y">Y offset to move to.</param>
 /// <returns></returns>
 public Actions dragAndDropByOffset(WebElement webelement_source, int offset_x, int offset_y)
 {
     _actions.DragAndDropToOffset(webelement_source._webElement, offset_x, offset_y);
     return(this);
 }