简体   繁体   English

在java中的android中滑动元素滑动

[英]Slider elemet swipe in android in java

I want to slide this button from left to right:我想从左向右滑动这个按钮:

我想从左向右滑动这个按钮

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM