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.
This test case is to handle the slider, and check the value is correctly chage.
The evidense screen shot is stored at location below.
Those screenshots a taken by Selenium program using taking screenshot technique.
The source code to test this is in "org.alinous.test.html5.jqparts" package.
The "JQuerySliderTest" class has the testing code of the JUnit.
At the first of the JUnit Test class, we initialize and connect the WebDriver, and make the download folder empty.
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.
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.