Testing jQuery Slider example

This page is about Testing Automation of jQuery Slider example. By lerning this example, you can understand how to handle the drag and drop action programmatically with JUnit and Selenium.

In order to understand what test, please take a look at jQuery Slider before reading this page.

About test cases

This test case is to handle the slider, and check the value is correctly chage.

testing to change slider value

The evidense screen shot is stored at location below.


screenshot of testing jquery slider

Those screenshots a taken by Selenium program using taking screenshot technique.

Location of the source code

The source code to test this is in "org.alinous.test.html5.jqparts" package.

java package including testing class

The "JQuerySliderTest" class has the testing code of the JUnit.

Initialize WebDriver of the Selenium

At the first of the JUnit Test class, we initialize and connect the WebDriver, and make the download folder empty.

Testing slider

In this test case, do actions below.

  • Go to the test page
  • Change each slider's value

Source code of this test case

The source code of this test case is below.

In this source code, it changes the value of 3 sliders by setPercentage() function.

testing slider

The source code of setPercentage() is below.

The setPercentage() function get current percentage of the sider widget by calling getPercentage() function. After getting it, it caluculates value to change, and executes to change the value by dragging the handle of the slider.

This exmaple code specify the value by percentage, so you can use this code, unless the size of the slider widget is same.

Go to Top