Sunday, January 25, 2015

How to move Slider using Selenium Webdriver


import java.util.ArrayList;
import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;


public class slider {

    public static void main(String[] args) {
       
       
        WebDriver driver = new FirefoxDriver();
        driver.get("http://jqueryui.com/demos/slider/");
        //Identify WebElement
        driver.manage().window().maximize();
        driver.switchTo().frame(0);
       
        WebElement slider = driver.findElement(By.xpath("//span[@class='ui-slider-handle ui-state-default ui-corner-all']"));
       
        //Using Action Class
        Actions move = new Actions(driver);
        Action action = move.dragAndDropBy(slider, 100, 0).build();
        action.perform();

        //driver.quit();

    }

}

1 comment: