Rag*_*son 7 android automated-tests seekbar appium android-seekbar
我有一个这样的自定义Android搜索栏,以及它可以移动到的位置.它从中间开始:
我想首先移动滑块,然后检查它是否已保存.我有一个使用TouchAction的方法:
public void moveSeekBar(){
WebElement seekBar = appiumDriver.findElementById("com.feverapp:id/SymptomTrackingActivity_var");
//Get start point of seekbar.
int startX = seekBar.getLocation().getX();
System.out.println(startX);
//Get end point of seekbar.
int endX = seekBar.getSize().getWidth();
System.out.println(endX);
//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 = 786;
System.out.println("Moving seek bar at " + moveToXDirectionAt+" In X direction.");
//Moving seekbar using TouchAction class.
TouchAction act=new TouchAction(appiumDriver);
act.press(startX,yAxis).moveTo(moveToXDirectionAt,yAxis).release().perform();
}
Run Code Online (Sandbox Code Playgroud)
我注意到的一点:
我尝试使用这样的sendkeys:
seekbar.sendKeys("0.5");
Run Code Online (Sandbox Code Playgroud)
并且它工作:它将滑块移动到最左边,它只用0.5,当我输入0到1范围内的数字时,它不起作用
任何帮助非常感谢.谢谢