[英]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.