Appium滑动和截屏方法封装
2016-07-25 18:33
399 查看
/**
* Swipe up on the screen
*/
public static void swipeToUp(AndroidDriver driver, int time) {
int width = driver.manage().window().getSize().width;
int height = driver.manage().window().getSize().height;
driver.swipe(width / 2, height * 3 / 4, width / 2, height / 4, time);
}
/**
* Swipe to right on the screen
*/
public static void swipeToRight(AndroidDriver driver, int time) {
int width = driver.manage().window().getSize().width;
int height = driver.manage().window().getSize().height;
driver.swipe(width / 4, height / 2, width * 3 / 4, height / 2, time);
}
/**
* This method is created for taking screenshot
*/
public static void snapshot(TakesScreenshot drivername, String filename) {
String currentPath = System.getProperty("user.dir");
File scrFile = drivername.getScreenshotAs(OutputType.FILE);
try {
System.out.println("Saved snapshot's path is:" + currentPath + "/"
+ filename);
FileUtils.copyFile(scrFile, new File(currentPath + "/" + filename));
} catch (IOException e) {
System.out.println("Can't save screenshot!");
e.printStackTrace();
}
}
* Swipe up on the screen
*/
public static void swipeToUp(AndroidDriver driver, int time) {
int width = driver.manage().window().getSize().width;
int height = driver.manage().window().getSize().height;
driver.swipe(width / 2, height * 3 / 4, width / 2, height / 4, time);
}
/**
* Swipe to right on the screen
*/
public static void swipeToRight(AndroidDriver driver, int time) {
int width = driver.manage().window().getSize().width;
int height = driver.manage().window().getSize().height;
driver.swipe(width / 4, height / 2, width * 3 / 4, height / 2, time);
}
/**
* This method is created for taking screenshot
*/
public static void snapshot(TakesScreenshot drivername, String filename) {
String currentPath = System.getProperty("user.dir");
File scrFile = drivername.getScreenshotAs(OutputType.FILE);
try {
System.out.println("Saved snapshot's path is:" + currentPath + "/"
+ filename);
FileUtils.copyFile(scrFile, new File(currentPath + "/" + filename));
} catch (IOException e) {
System.out.println("Can't save screenshot!");
e.printStackTrace();
}
}
相关文章推荐
- iOS中最简单实用的自定义动态返回行高的cell,动态计算cell的高度
- 11 百度地图
- Unity Aspect
- Android事件分发机制完全解析,带你从源码的角度彻底理解(下)
- Glide框架使用笔记
- Android Studio 和 gradle 修改缓存文件夹路径
- OC项目中使用Swift
- iOS_Swift_枚举
- Android—AlertDialog提示信息
- Android开发之shape自定义图形
- Android进阶处理图片之压缩图片大小、Lru内存解决方案
- activity和软键盘遮挡问题
- 关于cocos2dx虚拟摇杆的lua实现
- Android Studio improt project APIDemo
- Android 软键盘的显示和隐藏
- 轻量级数据缓存
- swift - UIPickerView 的使用
- android BLE 编程详解
- Android RecycleView 里面有按钮点击 复用错位的问题解决
- IOS设备的三种分辨率