群攜科技 Soocii App 自動化測試
- Android Studio 2.0
- Python 2.7
- pip 9.0.1
- pip install -r requirement.txt
- Appium
- Android File Transfer
- OSX 環境變數
export ANDROID_HVPROTO=ddm
export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"
export ANDROID_HOME=/Users/<user>/Library/Android/sdk/
export PATH="$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$JAVA_HOME/bin"
-
Uiautomatorviewer
- a tool to inspect app resource id, class name, text
- (OSX)
/Library/Android/sdk/tools/ (Android Studio 2.3版)/Library/Android/sdk/tools/bin
-
Appium Inspector
- a tool to inspect app resource id, class name, text and xpath
APPIUM TIP #13: USE INSPECTOR OR UIAUTOMATORVIEWER FOR UI ELEMENT INSPECTION
透過
adb devices
取得 Device Name
- 目前測試僅支援 WebView 型態的臉書登入介面,請先將 Facebook App 移出或內建的 App 停用
- 將 config.py 複製至 Readme.md 相同路徑
以下是範例,請接洽主管取得此設定檔
#coding=utf-8
# Test environment
PATH_TO_TEST_APK='soocii_xxx_staging.apk'
# Login with existing account and enable usage access once
EXISTING_FACEBOOK_ACCOUNT1="test1@gmail.com"
EXISTING_FACEBOOK_ACCOUNT1_PWD="test1"
EXISTING_FACEBOOK_ACCOUNT1_DISPLAYNAME=u"錢多多"
EXISTING_FACEBOOK_ACCOUNT1_SOOCIIID="test1.mobi"
# Login with new facebook account who friend with existing facebook account
NEW_FACEBOOK_ACCOUNT1="test2@gmail.com"
NEW_FACEBOOK_ACCOUNT1_PWD="test2"
NEW_FACEBOOK_ACCOUNT1_DISPLAYNAME="SoociiQA"
NEW_FACEBOOK_ACCOUNT1_SOOCIIID="test2.qa1"
- 將測試的 APK 檔複製至 Readme.md 相同路徑,並記得修改 config.py
PATH_TO_TEST_APK='soocii_xxx_staging.apk'
-
確認 Android 裝置已經開啟開發人員相關的設定,每種廠牌機型各有差異
-
透過 USB 連接 Android 裝置
- Use
adb devices
to make sure the device is connected
- Use
-
執行測項
# all test cases
py.test -x RAT.py
# single test case
py.test -x RAT.py::SociusTests::test_login_new_facebook_account
當你執行中發現以下類似的錯誤時,請同步 Platform Version,以下面的錯誤訊息為例,請設定為 5.0.2
[AndroidDriver] Error: Unable to find an active device or emulator with OS 6.0.1. The following are available: LC57WYP03147 (5.0.2)
at Object.wrappedLogger.errorAndThrow (lib/logger.js:60:13)
..............................................................
[Error: Unable to find an active device or emulator with OS 6.0.1. The following are available: LC57WYP03147 (5.0.2)]