使用 HomeBrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# 可能需要 GitHub 的帳號
brew tap homebrew/cask
Python:
pip install robotframework
Python3:
python3 -m pip install robotframework
Python:
robot [options] data_sources
rebot [options] robot_outputs
Python3:
python3 -m robot.run [options] data_sources
python3 -m robot.rebot [options] robot_outputs
Python3 很麻煩?
那就取個暱稱吧!
在家目錄找到 .bashprofile
使用 zsh 的話,就找 .zshrc
在檔案末尾加上
alias rebot='python3 -m robot.rebot'
alias robot='python3 -m robot.run'
當然要記得存檔
這樣就跟使用 Python 一樣了
然後還是要記得重開終端機
#這是 comand line tool
brew install Appium
pip install robotframework-appiumlibrary
#注意,這裡要有 cask 才會安裝應用程式
brew cask install Appium
安裝完畢就能在應用程式中找到了
啟動 Appium ……
然後馬上遇到問題😂
解除封鎖
解除封鎖
再次啟動
IP 使用 0.0.0.0 或是 127.0.0.1 都可以
按下[Start Server v1.15.1],啟動
按下[🔍]
裝置的設定參數
{
"platformName": "iOS",
"platformVersion": "13.0",
"deviceName": "iPad 9", //<-- 你的裝置名稱,不影響功能,可以隨意命名
"automationName": "XCUITest",
"language": "zh-TW",
"udid": "UDID", //<-- iPad 的 UDID,
"bundleId": "com.unieat.POS",
"xcodeOrgId": "7NH88K8P46", //<-- Team 是使用 Big innovation 的話,那就不需要改了
"xcodeSigningId": "iPhone Developer",
"wdaLocalPoet_3": "8102",
"useNewWDA": true
}
找到自己的 UDID
用 finder 或是
instruments -s devices | grep -e '.*\[\([a-zA-Z0-9]\{40\}\|[0-9]\{8\}-[a-zA-Z0-9]\{16\}\)\]'
然後就[Start Section]
Sublime Text 的 Robot framework 語法輔助
https://github.com/andriyko/sublime-robot-framework-assistant
Visual Studio Code 的 Robot framework 語法輔助
https://marketplace.visualstudio.com/items?itemName=TomiTurtiainen.rf-intellisense
*** Settings ***
Library AppiumLibrary
*** Variables ***
# App informations
${bundle identifier} com.unieat.POS
#如果 0.0.0.0 無法使用,就改成 127.0.0.1
${host} http://0.0.0.0:4723/wd/hub
${port} 8100
${iOS version} 13.0
# Device informations
${udid} 99cb70f1bb0189087b1bd0def269d728a2f7c59a
# App accounts
${store code} [你的店家代碼]
${account} [你的帳號]
${password} [你的密碼]
*** Test Cases ***
Case1 - Launch app
Launch app ${udid}
Case2 - Input account
Login ${store code} ${account} ${password}
Log To Console *** Input account successful ***
Case3 - Hide Keyboard
Click Element id=隱藏鍵盤
Log To Console *** Hide Keyboard successful ***
Case4 - Login
Click Element id=confirmBtn
Log To Console *** Login successful ***
*** Keywords ***
Launch app
[Arguments] ${udid}
Open Application ${host} platformName=iOS platformVersion=${iOS version} deviceName=iPad app=${bundle identifier} udid=${udid} wdaLocalPort=${port}
Log To Console *** Launch app successful ***
Log === Launch app successful ===
Login
[Arguments] ${store code} ${account} ${password}
[Documentation] Input login information
log === Start login ==
Clean and Input id=companyCode ${store code}
Clean and Input id=account ${account}
Clean and Input id=password ${password}
log === Input finish ===
Clean and Input
[Arguments] ${text field} ${text}
Clear Text ${text field}
Input Text ${text field} ${text}
然後存檔為DudooPos.robot
Robot Framework User Guide
http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html
內建的功能
https://robotframework.org/robotframework/latest/libraries/BuiltIn.html
String
https://robotframework.org/robotframework/latest/libraries/String.html
Appium
http://serhatbolsu.github.io/robotframework-appiumlibrary/AppiumLibrary.html
第一次使用的時候會自動的取得 WebDriverAgent 的第三方套件資料,
並且 WebDriverAgent 的第三方套件是使用 Carthage 管理的,
所以需要透過它來安裝第三方套件。
brew install carthage
在那之前,有兩種測試環境設定
準備 Default capabilities
提供 WebDriverAgent 的 code sign 資訊
{"xcodeOrgId": "7NH88K8P46","xcodeSigningId": "iPhone Developer","wdaLocalPoet_3": "8102","useNewWDA": true}
然後存檔為DeviceCapabilities.json
啟動 Appium
# 要跟前一個 json 檔案相同目錄
appium --default-capabilities "$(cat DeviceCapabilities.json)"&
開始 Robot 測試
robot -d ./Result DudooPos.robot
停止 Appium
# 喚回在背景的 appium
fg
# 之後按下 control + C 停止 appium
# Appium 版
git clone https://github.com/appium/WebDriverAgent.git
# facebook 版 (此 Git 倉已封存了,除非 Appium 版無法使用)
git clone https://github.com/facebookarchive/WebDriverAgent.git
進入 WebDriverAgent 的資料夾中,安裝第三方套件。
cd WebDriverAgent
carthage update
編譯到實機