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. php将字符串转为二进制数据串

    /** * 将字符串转换成二进制 * @param type $str * @return type */ function StrToBin($str){ //1.列出每个字符 $arr = pre ...

  2. JS获取登录者IP和登录城市

    登录城市:<sp class="cy"></sp><br /> 管理员个数:<font color=</strong>< ...

  3. Django2 Django MTV模板

    1.MVC模型 Web服务器开发领域里著名的MVC模式,所谓MVC就是把Web应用分为模型(M),控制器(C)和视图(V)三层,他们之间以一种插件式的.松耦合的方式连接在一起,模型负责业务对象与数据库 ...

  4. 动态chart Demo

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  5. CentOS7桌面版系统使用的一些小技巧

    1. 清空~/.kde/ 文件下的文件,登陆后不显示桌面的解决方法 在使用CentOS7 桌面系统时,有时候打开文件会很卡.这时我们需要清空当前用户下的 .kde 文件下的所有文件. 再重新登陆该用户 ...

  6. java 基本数据类型初始值(默认值)

    1.int类型定义的数组,初始化默认是0 2.String类型定义的数组,默认值是null 3.char类型定义的数组,默认值是0对应的字符 4.double类型定义的数组,默认值是0.0 5.flo ...

  7. element vue 表格编辑

    https://xuliangzhan.github.io/vue-element-extends/#/editable/click1

  8. Codeforces Round #520 (Div. 2) B. Math 唯一分解定理+贪心

    题意:给出一个x 可以做两种操作  ①sqrt(x)  注意必须是完全平方数  ② x*=k  (k为任意数)  问能达到的最小的x是多少 思路: 由题意以及 操作  应该联想到唯一分解定理   经过 ...

  9. Multi-View 3D Reconstruction with Geometry and Shading——Part-1

    From PhDTheses Multi-View 3D Reconstruction with Geometry and Shading 计算机视觉的主要任务就是利用图像信息能智能理解周围的世界. ...

  10. Java 8 特性 —— Stream

    Stream 是用函数式编程方式在集合类上进行复杂操作的工具,其集成了Java 8 中的众多新特性之一的聚合操作,开发者可以更容易地使用Lambda表达式,并且更方便地实现对集合的查找.遍历.过滤以及 ...