![](/img/trans.png)
[英]Long press a custom physical button on android device with appium java
[英]How to long press on android record button(during chat) for a particular time duration in appium test, by java
如何通過java在appium測試中長按android記錄按鈕特定時間。 我嘗試了兩種方法,但兩種方法都根本不起作用,它們是:
方法1:
By pressRecBtn = By.id("recorderButton");
int x = 353; // x coordinate of device screen, get it after enabling the Show touch and Pointer location from developer option
int y = 980; // same as x
int timeInMs = 4000;
Action.longPress(driver.findElement(pressRecBtn)).longPress(x, y, timeInMs).perform();
方式2:
By pressRecBtn = By.id("recorderButton");
int timeInMs = 4000;
Action.longPress(driver.findElement(pressRecBtn)).waitAction(timeInMs).perform();
為此,它可以按下錄音按鈕,但是要保留默認時間(> = 1000 MS)。
你可以這樣嘗試
TouchAction Action = new TouchAction(driver);
Action.longPress(driver.findElement(By.name("xyz"))).perform();
它的工作很酷!
By tapOnRecIcon = By.id("btnRecord");
int timeInMs = 4000;
TouchAction touchAction = new TouchAction((MobileDriver) driver);
touchAction.longPress(driver.findElement(pressRecBtn),timeInMs).release().perform();
public void longClick(String element) {
// TODO Auto-generated method stub
WebElement webElement = appiumDriver.findElement(By.xpath(element));
TouchAction Action = new TouchAction(appiumDriver);
Action.longPress(webElement).release().perform();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.