Appium 官网:appium.io/docs/en/abo…
下载 Appium: github.com/appium/appi…
iOS 配置
1、需要安装 brew node 和 npm,
brew mac 自带, node 官网下载:nodejs.org/en/download…
2、安装 Carthage
bash brew install carthage
如果只是模拟器的话,到此结束。
iOS 真机配置
一、安装 libimobiledevice
brew install libimobiledevice
但是这个命令报错不断
1、没权限
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
2、xcode commandlinetool
Error: Xcode alone is not sufficient on High Sierra.
Install the Command Line Tools:
xcode-select --install
按照提示改
3、/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/
4、/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/
5、没有 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/…
三、 启动 Appium Desktop
启动 AppiumDesktop,用默认设置就好,之后在启动 server。
配置Desired Capabilities
例如:
{
"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开始会话。