2016-04-25 11 views
2

是Appium能夠同時長按和截屏嗎?Appuim - 長按並同時截圖

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);} 

但它執行長按,之後採取截圖。我同時需要基本的長按和截圖。

任何幫助表示讚賞

+0

也許在這裏可以幫助:http://stackoverflow.com/questions/34201207/take-a-screenshot-during-dragging-in-appium – econoMichael

回答

0

這是我如何解決了

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(); 

} 

然後你就可以採取事先知情同意。但是,只有當我想從保留中釋放該元素時,它纔會給我帶來錯誤。現在我不介意釋放這個。現在罰款