parts of appium api

Lock

Lock the screen.//锁屏。

// java
driver.lockScreen(3);
// objective c
[driver lockDeviceScreen:3];
# python
driver.lock(5)

Background app

Send the currently active app to the background.//将当前的app放到后台运行。

// java
driver.runAppInBackground(5);
// objective c
[driver runAppInBackground:3];
# python
driver.background_app(5)
 

Hide Keyboard

Hide the keyboard. Note: on iOS, this helper function is not guaranteed to work. There is no automation hook for hiding the keyboard, and apps are free to allow the user to hide the keyboard using any of a variety of different strategies, whether that is tapping outside the keyboard, swiping down, etc… We encourage you, rather than using this method, to think about how a user would hide the keyboard in your app, and tell Appium to do that instead (swipe, tap on a certain coordinate, etc…). That being said, the default behavior here might help you.//隐藏键盘。需要注意的是,在iOS系统上,这个方法不一定正常工作。实际上,用户可以通过“点击键盘外的区域”、“滑动”这些操作隐藏键盘。所以,使用appium时,推荐通过这些操作来隐藏键盘。

// java
driver.hideKeyboard();
// objective c
[driver hideKeyboard];
# python
driver.hide_keyboard()

Start Activity

Open an activity in the current app or start a new app and open an activity Android only//只适用于安卓系统。在当前app中打开一个activity,或者打开一个新的app。

// java
driver.startActivity("appPackage","com.example.android.apis", null, null);
// objective c
[driver startActivity:@"com.example.android.apis" package:@".Foo"];
# python
driver.start_activity('com.example.android.apis', '.Foo')

Open Notifications

Open the notification shade Android only//只适用于安卓系统。打开通知栏。

// java
driver.openNotifications();
// objective c
[driver openNotifications];
# python
driver.open_notifications()

Is installed

Check if an app is installed//判断是否安装了某个app。

// java
driver.isAppInstalled("com.example.android.apis")
// objective c
[driver isAppInstalled:@"com.example.android.apis-"];
# python
driver.is_app_installed('com.example.android.apis')

Install App

Install an app to the device.//安装一个app。

// java
driver.installApp("path/to/my.apk")
// objective c
[driver installAppAtPath:@"path/to/my.apk"];
# python
driver.install_app('path/to/my.apk')

Remove App

Remove an app from the device.//卸载一个app。

// java
driver.removeApp("com.example.android.apis")
// objective c
[driver removeApp:@"com.example.android.apis"];
# python
driver.remove_app('com.example.android.apis')

Shake

Simulate the device shaking.//模拟晃动操作。

// java
driver.shake()
// objective c
[driver shakeDevice];
# python
driver.shake()

Close app

Close the app.//关闭app。

// java
driver.closeApp()
// objective c
[driver closeApp];
# python
driver.close_app();

Launch

Launch the session for the desired capabilities. Note that this is the companion to the autoLaunch=false capability. This is not for launching arbitrary apps/activities—for that use start_activity. This is for continuing the initialization ("launch”) process if you have used autoLaunch=false.//当autoLauch=false时,使用desired capability加载session。

// java
driver.launchApp()
// objective c
[driver launchApp];
# python
driver.launch_app()
 

Reset

Reset the app.//重启app。

// java
driver.resetApp()
// objective c
[driver resetApp];
# python
driver.reset()
 

Available Contexts

List all available contexts.//列出全部可用的“上下文”

// java
driver.getContextHandles()
// objective c
NSArray *contexts = driver.allContexts;
# python
driver.contexts
 

Current context

List the current context.//列出当前的上下文。NATIVE_APP或者WEBVIEW_1。NATIVE_APP是指原生应用。

// java
driver.getContext()
// objective c
NSString *context = driver.context;
# python
driver.current_context
 

Switch to default context

Change the context to the default.//切换到默认“上下文”。

// java
driver.context();
// objective c
[driver setContext:nil];
# python
driver.switch_to.context(None)
 

App Strings

Get the app’s strings.//获取app的字符串。

// java
driver.getAppStrings();
// objective c
[driver appStrings];
[driver appStringsForLanguage:"@ru"];
# python
driver.app_strings
 

Key Event

Send a key event to the device.//发送一个key event到设备。

// java
driver.sendKeyEvent(AndroidKeyCode.HOME);
// objective c
NSError *err;
[driver triggerKeyEvent:176 metastate:0 error:&err];
# python
driver.keyevent(176)
 

Current Activity

Android only. Get the current activity.//获取当前的activity。

// java
driver.currentActivity();
// objective c
NSError *err;
[driver currentActivity];
# python
driver.current_activity
 

TouchAction / MultiTouchAction

An API for generating touch actions. This section of the documentation will be expanded upon soon.//触摸操作。

// java
TouchAction action = new TouchAction(driver)
.press(mapview, 10, 10)
.release().
perform();
# python
action = TouchAction(driver)
action.press(element=el, x=10, y=10).release().perform()
 

Swipe

Simulate a user swipe.//模拟滑动操作。

// java
driver.swipe(75, 500, 75, 0, 0.8)
# python
driver.swipe(start_x=75, start_y=500, end_x=75, end_y=0, duration=800)
 

Pinch

Pinch the screen.//捏,两指滑动靠近。

// java
driver.pinch(element);
# python
driver.pinch(element=el)
 

Zoom

Zoom the screen.//两指滑动远离。

// java
driver.zoom(element);
# python
driver.zoom(element=el)
 

Scroll To

Scroll to an element.//滚动。

// java
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put("direction", "down");
scrollObject.put("element", ((RemoteWebElement) element).getId());
js.executeScript("mobile: scroll", scrollObject);
# python
driver.execute_script("mobile: scroll", {"direction": "down", element: element.id})
 

Pull file

Pulls a file from the device.//从设备中,下载一个文件到本地。

// java
driver.pullFile("Library/AddressBook/AddressBook.sqlitedb");
# python
driver.pull_file('Library/AddressBook/AddressBook.sqlitedb')
 

Push File

Pushes a file to the device.//上传一个文件到设备里。

// java
byte[] data = Base64.encodeBase64("some data for the file".getBytes());
String path = "/data/local/tmp/file.txt";
driver.pushFile(path, data)
# python
data = "some data for the file"
path = "/data/local/tmp/file.txt"
driver.push_file(path, data.encode('base64'))
 

Settings

Here you will find sample code for getting/setting appium serverSetting. For more information on how they work, and which settings are supported, see [the settings docs][/docs/en/advanced-concepts/settings.md]

JsonObject settings = driver.getSettings()
// java-client doesn't support setting arbitrary settings, just settings which are already provided by appium.
// So for the 'ignoreUnimportantViews' setting, the following method exists:
driver.ignoreUnimportantViews(true);
# python
current_settings = driver.get_settings()
driver.update_settings({"someSetting": true})

appium(6)-parts of appium api的更多相关文章

  1. 『与善仁』Appium基础 — 16、APPium基础操作API

    目录 1.前置代码 2.安装和卸载APP 3.判断APP是否已安装 4.关闭APP软件和关闭驱动对象 5.发送文件到手机和获取手机中的文件 6.获取当前屏幕内元素结构(重点) 7.脚本内启动其他APP ...

  2. Appium使用Python运行appium测试的实例

    Appium使用Python运行appium测试的实例 一.  Appium之介绍 https://testerhome.com/topics/8038 详情参考--https://testerhom ...

  3. appium(2)-Setting up Appium

    Setting up Appium Running Appium on Windows Additional Setup for Android App Testing Download latest ...

  4. 『与善仁』Appium基础 — 10、Appium基本原理

    目录 1.Appium自动化测试架构 2.Appium架构图 3.Session说明 4.Desired Capabilities说明 5.Appium Server说明 6.Appium Clien ...

  5. 『与善仁』Appium基础 — 14、Appium测试环境搭建

    目录 1.Appium测试环境搭建整体思路 (1)Android测试环境搭建 (2)Appium测试环境搭建 (3)测试脚本语言的环境搭建 2.Appium在Android端和IOS端的工作流程 (1 ...

  6. Appium基础二:Appium的安装(基Windows)

    1.JAVA环境配置: 1.1安装jdk: 1.2配置JAVA_Home.Path配置.java验证 Path: 输入C:\Program Files\Java\jdk1.8.0_121\bin:C: ...

  7. 『与善仁』Appium基础 — 12、Appium的安装详解

    目录 (一)Appium server安装 方式一:(桌面方式:推荐) 1.Appium Desktop下载 2.Appium Desktop安装 3.Appium Desktop使用 方式二:(No ...

  8. 『与善仁』Appium基础 — 20、Appium元素定位

    目录 1.by_id定位 2.by_name定位 3.by_class_name定位 4.by_xpath定位 5.by_accessibility_id定位 6.by_android_uiautom ...

  9. Appium+python自动化8-Appium Python API

    Appium+python自动化8-AppiumPython API   前言: Appium Python API全集,不知道哪个大神整理的,这里贴出来分享给大家. 1.contexts conte ...

随机推荐

  1. AC日记——乘积最大 洛谷 P1018

    题目描述 今年是国际数学联盟确定的“2000――世界数学年”,又恰逢我国著名数学家华罗庚先生诞辰90周年.在华罗庚先生的家乡江苏金坛,组织了一场别开生面的数学智力竞赛的活动,你的一个好朋友XZ也有幸得 ...

  2. Leetcode总结之Union Find

    package UnionFind; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; p ...

  3. filter 中用spring StopWatch 监控请求执行时间

    在filter中用spring stopWatch 来统计每个请求的执行时间: 虽然在firefox 中可以清楚的看到每个请求的执行时间,但是为了测试,记录日志, 方便以后查询维护. 还是必要的,下面 ...

  4. arcgis andriod Edit features

    来自:https://developers.arcgis.com/android/guide/edit-features.htm#ESRI_SECTION1_56C60DB71AF941E98668A ...

  5. 深入理解Activity启动流程(二)–Activity启动相关类的类图

    本文原创作者:Cloud Chou. 欢迎转载,请注明出处和本文链接 本系列博客将详细阐述Activity的启动流程,这些博客基于Cm 10.1源码研究. 在介绍Activity的详细启动流程之前,先 ...

  6. Activiti 流程部署方式 activi 动态部署(高级源代码篇)

    Activiti的流程 部署方式有非常多种方式,我们能够依据activit工作流引擎提供的ap方式进行部署. 当然了实际需求决定你要使用哪一种api操作,后面的总结具体介绍了使用场景. 以下看一下部署 ...

  7. SolidEdge 工程图中如何标注尺寸公差

    1 先标注基准框,输入基准符号(A B C之类的)   2 点击特征控制,设置马上要标注的特征和公差(可以保存为模板)   3 直接点击要标注的元素即可   4 没有基准的形位公差标注也一样  

  8. NATSserver配置具体解释

    NATSserver配置具体解释 作者:chszs,未经博主同意不得转载. 经许可的转载需注明作者和博客主页:http://blog.csdn.net/chszs 虽然NATS能够无配置的执行,但也能 ...

  9. Hadoop 源码阅读技巧

    http://www.cnblogs.com/xuxm2007/category/388607.html     个人谈谈阅读hadoop源代码的经验.首先,不得不说,hadoop发展到现在这个阶段, ...

  10. HAProxy简单使用

    一.HAProxy简介及定位         HAProxy 是一款基于TCP和HTTP应用的具备高可用行且负载均衡的代理软件.HAProxy是完全免费的,借助HAProxy可以快速.可靠地提供基于T ...