软件测试学习笔记丨常用的设备交互命令

编程有点难不难 2024-02-12 08:13:55
模拟器创建查看模拟器列表: emulator -list-avds在命令行启动模拟器: emulator @foo or emulator -avd foodesirecapbility配置caps.setCapability(AVD,“Pixel_Android6.0”);注意自动启动模拟器,只能是sdk的模拟器,第三方模拟器不支持,7.0不支持模拟电话、短信

//拨打电话(模拟器)driver.makeGsmCall(“18390522307”, GsmCallActions.CALL);//接听电话(模拟器)driver.makeGsmCall(“18390522307”, GsmCallActions.ACCEPT);// 拒接电话/挂断电话()driver.makeGsmCall(“18390522307”, GsmCallActions.CANCEL);//发送短信(模拟器)driver.sendSMS(“18390522307”,“hello appium message”);

网络模式

driver.toggleAirplaneMode();//飞行模式driver.toggleWifi();//wifi模式driver.toggleData();//数据流量模式

横竖屏切换

//横屏切换driver.rotate(ScreenOrientation.LANDSCAPE);//切换成竖屏driver.rotate(ScreenOrientation.PORTRAIT);

App处理

//锁屏driver.lockDevice();//截图File screenshotAs = driver.getScreenshotAs(OutputType.FILE);File file = new File(System.getProperty(“user.dir”) + “/src/main/resources/demo.png”);FileUtils.copyFile(screenshotAs,file);

//设置地理位置(仅限于模拟器)Location location = new Location(1,2,3);driver.setLocation(location);

录屏

//录屏driver.startRecordingScreen();driver.stopRecordingScreen();

硬件操作

-//硬件操作driver.pressKey(new KeyEvent().withKey(AndroidKey.BACK));

比如 back,home,menu,power,voice up,voice down,官网地址

qemu-system

@Test public void deviceTest() throws IOException { //拨打电话(模拟器) driver.makeGsmCall("18390522307", GsmCallActions.CALL); //接听电话(模拟器) driver.makeGsmCall("18390522307", GsmCallActions.ACCEPT); // 拒接电话/挂断电话() driver.makeGsmCall("18390522307", GsmCallActions.CANCEL); //发送短信(模拟器) driver.sendSMS("18390522307","hello appium message"); //网络设置 driver.toggleAirplaneMode();//飞行模式 driver.toggleWifi();//wifi模式 driver.toggleData();//数据流量模式 //横屏切换 driver.rotate(ScreenOrientation.LANDSCAPE); //切换成竖屏 driver.rotate(ScreenOrientation.PORTRAIT); //锁屏 driver.lockDevice(); //截图 File screenshotAs = driver.getScreenshotAs(OutputType.FILE); File file = new File(System.getProperty("user.dir") + "/src/main/resources/demo.png"); FileUtils.copyFile(screenshotAs,file); //录屏 driver.startRecordingScreen(); driver.stopRecordingScreen(); //设置地理位置(仅限于模拟器) Location location = new Location(1,2,3); driver.setLocation(location); //硬件操作 driver.pressKey(new KeyEvent().withKey(AndroidKey.BACK)); }

霍格沃兹的测试管理班是专门面向测试与质量管理人员的一门课程,通过提升从业人员的团队管理、项目管理、绩效管理、沟通管理等方面的能力,使测试管理人员可以更好的带领团队、项目以及公司获得更快的成长。提供 1v1 私教指导,BAT 级别的测试管理大咖量身打造职业规划。

0 阅读:0