Selenium is a very powerful, flexible open source automation testing tool for web applications. With the help of selenium we can automate Sliders. Sliders helps the user to select a value by dragging and dropping a handle.
The following code should be used to automate the slider:
WebDriver driver = new FirefoxDriver();
driver.get("http://jqueryui.com/resources/demos/slider/default.html");
driver.manage().timeouts().implicitlyWait(20L, TimeUnit.SECONDS);
WebElement slider = driver.findElement(By.xpath("//*[@id='slider']/a"));
Actions action = new Actions(driver);
action.dragAndDropBy(source, xOffset, yOffset).perform();
eg: action.dragAndDropBy(slider, 200, 0).perform();
source element to emulate button down at.
xOffset horizontal move offset.
yOffset vertical move offset.
Hope this helps you. In case you have any questions feel free to ask in comments below.
0 Comment(s)