我有一個自定義的Android搜索欄像這樣,以及它可以移動到的位置。它從中間開始:不能移動Android SeekBar與Appium
我想先移動滑塊,然後檢查它是否保存。我有我使用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();
}
東西我注意到:
- 搜索條完全不
- 的getX和移動的getY始終是相同的價值觀,甚至我試圖設置塊到最左邊之前,我把這種方法
我試着用的SendKeys是這樣的:
seekbar.sendKeys("0.5");
和它的工作:它移動滑塊到最左邊,而且只用0.5的工作,當我進入的範圍內從0到1,它不工作
任何幫助非常讚賞。謝謝
你嘗試單擊並按住或拖放? –
@PankajKatiyar:我按下並移動並釋放 – Ragnarsson