Slider elemet swipe in android in java

Viewed 36

I want to slide this button from left to right:

I want to slide this button from left to right

1 Answers

An example that can help you achieve that:

int startX = sliderEl.getLocation().x; // Get the initial starting X coordinate of the slider
int elWidth = sliderEl.getSize().width(); // Get the width of the slider
int endX = startX + elWidth; // Get the ending X coordinate of the slider
int y = sliderEl.getLocation().y + (sliderEl.getSize().height/2); // Generate the middle Y coordinate of the slider

TouchAction swipeSlider = new TouchAction(driver).press(PointOption.point(startX,y)).waitAction(WaitOptions.waitOptions(Duration.ofMillis(500))).moveTo(PointOption.point(endX, y)).release(); // Create the action that will swipe from the start coordinate to the end coordinate

swipeSlider.perform(); // Execute the swipe
Related