发布时间:2025-12-10 22:56:03 浏览次数:1
Appium 截图方法
Appium 截图,本质上还是Selenium的截图机制。因为Appium是基于Selenium。
方法实现如下(大家使用的时候直接调用screenShot这个方法,传入文件路径就可以。):
publicstaticvoidscreenShot(AndroidDriverdriver,StringsFilePath){Filefile=newFile(sFilePath);//如果截图存在先删除try{if(file.exists()){file.delete();}}catch(Exceptione){e.printStackTrace();}//截图FilenewFile=driver.getScreenshotAs(OutputType.FILE);try{FileUtils.copyFile(newFile,file);}catch(IOExceptione){e.printStackTrace();}}
如:screenShot(driver,"c:\\cheersTest\\screenshots\\test1.png")
感谢你能够认真阅读完这篇文章,希望小编分享的“Appium如何实现截图”这篇文章对大家有帮助,同时也希望大家多多支持本站,关注本站行业资讯频道,更多相关知识等着你来学习!