【问题标题】:Appuim - Long press and take screenshot at the same timeAppium - 长按同时截图
【发布时间】:2016-08-19 07:56:55
【问题描述】:

Appium 可以同时长按和截屏吗?

 public void press(By by) throws IOException {
    WebElement el = driver.findElement(by);
    TouchAction action = new TouchAction(driver);
    action.longPress(el);}

之后我申请截图

  public void screenshot(String filename) throws IOException {
    File srcFile=driver.getScreenshotAs(OutputType.FILE);
    File targetFile=new File("./Screenshots/Navigation/" + generateCurrentDate()+ "/"+ filename +".jpg");
    FileUtils.copyFile(srcFile,targetFile);}

但它会执行长按,然后截取屏幕截图。我基本上需要同时长按和截图。

任何帮助表示赞赏

【问题讨论】:

标签: java android selenium appium


【解决方案1】:

我就是这样解决的

    public void pressByElements(By by, int num) throws IOException, InterruptedException {
    List<WebElement> el = driver.findElements(by);
    TouchAction action = new TouchAction(driver);
    action.press(el.get(num)).waitAction(2000).perform();

}

然后你就可以拍照了。但只有当我想从保持中释放该元素时,它才会给我错误。现在我不介意发布它。暂时还好

【讨论】:

    猜你喜欢
    • 2016-03-16
    • 1970-01-01
    • 2015-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-12
    • 2014-05-31
    相关资源
    最近更新 更多