Appium 官網:appium.io/docs/en/abo…html
下載 Appium: github.com/appium/appi…node
appium.io/docs/en/dri…python
一、須要安裝 brew node 和 npm,ios
brew mac 自帶, node 官網下載:nodejs.org/en/download…git
二、安裝 Carthage
github
bash brew install carthage
複製代碼
若是隻是模擬器的話,到此結束。sql
真機配置:appium.io/docs/en/dri…npm
brew install libimobiledevice
複製代碼
可是這個命令報錯不斷json
一、沒權限xcode
brew install libimobiledevice --HEAD
Updating Homebrew...
Error: The following directories are not writable by your user:
/usr/local/share/man/man3
/usr/local/share/man/man5
/usr/local/share/man/man7
You should change the ownership of these directories to your user.
sudo chown -R $(whoami) /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7
ddxqdeMac-mini:~ ddxq$ sudo brew update
複製代碼
改完以後
Error: The following directories are not writable by your user:
/usr/local/include
/usr/local/lib
You should change the ownership of these directories to your user.
sudo chown -R $(whoami) /usr/local/include /usr/local/lib
複製代碼
二、xcode commandlinetool
Error: Xcode alone is not sufficient on High Sierra.
Install the Command Line Tools:
xcode-select --install
複製代碼
按照提示改
三、/usr/local/Cellar
權限
Error: An exception occurred within a child process:
Errno::EPERM: Operation not permitted @ dir_s_mkdir - /usr/local/Cellar
複製代碼
這個目錄壓根就不存在,只能本身建立,並改權限
sudo mkdir /usr/local/Cellar
sudo chown -R $(whoami) /usr/local/Cellar/
複製代碼
四、/usr/local/opt
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink .
/usr/local/opt is not writable.
You can try again using:
brew link autoconf
複製代碼
/usr/local/opt
目錄也是不存在,再建立一下:
sudo mkdir /usr/local/opt
sudo chown -R $(whoami) /usr/local/opt/
複製代碼
五、沒有 autoconf
Error: An exception occurred within a child process:
RuntimeError: /usr/local/opt/autoconf not present or broken
Please reinstall autoconf. Sorry :(
複製代碼
解決辦法:
./configure
make && make install
複製代碼
從新安裝以後,仍然報這個錯,沒辦法,把前面報錯的 brew link
所有從新執行一遍,而後依然報錯,最後用
brew install libimobiledevice
複製代碼
安裝成功。
累計的 brew link
有:
534 brew link autoconf
535 brew link --overwrite autoconf
536 brew install libimobiledevice --HEAD
537 brew link --overwrite autoconfbrew link automake
538 brew link automake
539 brew link libtool
540 brew link gdbm
541 brew link python@2
542 sudo mkdir /usr/local/Frameworks
543 sudo chown -R $(whoami) /usr/local/Frameworks
544 brew link python@2
545 brew link pkg-config
546 brew link libplist
547 brew link libtasn1
548 brew link libusb
549 brew link usbmuxd
複製代碼
中間執行 brew link python@2
還報了 /usr/local/Frameworks
不存在,又創建這個目錄。
以後啓動 Appium desktop 的時候,開啓 session,發現報錯
Command 'idevice_id -l' exited with code null
複製代碼
想到或許是 libimobiledevice
沒有安裝好的緣由。因而從新安裝 libimobiledevice
,此次又報錯:
brew install libimobiledevice --HEAD
Error: An exception occurred within a child process:
RuntimeError: /usr/local/opt/openssl not present or broken
Please reinstall openssl. Sorry :(
複製代碼
從新安裝 openssl,報:
brew install openssl
Warning: openssl 1.0.2q is already installed, it's just not linked You can use `brew link openssl` to link this version. 複製代碼
執行 brew link openssl
報:
Warning: Refusing to link macOS-provided software: openssl
If you need to have openssl first in your PATH run:
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
For compilers to find openssl you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
For pkg-config to find openssl you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"
複製代碼
網上說法大部分都是 要連接 openssl,如:
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
複製代碼
這個執行完畢後,發現依然報錯,後來發現/usr/local/opt
目錄下面壓根就沒有openssl
。 沒辦法執行 brew reinstall openssl
,從新安裝。安裝完成後繼續執行 brew install libimobiledevice --HEAD
,依然報
Error: An exception occurred within a child process:
RuntimeError: /usr/local/opt/readline not present or broken
Please reinstall readline. Sorry :(
複製代碼
不過好得 /usr/local/opt
目錄下面有了openssl
了,終因而個好消息。因而從新執行 連接:
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
複製代碼
結果倒是:
ln: /usr/local/lib//libcrypto.1.0.0.dylib: File exists
複製代碼
執行:brew link --force openssl
,仍是報錯:
Warning: Refusing to link macOS-provided software: openssl
If you need to have openssl first in your PATH run:
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
For compilers to find openssl you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
For pkg-config to find openssl you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"
複製代碼
最後沒辦法,安裝提示試試吧,執行
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
brew install libimobiledevice --HEAD
複製代碼
又是報錯:
Error: An exception occurred within a child process:
RuntimeError: /usr/local/opt/readline not present or broken
Please reinstall readline. Sorry :(
複製代碼
雖然報錯,可是說明把 openssl 的問題解決了,那麼依葫蘆畫瓢,在來解決readline
.
brew link --force readline
複製代碼
後面執行一次brew install libimobiledevice --HEAD
報錯的有:
Error: An exception occurred within a child process:
RuntimeError: /usr/local/opt/sqlite not present or broken
Please reinstall sqlite. Sorry :(
Error: An exception occurred within a child process:
RuntimeError: /usr/local/opt/libxml2 not present or broken
Please reinstall libxml2. Sorry :(
複製代碼
這兩個錯誤和 openssl 同樣,也是須要reinstall
,以後執行echo 'export PATH="/usr/local/opt/libxml2/bin:$PATH"' >> ~/.bash_profile
最後一次執行 brew install libimobiledevice --HEAD
報:
hecking for libusbmuxd >= 1.1.0... no
configure: error: Package requirements (libusbmuxd >= 1.1.0) were not met:
Requested 'libusbmuxd >= 1.1.0' but version of libusbmuxd is 1.0.10
複製代碼
參考:www.jianshu.com/p/1ec36db7d…
brew update
brew uninstall --ignore-dependencies libimobiledevice
brew uninstall --ignore-dependencies usbmuxd
brew install --HEAD usbmuxd
brew unlink usbmuxd
brew link usbmuxd
brew install --HEAD libimobiledevice
複製代碼
完了以後從新執行 brew install libimobiledevice --HEAD
,終於成功了。
WebDriverAgent
須要改 bundleIdentifier,安裝到手機是,安裝是執行 test 的 target,或者 Command + U
快捷鍵。執行完後在console 上也確實輸出了server的 ip 地址,其實就是 手機的 ip 地址,
WebDriverAgentRunner-Runner[331:18887] ServerURLHere->http://10.192.228.18:8100<-ServerURLHere
複製代碼
根據網上教程,在瀏覽器輸入 http://10.192.228.18:8100/status
,可是訪問不了,後來在網上找到須要作端口映射
iproxy 8100 8100
複製代碼
執行完,終端會顯示 waiting for connection
,這時候在瀏覽器裏輸入http://localhost:8100/status
,能夠看到輸出的 json。
參考這裏:www.cnblogs.com/xiyuan2016/…
啓動 AppiumDesktop,用默認設置就好,以後在啓動 server。
例如:
{
"automationName": "appium",
"platformName": "iOS",
"platformVersion": "12.0",
"app": "/Users/Shared/Jenkins/Home/workspace/***.ipa",
"deviceName": "iPhone",
"udid": "d8cf9de0ee74526c9f14e7a0a74a027217644346",
"xcodeOrgId": "4J5FV4S6P3",
"xcodeSigningId": "WildcardAppIDProfile",
"bundleId": "com.******"
}
複製代碼
最後點擊Start Session開始會話。