Drag and Drop Smoothly an Element in Selenium C#

Viewed 112

I'm trying to drag a slider to a specific position, the motion of slider is not smooth, it is moving in a discrete way. Is there any workaround for my case ,maybe by executing a javascript code? This is the code I am using in c#.

                List<int> Track = getTrack(distance);

                var hold = builder.ClickAndHold(slider);
                foreach(int t in Track)
                {
                    hold.MoveByOffset(t, 0);
                }
                    
                hold.Release().Build().Perform(); 
1 Answers

This might not be an answer, but I can't comment due to low reputation. Try OpenQA.Selenium.Interactions.Actions class:

 Actions actions = new Actions(driver);

 IWebElement from = driver.FindElement(By.XPath("start point of slider");
 IWebElement to = driver.FindElement(By.XPath("end point of slider"));

 actions.DragAndDrop(from, to).Perform();
Related