Java Appuim-长按同时拍摄屏幕截图
Appium是否能够同时长按和截图Java Appuim-长按同时拍摄屏幕截图,java,android,selenium,appium,Java,Android,Selenium,Appium,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 IOExce
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);}
但它会执行长按,然后截图。我需要基本上长新闻和截图在同一时间
感谢您的帮助我就是这样解决的
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();
}
public void pressByElements(By By,int num)引发IOException、InterruptedException{
列表el=驱动程序findElements(按);
TouchAction动作=新的TouchAction(驱动程序);
action.press(el.get(num)).waitAction(2000.perform();
}
然后你可以照张相。但只有当我想从保持中释放该元素时,它才会给我错误。现在我不介意发布这个。现在很好也许这里有些东西能帮上忙: