Device

Activity

Start Activity

Start an Android activity by providing package name and activity name

Java:driver.startActivity(new Activity("com.example", "ActivityName"));
Python:self.driver.start_activity("com.example", "ActivityName");

Get Current Activity

Get the name of the current Android activity

Java:String activity = driver.currentActivity();
Python:activity = self.driver.current_activity;

Get Current Package

Get the name of the current Android package

Java:String package = driver.getCurrentPackage();
Python:package = self.driver.current_package;

Install App

Install the given app onto the device

Java:driver.installApp("/Users/johndoe/path/to/app.apk");
Python:self.driver.install_app('/Users/johndoe/path/to/app.apk');

Is App Installed

Check whether the specified app is installed on the device

Java:driver.isAppInstalled("com.example.AppName");
Python:self.driver.is_app_installed('com.example.AppName');

Launch an App

Launch an app on device

Java:driver.launchApp();
Python:self.driver.launch_app()

Background App

Send the currently running app for this session to the background

Java:driver.runAppInBackground(Duration.ofSeconds(10));
Python:self.driver.background_app(10)

Close an App

Close an app on device

Java:driver.closeApp();
Python:self.driver.close_app()

Reset App

Reset the currently running app for this session

Java:driver.resetApp();
Python:self.driver.reset()

Remove App

Remove an app from the device

Java:driver.removeApp("com.example.AppName");
Python:self.driver.remove_app('com.example.AppName');

Description
iOS tests with XCUITest can also use the mobile: removeApp method.

Get App Strings

Java:Map<String, String> appStrings = driver.getAppStringMap("en", "/path/to/file");
Python:appStrings = self.driver.app_strings("en", "/path/to/file")

End Test Coverage

Get test coverage data

Java:driver.endTestCoverage("Intent", "/path");
Python:self.driver.end_test_coverage("Intent", "/path")

Get Clipboard

Get the content of the system clipboard

Java:
driver.getClipboard(ClipboardContentType.PLAINTEXT); // get plaintext
driver.getClipboardText();

Python:
self.driver.get_clipboard()
self.driver.get_clipboard_text()

Set Clipboard

Set the content of the system clipboard

Java:
// base64Content is Base64-encoded content
driver.setClipboard("label", ClipboardContentType.PLAINTEXT, base64Content);
driver.setClipboardText("happy testing");

Python:
self.driver.set_clipboard('happy testing')
self.driver.set_clipboard_text('happy testing')

Emulate power state

Emulate power state change on the connected emulator.

Java:driver.setPowerAC(PowerACState.OFF);
Python:# Not supported

Emulate power capacity

Emulate power capacity change on the connected emulator.

Java:driver.setPowerCapacity(100);
Python:# Not supported

Push File

Place a file onto the device in a particular place

Java:driver.pushFile("/path/to/device/foo.bar", new File("/Users/johndoe/files/foo.bar"));
Python:self.driver.push_file('/path/to/device/foo.bar', 'QXJlIHlvdXIgYmVlcnMgb2theT8=');

Pull File

Retrieve a file from the device's file system

Java:byte[] fileBase64 = driver.pullFile("/path/to/device/foo.bar");
Python:file_base64 = self.driver.pull_file('/path/to/device/foo.bar');

Pull Folder

Retrieve a folder from the device's file system

Java:byte[] folder = driver.pullFolder("/path/to/device/foo.bar");
Python:folder_base64 = self.driver.pull_folder('/path/to/device/foo.bar');

Shake

Perform a shake action on the device

Java:driver.shake();
Python:self.driver.shake();

Lock

Lock the device

Java:driver.lockDevice();
Python:self.driver.lock();

Unlock

Unlock the device

Java:
driver.lockDevice();
driver.unlockDevice();

Python:
self.driver.lock();
self.driver.unlock();

Is Device Locked

Check whether the device is locked or not

Java:boolean isLocked = driver.isDeviceLocked();
Python:# Not supported

Rotate

Rotate the device in three dimensions

Java:driver.rotate(new DeviceRotation(10, 10, 10));
Python:# Not supported

Press Key Code

Press a particular key on the device

Java:driver.pressKeyCode(AndroidKeyCode.SPACE, AndroidKeyMetastate.META_SHIFT_ON);
Python:self.driver.press_keycode(10);

Long Press Key Code

Press and hold a particular key code on the device

Java:driver.longPressKeyCode(AndroidKeyCode.HOME);
Python:self.driver.long_press_keycode(10);

Hide Keyboard

Hide soft keyboard

Java:driver.hideKeyboard();
Python:self.driver.hide_keyboard()

Is Keyboard Shown

Whether or not the soft keyboard is shown

Java:boolean isKeyboardShown = driver.isKeyboardShown();
Python:# Not supported

Toggle Airplane Mode

Toggle airplane mode on device

Java:driver.toggleAirplaneMode();
Python:# Not supported

Toggle Data

Switch the state of data service

Java:driver.toggleData();
Python:# Not supported

Toggle WiFi

Switch the state of the wifi service

Java:driver.toggleWifi();
Python:# Not supported

Toggle Location Services

Switch the state of the location service

Java:driver.toggleLocationServices();
Python:self.driver.toggle_location_services();

Send SMS

Simulate an SMS message (Emulator only)

Java:driver.sendSMS("555-123-4567", "Hey lol");
Python:# Not supported

GSM Call

Make GSM call (Emulator only)

Java:driver.makeGsmCall("5551234567", GsmCallActions.CALL);
Python:# Not supported

GSM Signal

Set GSM signal strength (Emulator only)

Java:driver.setGsmSignalStrength(GsmSignalStrength.GOOD);
Python:# Not supported

GSM Voice

Set GSM voice state (Emulator only)

Java:driver.setGsmVoice(GsmVoiceState.HOME);
Python:# Not supported

Get Performance Data

Returns the information of the system state which is supported to read as like cpu, memory, network traffic, and battery

Java:List<List> performanceData = driver.getPerformanceData("my.app.package", "cpuinfo", 5);
Python:# Not supported

Get Performance Data Types

Returns the information types of the system state which is supported to read as like cpu, memory, network traffic, and battery

Java:List performanceTypes = driver.getSupportedPerformanceDataTypes();
Python:# Not supported

Start Recording Screen

Java:
driver.startRecordingScreen();
driver.startRecordingScreen(new BaseStartScreenRecordingOptions(....));

Python:
self.driver.start_recording_screen()

Stop Recording Screen

Java:
driver.stopRecordingScreen();
driver.stopRecordingScreen(new BaseStopScreenRecordingOptions(....));

Python:
self.driver.stop_recording_screen()

Perform Touch ID

Simulate a touch id event (iOS Simulator only)

Java:
driver.performTouchID(false); // Simulates a failed touch
driver.performTouchID(true); // Simulates a passing touch

Python:
self.driver.touch_id(false); # Simulates a failed touch
self.driver.touch_id(true); # Simulates a passing touch

Toggle Touch ID Enrollment

Toggle the simulator being enrolled to accept touchId (iOS Simulator only)

Java:driver.toggleTouchIDEnrollment(true);
Python:self.driver.toggle_touch_id_enrollment()

Open Notifications

Open Android notifications (Emulator only)

Java:driver.openNotifications();
Python:self.driver.open_notifications();

Get System Bars

Retrieve visibility and bounds information of the status and navigation bars

Java:Map<String, String> systemBars = driver.getSystemBars();
Python:# Not supported

Get System Time

Get the time on the device

Java:String time = driver.getDeviceTime();
Python:time = self.driver.device_time()

Finger print

Authenticate users by using their finger print scans on supported emulators.

Java:driver.fingerPrint(1);
Python:self.driver.finger_print(1)

Appnium-API-Dvice的更多相关文章

  1. 手机用appnium,web自动化用eclips+webdriver2

    手机用appnium,web自动化用eclips+webdriver2 吴建清 pycharm 1.安装环境2.pycharm类似eclipse,写脚本,运行脚本3.uiautomatorviewer ...

  2. (转)MitmProxy+APPnium安装使用

    MitmProxy+APPnium安装使用 2019年08月19日 11:09:48 jiageibuuuyi 阅读数 61更多 分类专栏: python学习笔记   版权声明:本文为博主原创文章,遵 ...

  3. 干货来袭-整套完整安全的API接口解决方案

    在各种手机APP泛滥的现在,背后都有同样泛滥的API接口在支撑,其中鱼龙混杂,直接裸奔的WEB API大量存在,安全性令人堪优 在以前WEB API概念没有很普及的时候,都采用自已定义的接口和结构,对 ...

  4. 12306官方火车票Api接口

    2017,现在已进入春运期间,真的是一票难求,深有体会.各种购票抢票软件应运而生,也有购买加速包提高抢票几率,可以理解为变相的黄牛.对于技术人员,虽然写一个抢票软件还是比较难的,但是还是简单看看123 ...

  5. 几个有趣的WEB设备API(二)

    浏览器和设备之间还有很多有趣的接口, 1.屏幕朝向接口 浏览器有两种方法来监听屏幕朝向,看是横屏还是竖屏. (1)使用css媒体查询的方法 /* 竖屏 */ @media screen and (or ...

  6. html5 canvas常用api总结(三)--图像变换API

    canvas的图像变换api,可以帮助我们更加方便的绘画出一些酷炫的效果,也可以用来制作动画.接下来将总结一下canvas的变换方法,文末有一个例子来更加深刻的了解和利用这几个api. 1.画布旋转a ...

  7. JavaScript 对数据处理的5个API

    JavaScript对数据处理包括向上取整.向下取整.四舍五入.固定精度和固定长度5种方式,分别对应ceil,floor,round,toFixed,toPrecision等5个API,本文将对这5个 ...

  8. ES5对Array增强的9个API

    为了更方便的对Array进行操作,ES5规范在Array的原型上新增了9个方法,分别是forEach.filter.map.reduce.reduceRight.some.every.indexOf ...

  9. javascript的api设计原则

    前言 本篇博文来自一次公司内部的前端分享,从多个方面讨论了在设计接口时遵循的原则,总共包含了七个大块.系卤煮自己总结的一些经验和教训.本篇博文同时也参考了其他一些文章,相关地址会在后面贴出来.很难做到 ...

  10. 一百元的智能家居——Asp.Net Mvc Api+讯飞语音+Android+Arduino

    大半夜的,先说些废话提提神 如今智能家居已经不再停留在概念阶段,高大上的科技公司都已经推出了自己的部分或全套的智能家居解决方案,不过就目前的现状而言,大多还停留在展厅阶段,还没有广泛的推广起来,有人说 ...

随机推荐

  1. 修改DEDECMS文章标题长度,解决DEDECMS文章标题显示不全

    dedecms系统使用过程中,常遇到输入的标题原本输入的字数跟保存成功后的数字长度不一样,这个是因为 织梦dedecms系统默认的文章标题字数限制是60,也就是只能输入30个汉字,超过的会自动截断删除 ...

  2. nginx基础之【study one】

    Nginx是种代理服务器,即可以作为反向代理服务器.邮件服务器等HTTP服务器,支持很多第三方模块扩展,如GZip.SSL.FastCGI. 最常用的功能有Http反向代理.负载均衡和Web缓存: 1 ...

  3. dubbo框架的web端(war)和server端(tar.gz)结合jenkins打包方式

    一.web端程序,打包成war包 jenkins配置 1.项目名称,旧文件处理配置 2.参数构建配置 3.源码库配置 4.打包文件pom.xml配置及多环境打包传参,此处传参qa(表示打测试环境包,名 ...

  4. java篇 之 java概念

    Jvm:java虚拟机,让java拥有跨平台的能力,一次编写,导出运行 Java优点:提供了一个解释性环境(多线程,可执行程序跨平台,加快开发,支持动态更新) 没有指针,有垃圾将回收器(回收内存) 执 ...

  5. Android数据库优化

    1.索引 简单的说,索引就像书本的目录,目录可以快速找到所在页数,数据库中索引可以帮助快速找到数据,而不用全表扫描,合适的索引可以大大提高数据库查询的效率.(1). 优点大大加快了数据库检索的速度,包 ...

  6. swagger.core的使用方法

    Swagger 是一个规范和完整的框架,用于生成.描述.调用和可视化 RESTful 风格的 Web 服务,那么如何在abp中使用呢,已经有大牛为我们实现了一个swagger.core的组件而作为菜鸟 ...

  7. Ticwatch2_3G版省电优化

    设置 --> 网络与连接 --> 云消息同步(禁用) 设置 --> 声音与震动 --> 铃声与音量(静音) 设置 --> 声音与震动 --> 闹钟音量(静音) 设置 ...

  8. Java基础学习--数组

    1.数组的定义: 数组(Array)是相同数据类型的数据的有序集合. 2.数组的3个特点: 2.1数组长度是确定.数组一旦申请完空间,长度不能发生变化,用length属性访问. 2.2数组的元素都是同 ...

  9. 贝叶斯A/B测试 - 一种计算两种概率分布差异性的方法过程

    1. 控制变量 0x1:控制变量主要思想 科学中对于多因素(多变量)的问题,常常采用控制因素(变量)的方法,吧多因素的问题变成多个单因素的问题.每一次只改变其中的某一个因素,而控制其余几个因素不变,从 ...

  10. .NET技术-2.0. 操作数据库-EF

    .NET技术-2.0. 操作数据库-EF 项目参见: EF安装配置 参见: https://www.cnblogs.com/1285026182YUAN/p/10772330.html https:/ ...