How to slide slider on horizontal progress bar URL: http://jqueryui.com/slider/ I tried to scroll the slider but it did not work for me. My code using Java is below:
package UKRTEST;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
public class Ex_DragndDrop {
public static void main(String[] args) throws InterruptedException {
WebDriver driver;
System.setProperty("webdriver.chrome.driver", "E:\\Chrome Driver\\chromedriver.exe");
driver = new ChromeDriver();
String URL = "http://www.seleniumeasy.com/test/drag-drop-range-sliders-demo.html";
driver.get(URL);
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10000, TimeUnit.MILLISECONDS);
Thread.sleep(3000);
Actions builder = new Actions(driver);
WebElement draggablePartOfScrollbar = driver
.findElement(By.xpath("/html/body/div[2]/div/div[2]/section/div[1]/div[1]/div/input"));
// To get pixel count of Slider X axis and Y axis(267,25)
Dimension sliderWidth = draggablePartOfScrollbar.getSize();
System.out.println(sliderWidth);
// We need to give below value in +00 to move slider to 50 and +130 to move slider to 100,-100 to move slider to 12
int numberOfRangeToDragTheSlider = -100;
builder.moveToElement(draggablePartOfScrollbar).clickAndHold().moveByOffset(numberOfRangeToDragTheSlider, 0)
.release().perform();
}
}