溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

appium自動(dòng)化測(cè)試搭建

發(fā)布時(shí)間:2020-06-25 01:52:25 來(lái)源:網(wǎng)絡(luò) 閱讀:6900 作者:lovely_1133 欄目:移動(dòng)開(kāi)發(fā)

appium的環(huán)境搭建,網(wǎng)上的確一大堆不過(guò)都是比較老的版本安裝,目前我做的都是用命令下載安裝最新的,安裝前的準(zhǔn)備工作,首先你的有個(gè)mac~哈哈好了不啰嗦進(jìn)入正題;
系統(tǒng)環(huán)境 電腦系統(tǒng)版本:10.13.4;xcoke版本Version 9.3.1 ;(只適合電腦中有一個(gè)xcoke版本的)

安裝Homebrew

強(qiáng)烈推薦所有macOS上的軟件使用Homebrew進(jìn)行安裝,使用brew安裝過(guò)的軟件,不再需要sudo命令。
打開(kāi)終端,運(yùn)行:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

使用命令 :brew -v 如果輸出:
Homebrew 1.6.3
Homebrew/homebrew-core (git revision 3069d; last commit 2018-05-14)

表示安裝成功;

檢查是否有安裝過(guò)git
輸出命令git --version;
#git version 2.15.1 (Apple Git-101)
表示已安裝未安裝執(zhí)行brew install git命令

java安裝
去/Library/Java/JavaVirtualMachines/目錄下看是否安裝過(guò)java版本1.8以上包含;
有就執(zhí)行
java -version看環(huán)境是否配置
輸出版本號(hào)就配置了沒(méi)有就執(zhí)行

  1. 進(jìn)入當(dāng)前用戶的home目錄
    輸入cd ~
  2. 創(chuàng)建.bash_profile
    輸入touch .bash_profile
  3. 編輯.bash_profile文件
    輸入vi ~/.bash_profile
    添加
    JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home
    PATH=$JAVA_HOME/bin:$PATH:
    export JAVA_HOME
    export PATH
    4.source .bash_profile 后輸入java -version提示版本號(hào)就配置成功
    java未安裝
    java下載地址http://www.oracle.com/technetwork/java/javase/downloads/index.html
    自行下載安裝然后按java安裝執(zhí)行

安裝Nodejs
使用命令:brew install node
安裝完成后輸入命令:node -v
#v10.1.0
npm -v
#5.6.0
表示成功;
如果你能×××那么安裝cnpm就可以忽略后面用cnpm的命令你直接使用npm
由于npm源在國(guó)外,我們使用npm安裝庫(kù)時(shí)會(huì)比較慢,可以使用taobao的鏡像源
npm install -g cnpm --registry=https://registry.npm.taobao.org

檢查安裝是否成功
輸入命令:cnpm -v
#5.3.0

安裝python

brew install python3

檢測(cè)安裝成功

python3 -V
#Python 3.6.2

pip3 -V
#pip 9.0.1 from /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (python 3.6)

測(cè)試Android App需要。
下載地址:https://developer.android.com/studio/index.html#downloads
建議選擇Android Studio下載,借助studio來(lái)安裝SDK。和安裝其他Mac OS程序一樣進(jìn)行安裝就行。
安裝完成之后,打開(kāi)Android Studio,這時(shí)可能會(huì)提示 unable to access android sdk add-on list。這個(gè)意思是提示我們電腦上沒(méi)有安裝SDK,沒(méi)關(guān)系,點(diǎn)擊Cancel,在后續(xù)的界面安裝SDK就好了。
安裝 Android SDK Tools 和 Android SDK Platform-tools ,進(jìn)入Preference——Appearance&Behavior——System Settings——Android SDK。

appium自動(dòng)化測(cè)試搭建

可以在這里下載和更新 Android SDK Tools 和 Android SDK Platform-tools 。保持默認(rèn)的選項(xiàng)即可如果有需要可以和公司工程師溝通看公司項(xiàng)目支持的sdk版本,點(diǎn)擊Install 23 packages
appium自動(dòng)化測(cè)試搭建

Accept License。然后Install 大概30分鐘就能ok
配置android sdk環(huán)境變量
vi ~/.bash_profile
添加
export ANDROID_HOME=/Users/wangchao/Library/Android/sdk
export PATH=${PATH}:/Users/wangchao/Library/Android/sdk/platform-tools
export PATH=${PATH}:/Users/wangchao/Library/Android/sdk/tools
source .bash_profile
命令行輸入adb version
Android Debug Bridge version 1.0.39
Version 0.0.1-4500957
Installed as /Users/wangchao/Library/Android/sdk/platform-tools/adb

配置成功

安裝 appium server
在終端輸入cnpm install -g appium
安裝過(guò)程比較慢安裝完成后
安裝appium client
cnpm install wd
安裝carthage
brew install carthage
安裝appium doctor用來(lái)檢測(cè)appium的是否成功安裝
在終端執(zhí)行npm install appium-doctor -g來(lái)安裝doctor。
安裝完成后,終端輸入appium-doctor 檢測(cè)環(huán)境是否成功。
$ appium-doctor
info AppiumDoctor Appium Doctor v.1.4.3
info AppiumDoctor ### Diagnostic starting ###
info AppiumDoctor ? The Node.js binary was found at: /usr/local/bin/node
info AppiumDoctor ? Node version is 10.1.0
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 ? Carthage was found at: /usr/local/bin/carthage
info AppiumDoctor ? HOME is set to: /Users/wangchao
info AppiumDoctor ? ANDROID_HOME is set to: /Users/wangchao/Library/Android/sdk
info AppiumDoctor ? JAVA_HOME is set to: /Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home
info AppiumDoctor ? adb exists at: /Users/wangchao/Library/Android/sdk/platform-tools/adb
info AppiumDoctor ? android exists at: /Users/wangchao/Library/Android/sdk/tools/android
info AppiumDoctor ? emulator exists at: /Users/wangchao/Library/Android/sdk/tools/emulator
info AppiumDoctor ? Bin directory of $JAVA_HOME is set
info AppiumDoctor ### Diagnostic completed, no fix needed. ###
info AppiumDoctor
info AppiumDoctor Everything looks good, bye!
info AppiumDoctor
表示成功

安裝appium-desktop
網(wǎng)站http://appium.io
我下載版本是Appium-1.6.1

安裝后在電腦應(yīng)用程序中找到appium點(diǎn)擊打開(kāi)
看到這個(gè)頁(yè)面
appium自動(dòng)化測(cè)試搭建
用android sdk創(chuàng)建模擬器;不會(huì)的自行百度;使用真機(jī)最好;
獲取設(shè)備名字列表:adb devices
獲取系統(tǒng)版本:adb shell getprop ro.build.version.release
修改host 添加127.0.0.1 localhost不是會(huì)出現(xiàn)服務(wù)器啟動(dòng)后連接不上
打開(kāi)如圖界面修改Server Address為127.0.0.1
appium自動(dòng)化測(cè)試搭建

點(diǎn)擊start service v1.8.0
看到一下圖表示啟動(dòng)成功
appium自動(dòng)化測(cè)試搭建

點(diǎn)擊圖片紅圈里面的按鈕
appium自動(dòng)化測(cè)試搭建
然后出現(xiàn)一下頁(yè)面

appium自動(dòng)化測(cè)試搭建

再根據(jù)我給的圖片配置相關(guān)參數(shù),根據(jù)自己情況修改platformVersion(系統(tǒng)版本號(hào)),deviceName(設(shè)備名字),appPackage(包名),appActivity(啟動(dòng)頁(yè)面),app(apk包在電腦的位置)點(diǎn)擊紅圈標(biāo)注的start session按鈕
appium自動(dòng)化測(cè)試搭建

出現(xiàn)一下頁(yè)面配置成功
appium自動(dòng)化測(cè)試搭建

ios需要設(shè)置
使用XCUITest設(shè)置iOS真實(shí)設(shè)備測(cè)試
必要的安裝軟件
目前在真實(shí)設(shè)備上運(yùn)行iOS測(cè)試需要兩個(gè)軟件:

  1. sudo gem install xcpretty
  2. brew uninstall ideviceinstaller
    brew uninstall libimobiledevice
    brew install --HEAD libimobiledevice
    brew link --overwrite libimobiledevice
    brew install ideviceinstaller
    brew link --overwrite ideviceinstaller
    3.ios-deploy - 使用安裝 npm install -g ios-deploy
    出現(xiàn)如圖錯(cuò)誤是xcodebuild找不到Xcode,所以我們要重定向一下Xcode的文檔的位置。執(zhí)行命令:sudo xcode-select --switch/Applications/Xcode.app/Contents/Developer/
    appium自動(dòng)化測(cè)試搭建

4.WebDriverAgent
該目錄下/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent這個(gè)最好不要使用;
找個(gè)常用的位置創(chuàng)建文件WDA
在用git下載;
git clone https://github.com/facebook/WebDriverAgent
下載完成
進(jìn)入目錄WebDriverAgent執(zhí)行以下命令
./Scripts/bootstrap.sh

然后找到選中WebDriverAgent.xcodeproj 文件,用xcode打開(kāi),并做如圖設(shè)置。
說(shuō)明下: 這里需要設(shè)置證書(shū),沒(méi)有的話,咨詢iOS 開(kāi)發(fā)人員
appium自動(dòng)化測(cè)試搭建
appium自動(dòng)化測(cè)試搭建
運(yùn)行與測(cè)試

1.菜單欄選擇目標(biāo)設(shè)備
appium自動(dòng)化測(cè)試搭建

2.Scheme選擇WebDriverAgentRunner
appium自動(dòng)化測(cè)試搭建

3.最后運(yùn)行 Product -> Test
一切正常的話,手機(jī)上會(huì)出現(xiàn)一個(gè)無(wú)圖標(biāo)的WebDriverAgent應(yīng)用,啟動(dòng)之后,馬上又返回到桌面。這是很正常的不要奇怪
剩下的后面和安裝啟動(dòng)appium桌面應(yīng)用后面步驟相同就是配置上多了2項(xiàng)如圖appium自動(dòng)化測(cè)試搭建

xcodeOrgId 就是Team ID ;它在 https://github.com/developer.apple.com/account 中的Membership中

如果有任何疑問(wèn)可以發(fā)郵件問(wèn)我;郵件chao.wang@niu.com

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI