当前位置:网站首页>干货|app自动化测试之设备交互API详解
干货|app自动化测试之设备交互API详解
2022-06-09 16:03:00 【华为云】
Appium 提供了很多系统操作,在测试 APP 过程中会有一些特殊场景,比如来电话、短信,横竖屏切换,安装/卸载 APP,手机上的键盘操作,录屏等功能。下面介绍几个常用的设备交互 API。
更多用法参见官网:
http://appium.io/docs/en/about-appium/intro/
模拟电话/短信
用下面的命令模拟 GSM 电话和短信,注意:只能在模拟器上使用!
self.driver.make_gsm_call("5551234567", GsmCallActions.CALL);self.driver.send_sms('555-123-4567', 'Hey lol')App操作
# 实现 APP 的安装self.driver.install_app('/Users/johndoe/path/to/app.apk') # 检测 APP 是否被安装self.driver.is_app_installed('com.example.AppName');# 启动 APPself.driver.launch_app()weditor安装方式
键盘事件可以参考 Android 官网:
https://developer.android.com/reference/android/view/KeyEvent.html
下面分别展示了按键、长按、隐藏键盘、软键盘是否显示,代码如下:
self.driver.press_keycode(10)self.driver.long_press_keycode(10)self.driver.hide_keyboard()self.driver.is_keyboard_shown()设置系统剪贴板的内容:
self.driver.set_clipboard('happy testing')self.driver.set_clipboard_text('happy testing')获取到剪贴板的内容:
self.driver.get_clipboard()self.driver.get_clipboard_text()设备交互API就先讲这些,如果还想学习其他的设备交互 API或其他知识点,都可以在下方留言哦!
边栏推荐
- Easywechat realizes wechat real payment operation
- Where to open an account for futures and who to open it for safe and reliable??
- 网页加载waiting(TTFB)时间过长的解决方案参考
- Dapr source code analysis | basic introduction
- Problem with the setting of working directory when GoLand runs the Go program: an error path is reported. If no such file or directory is not found, check the configuration
- 10 questions that must be asked in software testing interview
- Dotnet core releases only necessary dependent files
- Install MySQL 5.7 server under windows (full of holes)
- 中台架构学习
- 国泰君安开户安全吗
猜你喜欢

应用软件效率测试的执行策略

使用ffmpeg合并mp4文件

从 0 到 1,探究百亿流量验证下的 MVVM 框架设计

Replace ROC-AUC with auprc on unbalanced data

疫情之下,四点认知助你成长!

Ts编译配置

资深OpenStacker - 彭博、Vexxhost升级为OpenInfra基金会黄金成员

Dapr source code analysis | basic introduction

网页加载waiting(TTFB)时间过长的解决方案参考

Phalapi framework improvement scheme: manage multiple API applications on a set of phalapi system
随机推荐
Qscrollarea use tutorial to realize the setting interface that can slide up and down
Interface test series -- practical application of autodiff traffic playback in integration test
数据库存储目录结构简介
Ffmpeg mind map
UEditor圖片跨域上傳解决方案
ESP32-C3单火线智能开关,赋能传统开关智能化升级
Dotnet core releases only necessary dependent files
姑娘,你为什么要编程呢
EasyWeChat实现微信真实支付操作
“喜新厌旧”的喜茶,该如何撑起600亿的估值?
QScrollArea使用教程之实现可上下滑动的设置界面
在不平衡数据上使用AUPRC替代ROC-AUC
UEditor图片跨域上传解决方案
Nth child selector
C#/VB. Net to generate directory bookmarks when word is converted to PDF
10 required AutoCAD plug-ins
软件测试面试必问的10个问题
vulnstack系列靶场一
Wechat applet mind map
测试必看,初次编写测试用例的要点