I am using TouchActions class in to and the to a specified .The problem that I am facing is that on some pages the slider works fine and I’m able to initiate touch action and move the slider, but on the other page the same thing may or may not work.What’s uncanny is that the code seems to be working fine and no error is being thrown.It would be really helpful if someone points out what could possibly cause this behavior.

My code for controlling the slider is as follows:

import io.appium._client.AppiumDriver;
import io.appium._client.TouchAction;
import org.openqa.selenium.WebElement;

public class SlideController {

private WebElement seekbar;
private AppiumDriver driver;
private TouchAction touchAction;
private final int offset = 200;

public SlideController(WebElement seekbar, AppiumDriver driver) {
    this.seekbar = seekbar;
    this.driver = driver;
}

public void slideBy(int slideByPercentage){
    int xStartingPoint = seekbar.getLocation().getX();
    int xEndingPoint = seekbar.getSize().getWidth();
    int yStartingAndEndingPoint = seekbar.getLocation().getY();
    moveSliderAccordingToSpecifiedPercentage(xStartingPoint,xEndingPoint,yStartingAndEndingPoint,slideByPercentage);
}

private void moveSliderAccordingToSpecifiedPercentage(int xStartingPoint, int xEndingPoint, int yStartingAndEndingPoint, int slideByPercentage) {
    double slideFactor = (double)slideByPercentage/(double)100;
    int pointToMoveTo = (int) ((xEndingPoint+offset)*slideFactor);
    touchAction = new TouchAction(driver);
    touchAction.longPress(xStartingPoint,yStartingAndEndingPoint,1000).moveTo(pointToMoveTo,yStartingAndEndingPoint).release().perform();
   }
} 



Source link https://sqa.stackexchange.com/questions/27559/-to-press-and-move-slider-to--position-in-a----ap

LEAVE A REPLY

Please enter your comment!
Please enter your name here