Appium自動化測試-iOS

Appium的哲學

咱們相信,對原生應用的自動化測試,應當沒必要要包含其餘的SDK組件或者特別編譯您的App,而且應當能夠選擇任何您喜歡的測試方法,框架和工具。基於這些出發點咱們開發了Appium。如今Appium是一個開源項目,經過一系列設計和工具抉擇,鼓勵廣大開發者爲社區提供多種多樣的貢獻。java

Appium的結構

Appium Server

就是咱們經過Appium.app/Appium.exe啓動的服務,或者命令行執行appium啓動的服務。node

Appium client

每一個語言下的Appium庫,例如java的io.appium.java-client庫,python的Appium-Python-Client庫等等。python

Appium.app Appium.exe

以客戶端的方式執行appium的工具,appium被打包在可視化的應用內部。能夠用來查找元素,還有錄製腳本,可是不推薦使用客戶端錄製腳本。android

官方示例

> brew install node      # get node.js
> npm install -g appium  # get appium
> npm install wd         # get appium client
> appium &               # start appium
> node your-appium-test.js

Appium的iOS環境配置

環境準備

  • Mac電腦
  • iOS設備
  • nodejs環境
  • xcode
  • iphone sdk

安裝appium

  • 安裝nodejs:brew install node
  • 安裝appium:npm install -g appium
  • 安裝Appium.app

環境檢查

安裝appium-doctor命令:npm install -g appium-doctor,用來檢查appium的環境配置。ios

info AppiumDoctor ### Diagnostic starting ###
info AppiumDoctor  ✔ Xcode is installed at: /Applications/Xcode.app/Contents/Developer
info AppiumDoctor  ✔ Xcode Command Line Tools are installed.
info AppiumDoctor  ✔ DevToolsSecurity is enabled.
info AppiumDoctor  ✔ The Authorization DB is set up properly.
info AppiumDoctor  ✔ The Node.js binary was found at: /usr/local/bin/node
info AppiumDoctor  ✔ HOME is set to: /Users/user
info AppiumDoctor  ✔ ANDROID_HOME is set to: /Users/user/Library/Android/sdk
info AppiumDoctor  ✔ JAVA_HOME is set to: /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home
info AppiumDoctor  ✔ adb exists at: /Users/user/Library/Android/sdk/platform-tools/adb
info AppiumDoctor  ✔ android exists at: /Users/user/Library/Android/sdk/tools/android
info AppiumDoctor  ✔ emulator exists at: /Users/user/Library/Android/sdk/tools/emulator
info AppiumDoctor ### Diagnostic completed, no fix needed. ###
info AppiumDoctor
info AppiumDoctor Everything looks good, bye!
info AppiumDoctor

安裝appium client

java的appium client配置:npm

<dependency>
    <groupId>io.appium</groupId>
    <artifactId>java-client</artifactId>
    <version>3.4.1</version>
</dependency>

python安裝:pip install Appium-Python-Clientxcode

iOS控件定位

使用appium的inspect工具定位控件元素。須要先獲取手機的udid,能夠經過itunes和ideviceinfo命令行查找。
app

相關文章
相關標籤/搜索