在使用AppiumLibrary库时,需要预先安装好Appium自动化工具,Appium官网地址为:http://appium.io/

Appium的GitHub地址为:https://github.com/appium

Appium的下载地址:http://appium.io/downloads.html,可以下载最新的安装版本和响应的Library库

Appium的相关介绍文档:http://appium.io/slate/cn/master/

Appium的RobotFramework-appiumlibrary地址:https://github.com/serhatbolsu/robotframework-appiumlibrary,library的安装方式,可以通过pip在线安装,也可以使用下载好library库后,采用python setup.py install的方式来进行安装,

1)  使用pip安装

pip install robotframework-appiumlibrary

2)  使用setup.py安装

git clone https://github.com/jollychang/robotframework-appiumlibrary.git
cd robotframework-appiumlibrary
python setup.py install

Appium介绍

Appium 真正的工作引擎其实是第三方自动化框架,共使用以下的第三方框架:

iOS: 苹果的 UIAutomation

Android 4.2+: Google’s UiAutomator

Android 2.3+: Google’s Instrumentation. (Instrumentation由单独的项目Selendroid提供支持 )

Appium为了实现自身提出的理念你不必局限于某种语言或者框架来写和运行测试脚本和一个移动自动化的框架不应该在接口上重复造轮子,把上面提到的第三方框架都封装成了一套API,即WebDriver,API.WebDriver( “Selenium WebDriver",Appium对此进行了扩展) 指定了客户端到服务端的协议,使用这种客户端-服务端的架构可以使用任何语言来编写客户端,向服务端发送恰当的 HTTP 请求。

Appium 的核心是一个 web 服务器,它提供了一套 REST 的接口。它收到客户端的连接,监听到命令,接着在移动设备上执行这些命令,然后将执行结果放在 HTTP响应中返还给客户端。

Appium中的常用术语

1)  Session

Appium自动化建立在一个session上运行,Client端初始化一个seesion来与服务端进行请求和交互,客户端会发送为一个POST请求给服务端,请求中包含一个JSON对象,被称作“desired capabilities”。然后,服务端就会开启一个自动化的 session,并且返回一个 session ID给客户端,客户端的后续请求都会带上该session ID给服务端做识别。

2)  Desired Capabilities

Desired capabilities 是一些键值对的集合 (比如,一个 map 或者 hashmap),客户端将这些键值对发给服务端,告诉服务端需要怎么执行测试。比如,我们可以把platformNamecapability 设置为 Android,告诉 Appium 服务端,我们想要一个Android的 session,而不是一个 iOS 的。我们也可以设置 safariAllowPopups capability 为 true,确保在 Safari 自动化 session 中,我们可以使用 javascript 来打开新窗口。

3)  Appium Server

Appium server 是基于 Node.js 实现的,可以使用NPM 直接安装。

4)  Appium 服务关键字

usage: appium.js [-h] [-v] [--shell]

[--localizable-strings-dir LOCALIZABLESTRINGSDIR] [--app APP]

[--ipa IPA] [-U UDID] [-a ADDRESS] [-p PORT]

[-ca CALLBACKADDRESS] [-cp CALLBACKPORT] [-bp BOOTSTRAPPORT]

[-k] [-r BACKENDRETRIES] [--session-override] [--full-reset]

[--no-reset] [-l] [-lt LAUNCHTIMEOUT] [-g LOG]

[--log-level {info,info:debug,info:info,info:warn,info:error,wa

rn,warn:debug,warn:info,warn:warn,warn:error,error,error:debug,error:info,error:

warn,error:error,debug,debug:debug,debug:info,debug:warn,debug:error}]

[--log-timestamp] [--local-timezone] [--log-no-colors]

[-G WEBHOOK] [--native-instruments-lib]

[--app-pkg ANDROIDPACKAGE] [--app-activity ANDROIDACTIVITY]

[--app-wait-package ANDROIDWAITPACKAGE]

[--app-wait-activity ANDROIDWAITACTIVITY]

[--android-coverage ANDROIDCOVERAGE] [--avd AVD]

[--avd-args AVDARGS]

[--device-ready-timeout ANDROIDDEVICEREADYTIMEOUT] [--safari]

[--device-name DEVICENAME] [--platform-name PLATFORMNAME]

[--platform-version PLATFORMVERSION]

[--automation-name AUTOMATIONNAME]

[--browser-name BROWSERNAME] [--default-device]

[--force-iphone] [--force-ipad] [--language LANGUAGE]

[--locale LOCALE] [--calendar-format CALENDARFORMAT]

[--orientation ORIENTATION]

[--tracetemplate AUTOMATIONTRACETEMPLATEPATH]

[--instruments INSTRUMENTSPATH] [--show-sim-log]

[--show-ios-log] [--nodeconfig NODECONFIG] [-ra ROBOTADDRESS]

[-rp ROBOTPORT] [--selendroid-port SELENDROIDPORT]

[--chromedriver-port CHROMEDRIVERPORT]

[--chromedriver-executable CHROMEDRIVEREXECUTABLE]

[--use-keystore] [--keystore-path KEYSTOREPATH]

[--keystore-password KEYSTOREPASSWORD] [--key-alias KEYALIAS]

[--key-password KEYPASSWORD] [--show-config]

[--no-perms-check] [--command-timeout DEFAULTCOMMANDTIMEOUT]

[--keep-keychains] [--strict-caps] [--isolate-sim-device]

[--tmp TMPDIR] [--trace-dir TRACEDIR]

[--intent-action INTENTACTION]

[--intent-category INTENTCATEGORY]

[--intent-flags INTENTFLAGS]

[--intent-args OPTIONALINTENTARGUMENTS]

[--dont-stop-app-on-reset] [--debug-log-spacing]

[--suppress-adb-kill-server] [--async-trace]

A webdriver-compatible server for use with native and hybrid iOS and Android

applications.

Optional arguments:

-h, --help            Show this help message and exit.

-v, --version         Show program's version number and exit.

--shell               Enter REPL mode

--localizable-strings-dir LOCALIZABLESTRINGSDIR

IOS only: the relative path of the dir where

Localizable.strings file resides

--app APP             IOS: abs path to simulator-compiled .app file or the

bundle_id of the desired target on device; Android:

abs path to .apk file

--ipa IPA             (IOS-only) abs path to compiled .ipa file

-U UDID, --udid UDID  Unique device identifier of the connected physical

device

-a ADDRESS, --address ADDRESS

IP Address to listen on

-p PORT, --port PORT  port to listen on

-ca CALLBACKADDRESS, --callback-address CALLBACKADDRESS

callback IP Address (default: same as --address)

-cp CALLBACKPORT, --callback-port CALLBACKPORT

callback port (default: same as port)

-bp BOOTSTRAPPORT, --bootstrap-port BOOTSTRAPPORT

(Android-only) port to use on device to talk to Appium

-k, --keep-artifacts  [DEPRECATED] no effect, trace is now in tmp dir by

default and is cleared before each run. Please also

refer to the --trace-dir flag.

-r BACKENDRETRIES, --backend-retries BACKENDRETRIES

(iOS-only) How many times to retry launching

Instruments before saying it crashed or timed out

--session-override    Enables session override (clobbering)

--full-reset          (iOS) Delete the entire simulator folder. (Android)

Reset app state by uninstalling app instead of

clearing app data. On Android, this will also remove

the app after the session is complete.

--no-reset            Don't reset app state between sessions (IOS: don't

delete app plist files; Android: don't uninstall app

before new session)

-l, --pre-launch      Pre-launch the application before allowing the first

session (Requires --app and, for Android, --app-pkg

and --app-activity)

-lt LAUNCHTIMEOUT, --launch-timeout LAUNCHTIMEOUT

(iOS-only) how long in ms to wait for Instruments to

launch

-g LOG, --log LOG     Also send log output to this file

--log-level {info,info:debug,info:info,info:warn,info:error,warn,warn:debug,wa

rn:info,warn:warn,warn:error,error,error:debug,error:info,error:warn,error:error

,debug,debug:debug,debug:info,debug:warn,debug:error}

log level; default (console[:file]): debug[:debug]

--log-timestamp       Show timestamps in console output

--local-timezone      Use local timezone for timestamps

--log-no-colors       Don't use colors in console output

-G WEBHOOK, --webhook WEBHOOK

Also send log output to this HTTP listener

--native-instruments-lib

(IOS-only) IOS has a weird built-in unavoidable delay.

We patch this in appium. If you do not want it

patched, pass in this flag.

--app-pkg ANDROIDPACKAGE

(Android-only) Java package of the Android app you

want to run (e.g., com.example.android.myApp)

--app-activity ANDROIDACTIVITY

(Android-only) Activity name for the Android activity

you want to launch from your package (e.g.,

MainActivity)

--app-wait-package ANDROIDWAITPACKAGE

(Android-only) Package name for the Android activity

you want to wait for (e.g., com.example.android.myApp)

--app-wait-activity ANDROIDWAITACTIVITY

(Android-only) Activity name for the Android activity

you want to wait for (e.g., SplashActivity)

--android-coverage ANDROIDCOVERAGE

(Android-only) Fully qualified instrumentation class.

Passed to -w in adb shell am instrument -e coverage

true -w

--avd AVD             (Android-only) Name of the avd to launch

--avd-args AVDARGS    (Android-only) Additional emulator arguments to

launch the avd

--device-ready-timeout ANDROIDDEVICEREADYTIMEOUT

(Android-only) Timeout in seconds while waiting for

device to become ready

--safari              (IOS-Only) Use the safari app

--device-name DEVICENAME

Name of the mobile device to use

--platform-name PLATFORMNAME

Name of the mobile platform: iOS, Android, or

FirefoxOS

--platform-version PLATFORMVERSION

Version of the mobile platform

--automation-name AUTOMATIONNAME

Name of the automation tool: Appium or Selendroid

--browser-name BROWSERNAME

Name of the mobile browser: Safari or Chrome

--default-device, -dd

(IOS-Simulator-only) use the default simulator that

instruments launches on its own

--force-iphone        (IOS-only) Use the iPhone Simulator no matter what

the app wants

--force-ipad          (IOS-only) Use the iPad Simulator no matter what the

app wants

--language LANGUAGE   Language for the iOS simulator / Android Emulator

--locale LOCALE       Locale for the iOS simulator / Android Emulator

--calendar-format CALENDARFORMAT

(IOS-only) calendar format for the iOS simulator

--orientation ORIENTATION

(IOS-only) use LANDSCAPE or PORTRAIT to initialize

all requests to this orientation

--tracetemplate AUTOMATIONTRACETEMPLATEPATH

(IOS-only) .tracetemplate file to use with Instruments

--instruments INSTRUMENTSPATH

(IOS-only) path to instruments binary

--show-sim-log        (IOS-only) if set, the iOS simulator log will be

written to the console

--show-ios-log        (IOS-only) if set, the iOS system log will be written

to the console

--nodeconfig NODECONFIG

Configuration JSON file to register appium with

selenium grid

-ra ROBOTADDRESS, --robot-address ROBOTADDRESS

IP Address of robot

-rp ROBOTPORT, --robot-port ROBOTPORT

port for robot

--selendroid-port SELENDROIDPORT

Local port used for communication with Selendroid

--chromedriver-port CHROMEDRIVERPORT

Port upon which ChromeDriver will run

--chromedriver-executable CHROMEDRIVEREXECUTABLE

ChromeDriver executable full path

--use-keystore        (Android-only) When set the keystore will be used to

sign apks.

--keystore-path KEYSTOREPATH

(Android-only) Path to keystore

--keystore-password KEYSTOREPASSWORD

(Android-only) Password to keystore

--key-alias KEYALIAS  (Android-only) Key alias

--key-password KEYPASSWORD

(Android-only) Key password

--show-config         Show info about the appium server configuration and

exit

--no-perms-check      Bypass Appium's checks to ensure we can read/write

necessary files

--command-timeout DEFAULTCOMMANDTIMEOUT

The default command timeout for the server to use for

all sessions. Will still be overridden by

newCommandTimeout cap

--keep-keychains      (iOS) Whether to keep keychains (Library/Keychains)

when reset app between sessions

--strict-caps         Cause sessions to fail if desired caps are sent in

that Appium does not recognize as valid for the

selected device

--isolate-sim-device  Xcode 6 has a bug on some platforms where a certain

simulator can only be launched without error if all

other simulator devices are first deleted. This

option causes Appium to delete all devices other than

the one being used by Appium. Note that this is a

permanent deletion, and you are responsible for using

simctl or xcode to manage the categories of devices

used with Appium.

--tmp TMPDIR          Absolute path to directory Appium can use to manage

temporary files, like built-in iOS apps it needs to

move around. On *nix/Mac defaults to /tmp, on Windows

defaults to C:\Windows\Temp

--trace-dir TRACEDIR  Absolute path to directory Appium use to save ios

instruments traces, defaults to <tmp

dir>/appium-instruments

--intent-action INTENTACTION

(Android-only) Intent action which will be used to

start activity

--intent-category INTENTCATEGORY

(Android-only) Intent category which will be used to

start activity

--intent-flags INTENTFLAGS

(Android-only) Flags that will be used to start

activity

--intent-args OPTIONALINTENTARGUMENTS

(Android-only) Additional intent arguments that will

be used to start activity

--dont-stop-app-on-reset

(Android-only) When included, refrains from stopping

the app before restart

--debug-log-spacing   Add exaggerated spacing in logs to help with visual

inspection

--suppress-adb-kill-server

(Android-only) If set, prevents Appium from killing

the adb server instance

--async-trace         Add long stack traces to log entries. Recommended for

debugging only.

服务关键字

描述

automationName

自动化测试引擎的名称,比如Appium (默认) 或 Selendroid

platformName

待测试的手机操作系统,比如iOSAndroid, 或 FirefoxOS

platformVersion

手机操作系统版本

deviceName

手机device或模拟器的device,在安卓上,可以通过adb devices 来得到,在ios上,可以使用 instruments -s devices来得到

app

.ipa or .apk文件所在的本地绝对路径或者远程路径

browserName

待自动化测试的手机 的web 浏览器名称,如果是对APP应用进行自动化测试,这个关键字的值应该要为空。

newCommandTimeout

执行命令超时时间,单位:秒。如果达到超时时间仍未接收到新的命令时 Appium 会认为客户端退出然后自动结束会话。

autoLaunch

Appium是否需要自动安装和启动应用,默认true

language

(Sim/Emu-only) 设定模拟器 ( simulator / emulator ) 的语言。

locale

(Sim/Emu-only) 设定模拟器 ( simulator / emulator ) 的区域设置。

noReset

不在会话前重置应用状态,默认值false

fullReset

Android上通过卸载,而不是清空数据重置应用状态,在 Android 上会话结束后自动清除被测应用,ios上会删除整个模拟器目录。

udid

连接的物理设备的唯一设备标识

orientation

(Sim/Emu-only) 在一个设定的方向模式中开始测试

【原文归作者所有,欢迎转载,但是保留版权】

相关博文汇总:

RobotFramework下的http接口自动化Create Http Context关键字的使用

RobotFramework下的http接口自动化Get关键字的使用

RobotFramework下的http接口自动化post关键字的使用

如何创建一个自动化测试项目

RobotFramework下的http接口自动化Get Response Body关键字的使用

RobotFramework下的http接口自动化Get Response Status 关键字的使用

RobotFramework下的http接口自动化Get Response header 关键字的使用

RobotFramework下的http接口自动化Set Request Header 关键字的使用

RobotFramework下HttpLibrary库其它关键字

RobotFramework下的http接口自动化Set Request Body 关键字的使用

RobotFramework下的http接口自动化Follow Response关键字的使用

RobotFramework自动化测试框架的基础关键字(一)

RobotFramework自动化测试框架的基础关键字(二)

RobotFramework自动化测试框架的基础关键字(三)

RobotFramework自动化测试框架的基础关键字(四)

RobotFramework自动化测试框架的基础关键字(五)

RobotFramework自动化测试框架-移动手机自动化测试AppiumLibrary介绍

RobotFramework自动化测试框架-移动手机自动化测试Open Application关键字的使用

RobotFramework自动化测试框架-常用断言关键字

RobotFramework自动化测试框架-移动手机自动化测试AppiumLibrary库其它的常见自动化关键字

RobotFramework自动化测试框架-移动手机自动化测试Input Text和Click Button关键字的使用

RobotFramework自动化测试框架-移动手机自动化测试Clear Text关键字的使用

RobotFramework自动化测试框架-移动手机自动化测试Click Element关键字的使用

RobotFramework自动化测试框架-移动手机自动化测试Click A Point关键字的使用

RobotFramework自动化测试框架-移动手机自动化测试Click Element At Coordinates关键字的使用

RobotFramework自动化测试框架-移动手机自动化测试Get Element Location关键字的使用

RobotFramework自动化测试框架-移动手机自动化测试Get Network Connection Status和Set Network Connection Status关键字的使用

RobotFramework自动化测试框架-移动手机自动化测试Element Attribute Should Match关键字的使用

RobotFramework自动化测试框架-DatabaseLibrary库的使用(对数据库的操作)

RobotFramework自动化测试框架-使用Python编写自定义的RobotFramework Lib

RobotFramework自动化测试框架-Selenium Web自动化(-)-Open Browser和Close Browser

RobotFramework自动化测试框架-MongoDBLibrary库的使用

RobotFramework自动化测试框架-移动手机自动化测试AppiumLibrary介绍的更多相关文章

  1. RobotFramework自动化测试框架-移动手机自动化测试AppiumLibrary库其它的常见自动化关键字

    关键字 使用描述 Close Application 关闭掉当前已经打开的APP Application,该关键字不需要接收任何的参数,但是使用该关键字的前提是已经打开了一个APP Applicati ...

  2. RobotFramework自动化测试框架-移动手机自动化测试Input Text和Click Button关键字的使用

    Input Text和Click Button Input Text 关键字一般用来给输入框进行输入操作,该关键字接收两个参数[ locator | text ]. 示例1:启动安卓手机上一个APP的 ...

  3. RobotFramework自动化测试框架-移动手机自动化测试Open Application关键字的使用

    在AppiumLibrary库中,Open Application关键字用来打开一个待测试移动APP. 示例1:连接本机已经打开的appium服务端,打开一个待测试的安卓APP,指定测试平台为Andr ...

  4. RobotFramework自动化测试框架-移动手机自动化测试Get Network Connection Status和Set Network Connection Status关键字的使用

    Get Network Connection Status关键字用来获取手机的网络连接状态.在获取到连接状态后,会返回不同的数字. Set Network Connection Status关键字用来 ...

  5. RobotFramework自动化测试框架-移动手机自动化测试Clear Text关键字的使用

    Clear Text关键字用来清除输入框的数据,该关键字接收一个参数[ locator ],这里的locator指的就是界面元素的定位方式. 示例1:Clear Text清除输入框数据时,采用reso ...

  6. RobotFramework自动化测试框架-移动手机自动化测试Click Element关键字的使用

    Click Element关键字用来模拟点击APP界面上的一个元素,该关键字接收一个参数[ locator ] ,这里的locator指的是界面元素的定位方式. 示例1:使用Click Element ...

  7. RobotFramework自动化测试框架-移动手机自动化测试Click A Point关键字的使用

    Click A Point关键字用来模拟点击APP界面上的一个点,该关键字接收两个三个参数[ x=0 | y=0 | duration=100 ],x和y代表的是点的坐标位置,duration代表的是 ...

  8. RobotFramework自动化测试框架-移动手机自动化测试Click Element At Coordinates关键字的使用

    Click Element At Coordinates关键字通过一个具体的坐标点,来模拟点击一个Element,该关键字接收两个参数[ coordinate_X | coordinate_Y ]. ...

  9. RobotFramework自动化测试框架-移动手机自动化测试Get Element Location关键字的使用

    Get Element Location关键字用来获取一个Element的Location位置,该关键字接收一个参数[ locator ] 示例1:使用Get Element Location来获取一 ...

随机推荐

  1. Pycharm创建的virtualenv环境缺失pip.exe的问题(Windows系统)

    Windows环境: 1. Python安装在d:\Python\Python35下, Python新版本安装时默认会勾选pip功能 2. PyCharm的Settings中Create Virtua ...

  2. Codeforces 818B Permutation Game

    首先看一下题目 B. Permutation Game time limit per test 1 second memory limit per test 256 megabytes input s ...

  3. js模拟jq获取id

    js模拟jq获取id: (jquery)需要自己添加 <!DOCTYPE html> <html lang="en"> <head> <m ...

  4. ASP.NET Core Web API 最小化项目

    ASP.NET Core中默认的ASP.NET Core 模板中有Web API 模板可以创建Web API项目. 有时,只需要创建一个API,不需要关心Razor,本地化或XML序列化.通过删除无用 ...

  5. webpack的Hot Module Replacement运行机制

    使用webpack打包,难免会使用Hot Module Replacement功能,该功能能够实现修改.添加或删除前端页面中的模块代码,而且是在页面不刷新的前提下.它究竟是怎么运作的呢?本文主要从调试 ...

  6. Perl根据日期分割数据文件

    Perl的优势:比C好写,比Shell高效,Linux普遍支持. #!/usr/bin/perl -w # auth: lichmama@cnblogs.com # what: split data_ ...

  7. 水题 第三站 HDU Largest prime factor

    先写一遍思路,跟素数表很类似吧. 1)从小到大遍历数据范围内的所有数.把包含质因子的数的位置都设成跟质因子的位置相同. 2)同一个数的位置可能被多次复写.但是由于是从小到大遍历,这就保证了最后一次写入 ...

  8. SQL server数据库备份还原问题备忘(亲测有效)

    问题一:SQL server数据库备份还原方法 http://www.cnblogs.com/zgqys1980/archive/2012/07/04/2576382.html 问题二:无法执行 BA ...

  9. UltraEdit MAC破解方法

    在终端输入 printf '\x31\xC0\xFF\xC0\xC3\x90' | dd seek=$((0x92D370)) conv=notrunc bs=1 of=/Applications/U ...

  10. redhat设置开机自动连接网络

    一.设置开机自动连接网络1.用root账号登录2.打开etcsysconfignetwork-scrpts目录3.vi ifcfg-eth04.将ONBOOT改为yes 二.没有图形界面如何连接网络1 ...