# How to Handle (drag) Seek bar in Android?

**URL:** <https://discuss.appium.io/t/how-to-handle-drag-seek-bar-in-android/5864>\
**Category:** Support\
**Created:** [September 4, 2015, 12:49pm UTC](https://discuss.appium.io/t/how-to-handle-drag-seek-bar-in-android/5864 "2015-09-04T12:49:27Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![chethan\_shetty\_c](https://discuss.appium.io/user_avatar/discuss.appium.io/chethan_shetty_c/32/2793_2.png) [@chethan\_shetty\_c](https://discuss.appium.io/u/chethan_shetty_c)\
**Post date:** [October 26, 2016, 6:20am UTC](https://discuss.appium.io/t/how-to-handle-drag-seek-bar-in-android/5864/8 "2016-10-26T06:20:08Z")

</div>

Please use the following code to automation seek bar,

```
        /**
 * Automates slider or seek bar to the desired value provided
 * @param elementType: Element identification type as string (ID,XPATH,CSS etc)
 * @param elementName: Element name (ID value, XPATH value etc)
 * @param intToSlideValue: Value to which element needs to be slided(0 to 100)
 * @author chethanshetty
 */
public void setSliderValue(String elementType, String elementName, int intToSlideValue) {
	WebElement seekBar = getElement(elementType, elementName);
	
	//Get start point of seekbar.
    int startX = seekBar.getLocation().getX();
    
    //Get vertical location of seekbar.
    int yAxis = seekBar.getLocation().getY();
    
    //Set slidebar move to position.
    // this number is calculated based on (offset + 3/4width)
    int moveToXDirectionAt = intToSlideValue + startX;
    
    //Moving seekbar using TouchAction class.
    TouchAction act=new TouchAction(DriverSingleton.getInstance().getMobileDriver());
    act.longPress(startX,yAxis).moveTo(moveToXDirectionAt,yAxis).release().perform();
}

```

The above code makes use of long press to automate seek bar.  
For more info please refer [this link](http://stackoverflow.com/questions/35799788/cant-move-android-seekbar-with-appium)

---

_[View the full topic](https://discuss.appium.io/t/how-to-handle-drag-seek-bar-in-android/5864)._
