My code is:
By slider_humidity = By.XPath("ExampleXpath");
var hSlider = driver.FindElement(slider_humidity);
Actions action = new Actions(driver);
action.MoveToElement(hSlider, 0, 0); //this will make it to start at 0,0 of the slider
action.ClickAndHold(); //don't pass the element, now it will click current mouse location which is (0,0)
action.MoveByOffset(pixelstomove, 0); // move by 30 pixel from 0
action.Build().Perform();
It seem to be too fast for my targeted website and I need to change the speed of it. It basically goes from point 0 to the given point instantly. I however would like it to slide the slider slowly. Also alternatives way using Javascript inside C# would be apprecited, as long as I can adjust the speed to my wishes.
CodePudding user response:
Try this:
By slider_humidity = By.XPath("ExampleXpath");
var hSlider = driver.FindElement(slider_humidity);
PointerInputDevice mouse = new PointerInputDevice();
Actions action = new Actions(driver);
action.MoveToElement(hSlider, 0, 0) //this will make it to start at 0,0 of the slider
.ClickAndHold() //don't pass the element, now it will click current mouse location which is (0,0)
.tick(mouse.CreatePointerMove(hSlider, pixelstomove, 0, TimeSpan.FromMilliseconds(200))) // Move by <pixelstomove> in x-offset
.Build()
.Perform();