简体   繁体   English

如何在appium测试中长按android记录按钮(在聊天过程中)一段特定的时间,由java

[英]How to long press on android record button(during chat) for a particular time duration in appium test, by java

How to long press on android record button for a particular time in appium test, by java. 如何通过java在appium测试中长按android记录按钮特定时间。 I have tried 2 ways but both are not working at all, those are: 我尝试了两种方法,但两种方法都根本不起作用,它们是:

Way 1: 方法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();

Way 2: 方式2:

By pressRecBtn = By.id("recorderButton");
int timeInMs = 4000;

Action.longPress(driver.findElement(pressRecBtn)).waitAction(timeInMs).perform();

for this way its press on rec button but for a default time(>=1000 MS). 为此,它可以按下录音按钮,但是要保留默认时间(> = 1000 MS)。

You can try this way, 你可以这样尝试

 TouchAction Action = new TouchAction(driver);
 Action.longPress(driver.findElement(By.name("xyz"))).perform();

Its working cool!! 它的工作很酷!

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.

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