# Appium 簡述

## appium
- 運行時的基本檢查
- 節點版本(>= 5)
- CLI 參數檢查
- 包含所有可用和支持的CLI參數
- 檢是否有沖突和棄用
- 統一存放日志
- 統一存放npmlog, winston和自定義log
- 啟動AppiumDriver(繼承Basedriver)
- 為iOS/Android/Fake Driver 建立會話
- 創建/刪除Appium會話
- 啟動baseServer (appium-express)
- 通過driver給出的路徑
## appium-express (部分appium basedriver)
- 啟動express server(允許x-domain-origin)
- 從AppiumDriver初始化
- 超時處理
- 提供一個用于測試的靜態頁面
- 將req/res事件記入日志
## mobile-json-wire-protocol (部分appium basedriver)
- 提供了Appium命令列表
- 通過協議的驅動子類
-客戶端和驅動程序之間的中間件
- 處理驅動程序的jwp代理
- 包含所有類型錯誤的錯誤類
- 消除錯誤響應
- 將參數封裝/解封到命令中
- 檢查所需參數,驗證參數
## appium basedriver
- 每個實例化都有一個單獨的測試會話
- 包含對caps的約束 (platformName必須存在等)
- 驗證功能
- 運行具有單個并發性的命令
- 處理會話重啟
- 處理滑動選項
- DeviceSettings負責設備的get/update管理
- 包含基本命令
- 找到元素
- 創建/刪除會話
- 處理超時
- 設備的set/update設置
- 為命令提供幫助方法
## appiium iosdriver
- 也可以作為獨立服務器運行(從appium-express繼承了小部分服務)
- 支持的策略:“name”,“xpath”,“id”,“-ios uiautomation”,“class name”,“accessibility id”
- 可以啟動一個模擬器或一個真實的設備(需要標明udid)
- 每個類型的說明
- removeInstrumentsSocket
- setBundleIdFromApp
- createInstruments
- runSimReset, isolateSimDevice, setLocale || runRealDeviceReset
- setPreferences || runRealDeviceReset
- startLogCapture
- prelaunchSimulator || (noop)
- startInstruments
- onInstrumentsLaunch
- configureBootstrap
- setBundleId
- setInitialOrientation
- initAutoWebview
- waitForAppLaunched
- 所有幫助說明都在driver.js中
- 包含一組更具體的功能約束
- 有使用appium-xcode構建和運行Safari(safari-launcher)的邏輯
- 實現iOSdriver的命令
- Selenium命令被編譯為ui-automator命令
- 命令將會發送到uiAutoClient(appium-uiauto)
- 連接到appium遠程調試器
## appium-xcode
- 運行shell命令從Xcode返回有用的數據,比如
- getPath
- getVersion
- getAutomationTraceTemplatePath
- getMaxIOSSDK
- …
- 內置自動重試
## appium-uiauto
- 封裝 iOS UI Automation 框架
- 通過socket連接進行通信
- 運行由sendCommand函數填充的命令隊列
- 處理來自ui-automation的響應(作為緩沖區)
- 使用osascript旋轉屏幕截圖
- 提供bootstrap simulator/realdevice (dynamic-bootstrap)的方法
- 在iOS UI自動化上下文(非節點)中運行的JavaScript文件
- 負責執行實際的iOS UI Automation命令
- 參考 [UIAutomation docs](https://web.archive.org/web/20160904214108/https://developer.apple.com/library/ios/documentation/DeveloperTools/Reference/UIAutomationRef/)
- 命令流程就像
- Webdriver 命令-> iOS driver 命令 -> uiauto-命令
## appium-instruments
- 封裝運行instruments的命令
- 很多exec調用與instruments二進制義互
- 所有這些都采取回調來獲取結果
- 必須使用“iwd”包編譯軟件包
- 特殊的Instruments包不存在命令延遲
-?還包含較舊版本的iwd instrument(v4 - v7)
## appium-ios日志
- 捕獲iOS模擬器或真機的控制臺,性能和崩潰日志
- 通過調用tail來從系統路徑獲取日志(模擬器設備)
- 或通過調用deviceconsole(真機)
- 使用遠程調試器來抓取性能日志
- 崩潰日志保留在系統上的“.crash”文件中
## appium-iOS-模擬器
- 封裝iOS模擬器應用程序
- 啟動和關閉(殺死所有)模擬器
- 更新設置和本地
- 更新/清除 safari
- 獲取有關模擬器設備的元數據
- 使用simctl與模擬器通信
- 適用于Xcode 6和7
## node-simctl
- 封裝simctl二進制(cli實用程序來控制iOS模擬器)
- 作為xcrun的子命令執行(從命令行查找或調用開發人員工具)
- 包含功能
- 安裝/刪除應用程序
- 啟動和關閉模擬器
- 創建/清除/刪除設備
- 獲取設備列表
## appium-cookies
- 簡單的包來創建和接收cookie
- 在appium-iosdriver中使用,以在Web上下文中實現jswonwire cookie命令
## appium-chromedriver
- 封裝 chromedriver
- 下載并安裝chromedriver二進制文件
- 啟動,重新啟動并停止(或殺死所有)chrome實例
- 使用appium-jsonwp-proxy向driver發送json wire protocol命令
## jsonwp-proxy (部分appium-base-driver)
- 允許將json wire協議命令發送到了解它的服務器(瀏覽器驅動程序)
- 解析json的響應
- 允許代理服務器的請求
- 用戶在 appium-chromedriver 里通信
## appium-android-driver
- 類似于appium-ios-driver,它可以作為獨立服務運行
- 自動化模擬器和真機上的原生,混合和移動Web應用程序
- 負責安裝Android軟件包到設備
- 如果需要,運行chromedriver會話
- 包含一組更具體的功能約束
- 使用appium-adb與emulator/simulator/realdevice進行交互
- 和appium-android-bootstrap來執行實際的命令
- 包含helpers找出哪個網頁視圖屬于哪個應用程序包,反之亦然
## appium-adb
- 封裝 Android Debug Bridge(adb)
- 包含一些基本的rpc到adb二進制的命令
- 容納jar文件來運行特殊用例,例如簽名,驗證應用程序或移動manifests
- 允許與webdriver協議無關的特殊(移動專用)模擬器命令
- 鎖定屏幕
- 按返回按鈕
- 按home按鈕
- 設置/獲取飛行模式
- 設置/獲取wifi狀態
- 捕獲logcat
- 處理模擬器/模擬器動作(例如重啟)
## appium-android-bootstrap
- JavaScript界面??和Java代碼,用于與Android UI Automator進行交互
- 構建包含邏輯執行命令的AppiumBootstrap.jar
- 對應的 iOS 上的 appium-uiauto
- 一旦啟動,就會創建一個到設備的web scoket連接
- 應用程序提供啟動/關閉/發送命令接口
- 命令流程如下:
- Selenium 命令 - > appium-adb - > appium-androidbootstrap - > 使用Android UI Automator 框架的 Java 代碼
## appium-uiautomator
- 啟動和關閉uiautomator服務器,uiautomator由appium-android-bootstrap jar 構建
- 命令流程如下:
- appium-android-bootstrap:start -> appium-uiautomator:start -> appium-adb:install bootstrap
## appium-android-ime
- 允許從 Android 設備發送和接收 unicode 字符
- 將文本編碼為UTF-7將其發送到設備并將其重新編碼為 Unicode
- 由 appium-android-driver 使用
## appium-doctor
- 在啟動Appium之前診斷,報告和修復常見的Node,iOS和Android配置問題
- 暴露cli命令“appium-doctor”
- 它檢查
- Android:
- android sdk存在并正確配置
- env變量和路徑檢查
- iOS:
- 安裝了xcode(使用命令行工具)
- 開發工具安全檢查
- auth檢查
- node 二進制校驗
## appium-gulp-plugins
- 具有定制插件的開發包使用交叉應用模塊(僅適用于Appium開發)
- 包含任務
- e2e和單元測試(覆蓋率報告)
- 將ES2016 轉換成 ES5
- 靜態代碼分析(eslint)
- 開發人員的任務
## appium-remote-debugger
- RPC客戶端將Appium連接到iOS webviews
- 可以連接到WebKit devtools
- 僅適用于iOS
- 有兩個rpc客戶端類
- remote-debugger-rpc-client:使用連接到localhost的tcp6:27753
- webkit-rpc-client:使用WebSockets連接到ws:// localhost:27753 / devtools / page / $ {pageId}
## node-teen_process
- 助手模塊暴露:
- exec:在引擎蓋下使用spawn的exec的ES7(async / await)實現
- SubProcess:在使用spawn時減少樣板(特別是在async / await上下文中使用時)
## appium 日志
- 運行時,日志器默認為 npmlog,
- 暴露了幾乎所有的Appium軟件包使用的getLogger函數
- 如果有一個已經運行的記錄器,那么所有的東西都會記錄
## appium-support
- 用于支持跨應用程序包的庫的實用程序函數。
- 為一些常見的操作提供封裝,如
- 系統方法(isWindows,isLinux ...)
- 實用程序方法,如hasValue,escapeSpace
- 一堆fs方法
- plist幫助類解析和更新plist文件
本文由 [校長](https://testerhome.com/xushizhao) 翻譯,由 [lihuazhang](https://github.com/lihuazhang) 校驗。
- 關于TesterHome和MTSC
- 關于Appium
- 簡介
- Appium 客戶端
- 入門指南
- 已支持的平臺
- API 文檔
- Appium驅動
- XCUITest (iOS)
- XCUITest Real Devices (iOS)
- UIAutomation (iOS)
- UIAutomation Safari Launcher (iOS)
- UIAutomator (Android)
- UIAutomator2 (Android)
- Espresso (Android)
- Windows
- Mac
- Appium命令
- Status
- Execute Mobile Command
- Session
- Create
- End
- Get Session Capabilities
- Go Back
- Screenshot
- Source
- Timeouts
- Timeouts
- Implicit Wait
- Async Script
- Orientation
- Get Orientation
- Set Orientation
- Geolocation
- Get Geolocation
- Set Geolocation
- Logs
- Get Log Types
- Get Logs
- Events
- Log event
- Get events
- Settings
- Update Settings
- Get Device Settings
- Settings
- Update Settings
- Get Device Settings
- Execute Driver Script
- Device
- Activity
- Start Activity
- Current Activity
- Current Package
- App
- Install App
- Is App Installed
- Launch App
- Background App
- Close App
- Reset App
- Remove App
- Activate App
- Terminate App
- Get App State
- Get App Strings
- End Test Coverage
- Clipboard
- Get Clipboard
- Set Clipboard
- Emulator
- Power AC
- Power Capacity
- Files
- Push File
- Pull File
- Pull Folder
- Interactions
- Shake
- Lock
- Unlock
- Is Locked
- Rotate
- Keys
- Press keycode
- Long press keycode
- Hide Keyboard
- Is Keyboard Shown
- Network
- Toggle Airplane Mode
- Toggle Data
- Toggle WiFi
- Toggle Location Services
- Send SMS
- GSM Call
- GSM Signal
- GSM Voice
- Network Speed
- Performance Data
- Get Performance Data
- Performance Data Types
- Screen Recording
- Start Screen Recording
- Stop Screen Recording
- Simulator
- Perform Touch ID
- Toggle Touch ID Enrollment
- System
- Open Notifications
- System Bars
- System Time
- Display density
- Authentication
- Finger Print
- Element
- Find Element
- Find Elements
- Actions
- Click
- Send Keys
- Clear
- Attributes
- Text
- Name
- Attribute
- Selected
- Enabled
- Displayed
- Location
- Size
- Rect
- CSS Property
- Location in View
- Other
- Submit
- Active Element
- Equals Element
- Context
- Get Context
- Get All Contexts
- Set Context
- Interactions
- Mouse
- Move To
- Click
- Double Click
- Button Down
- Button Up
- Touch
- Single Tap
- Double Tap
- Move
- Touch Down
- Touch Up
- Long Press
- Scroll
- Flick
- Multi Touch Perform
- Touch Perform
- W3C Actions
- Web
- Window
- Set Window
- Close Window
- Get Handle
- Get Handles
- Get Title
- Get Window Size
- Set Window Size
- Get Window Position
- Set Window Position
- Maximize Window
- Navigation
- Go to URL
- Get URL
- Back
- Forward
- Refresh
- Storage
- Get All Cookies
- Set Cookie
- Delete Cookie
- Delete All Cookies
- Frame
- Switch to Frame
- Switch to Parent Frame
- Execute Async
- Execute
- 編寫 & 運行Appium腳本
- Running Tests
- Desired Capabilities
- The --default-capabilities flag
- Finding Elements
- Touch Actions
- CLI Arguments
- Server Security
- Web/Web Views
- Mobile Web Testing
- Automating Hybrid Apps
- Using ios-webkit-debug-proxy
- Using Chromedriver
- Image Comparison
- iOS
- Low-Level Insights on iOS Input Events
- XCUITest Mobile Gestures
- XCUITest Mobile App Management
- iOS Pasteboard Guide
- iOS Predicate Guide
- iOS Touch ID Guide
- iOS Install Certificate
- tvOS support
- Pushing/Pulling files
- Audio Capture
- Android
- Low-Level Insights on Android Input Events
- UiSelector Guide
- Espresso Datamatcher Guide
- Android Code Coverage Guide
- Activities Startup Troubleshooting Guide
- How To Execute Shell Commands On The Remote Device
- Android Device Screen Streaming
- How To Emulate IME Actions Generation
- How To Test Android App Bundle
- Other
- Reset Strategies
- Network Connection Guide
- Using Unicode with Appium
- Troubleshooting
- Tutorial
- Swipe Tutorial
- Screen
- Element
- Partial screen
- Simple
- Multiple scroll views
- Add scroll layout
- Tricks and Tips
- Screen
- Element
- Element search
- Fast
- Slow
- Guide
- 進階概念
- 定位圖像中的元素
- 使用定位元素的插件
- 遷移到 XCUITest
- 在 Appium 中使用 Selenium Grid
- Appium Logs Filtering
- 跨域 iframes
- 使用自定義 WDA 服務器
- 使用不同版本的 Xcode 運行
- The Event Timings API
- 并行測試的設置
- The Settings API
- Memory Collection
- 向Appium項目做貢獻
- 從源代碼運行 Appium
- 開發者概述
- 標準開發命令
- Appium 風格指南
- 如何編寫文檔
- Appium 包結構
- 鳴謝