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. C#、WPF中如何自定义鼠标样式

    需求:在C#中如何自定义鼠标样式?在这里可以分两种情况,一种是在winForm,另一种是在WPF中(注意使用的Cursor对象不一样) 解决办法如下: a.首先针对WinForm中,我们可以采用图标加 ...

  2. C#之事件与eventArgs

    static void Main(string[] args)         {             MyText myText = new MyText();             myTe ...

  3. 全面系统讲解CSS 工作应用+面试一步搞定

  4. mysql强制索引和禁止某个索引

    1.mysql强制使用索引:force index(索引名或者主键PRI) 例如: select * from table force index(PRI) limit 2;(强制使用主键) sele ...

  5. 测试体验Centrifugo

    今天尝试用 centrifugo 来做一个在聊天室,以前用workerman做过,相对来说 workerman的配置就显得复杂多了,需要自己搭建PHP环境, 而 centrifugo 就清爽多了,官网 ...

  6. MySQLorder by用法

    首先,order by是用来写在where之后,给多个字段来排序的一个DQL查询语句. 其次,order by写法: 1.  select 字段列表/* from 表名 where 条件 order ...

  7. pip模块

    pip模块 Usage: pip <command> [options] Commands: install Install packages. download Download pac ...

  8. 我的python之路

    一.基础语法 Python基础—基本语法结构 Python基础—程序控制结构 Python基础—基本数据类型 Python基础—文件的读写操作 二.函数 Python基础—初识函数 Python基础— ...

  9. 机器学习---最小二乘线性回归模型的5个基本假设(Machine Learning Least Squares Linear Regression Assumptions)

    在之前的文章<机器学习---线性回归(Machine Learning Linear Regression)>中说到,使用最小二乘回归模型需要满足一些假设条件.但是这些假设条件却往往是人们 ...

  10. AttributeError: 'NoneType' object has no attribute 'split' 报错处理

    报错场景 social_django 组件对原生 django 的支持较好, 但是因为 在此DRF进行的验证为 JWT 方式 和 django 的验证存在区别, 因此需要进行更改自行支持 JWT 方式 ...