一、app(appaction)
(一)、AppAction
*** Settings ***
Library AppiumLibrary
Library DateTime
Resource Variable.txt
*** Keywords ***
1、关闭全部应用
AppiumLibrary.Close All Applications【应用】
2、打开应用
[Arguments] ${remote_url} &{input}
AppiumLibrary.Open Application ${remote_url} &{input}
3、滑动页面
[Arguments] ${START_X} ${START_Y} ${OFFSET_X} ${OFFSET_Y} ${DURATION}=1000
AppiumLibrary.Swipe ${START_X} ${START_Y} ${OFFSET_X} ${OFFSET_Y} ${DURATION}【刷卡,滑动】
4、输入文本(元素属性)
[Arguments] ${LOCATOR} ${TEXT}
AppiumLibrary.Input Text ${LOCATOR} ${TEXT}【定位器】#输入文字
5、输入值
[Arguments] ${LOCATOR} ${TEXT}
AppiumLibrary.Input Value ${LOCATOR} ${TEXT} #输入文字
6、抓取屏幕
[Arguments] ${FILE_NAME}=
${picName} Evaluate time.strftime("%Y%m%d%H%M%S", time.localtime()) time
Run Keyword If '${FILE_NAME}'=='' AppiumLibrary.Capture Page Screenshot ${picName}.png
... ELSE AppiumLibrary.Capture Page Screenshot ${FILE_NAME}.png
7、按键(手机硬件:菜单,返回,主页,电源,音量+—)
[Arguments] ${keyCode}
${key} Evaluate int(${keyCode})
AppiumLibrary.Press Keycode ${keyCode}
8、清除文本
[Arguments] ${LOCATOR}
AppiumLibrary.Clear Text ${LOCATOR}
9、获取偏移日期
[Arguments] ${OFFSET}
${date} Get Time
${newDate} Add Time To Date ${date} ${OFFSET} %Y-%m-%d
[Return] ${newDate}
10、向上滚动
[Arguments] ${LOCATOR}