How to move (drag) seek bar in appium

automate-seekbar-using-appium

A seek bar in any android handset or emulator is kind of a progress bar but this one is draggable, user can touch on the round shape or thumb, then can move towards right or left.

E.g – increase or decrease of volume or screen brightness.

Let’s see how we can automate the seek bar to move left or right.

Connect your mobile to PC and run below test

 

Code implementation

[Sample application – ApiDemos.apk]

  • Open application
  • Tap / click on “Views”
  • Scroll till “Seek Bar”
  • Drag the seekbar to 70%

 

DriverFactory.java

 

MobileDriver.java

Get and set the driver instance

 

TestApp.java

Actual Test to –

Tap on Views

Scroll till Seek Bar

Drag the seek bar

 

SeekBar.java

Write logic to scroll till SeekBar item in method scrollTillSeekbar(), to get more details, refer scrolling in appium

Run below testng.xml to perform the seekbar operation

Hope that helps!

Content posted is based on learning or working experience,
Share the post with others if find useful,
Any queries?, leave comments or discuss on our facebook:qavalidation.com, Thanks!

6 Responses

  1. Payal says:

    I tried executing the above code. But I am running into this issue:
    org.openqa.selenium.WebDriverException: Method has not yet been implemented (WARNING: The server did not provide any stacktrace)
    At line : appium.swipe(0,scrollStart,scrollEnd,0,2000);

    I am using saucelabs to run my mobile tests
    Driver info: io.appium.java_client.ios.IOSDriver
    appiumVer “1.5.3”

    Please let me know what the issue is

  2. sunilpatro1985 says:

    Hi Payal,

    Can you update your java-client jar version and retry, I am using java-client version 4.0 or above.

  3. Vinoth says:

    I used the same code for my app, when i run the code i get the below issue
    :org.openqa.selenium.WebDriverException: Support for this gesture is not yet implemented. Please contact an Appium dev (WARNING: The server did not provide any stacktrace information)
    Command duration or timeout: 11 milliseconds
    Build info: version: ‘unknown’, revision: ‘1969d75’, time: ‘2016-10-18 09:43:45 -0700’
    System info: host: ‘Rinsofts-Mac-mini-2.local’, ip: ‘192.168.1.120’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.11.6’, java.version: ‘1.8.0_111’
    Driver info: io.appium.java_client.ios.IOSDriver
    Java -client version is 5.0BETA.

  4. sunilpatro1985 says:

    Hi Vinoth,
    From java-client.jar 5.0.0 on wards, swipe() deprecated, so you can replace line 49 with this

    new TouchAction(driver).press(0, scrollStart).waitAction(2000).moveTo(0, scrollEnd).release().perform();

  5. 19michi98 says:

    Hi,
    Some improvement I worked hard on finding out whats not working (i am new in appium):

    old line 37: //move slider to 70% of width
    int moveTo=(int)(end*0.7); // This will move to 70% of screen0 -> end Seekbar

    new:
    int moveTo=(int)(widthOfSeekbar*0.7+start); // This will move to real 70% from Seekbar

    Best regards
    Michi

  6. sunilpatro1985 says:

    I have completely updated the post with version of appium java-client 6.0

Leave a Reply

Your email address will not be published. Required fields are marked *