Appium 截图方法
Appium 截图,本质上还是Selenium的截图机制。因为Appium是基于Selenium。
方法实现如下(大家使用的时候直接调用screenShot这个方法,传入文件路径就可以。):
public static void screenShot(AndroidDriver driver,String sFilePath)
{
File file=new File(sFilePath);
// 如果截图存在先删除
try {
if(file.exists())
{
file.delete();
}
} catch (Exception e) {
e.printStackTrace();
}
// 截图
File newFile=driver.getScreenshotAs(OutputType.FILE);
try {
FileUtils.copyFile(newFile, file);
} catch (IOException e) {
e.printStackTrace();
}
}如:screenShot(driver,"c:\\cheersTest\\screenshots\\test1.png")
说明:这个方法大家可以自行包装,在有需要的地方。

本文介绍了一种基于Appium实现的截图方法,该方法利用Selenium的截图机制,并提供了具体的实现代码,用户只需调用screenShot方法并传入文件路径即可完成截图。
569

被折叠的 条评论
为什么被折叠?



