Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Automate a Slider in Selenium?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 16.6k
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: