安装 Appium

Appium 官网:appium.io/docs/en/abo…html

下载 Appium: github.com/appium/appi…node

iOS 配置

appium.io/docs/en/dri…python

一、须要安装 brew node 和 npm,ios

brew mac 自带, node 官网下载:nodejs.org/en/download…git

二、安装 Carthagegithub

bash brew install carthage
复制代码

若是只是模拟器的话,到此结束。sql

iOS 真机配置

真机配置:appium.io/docs/en/dri…npm

1、安装 libimobiledevice

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 :(
复制代码

解决办法:

autoconf下载源码包

./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,终于成功了。

2、安装 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/…

3、 启动 Appium Desktop

启动 AppiumDesktop,用默认设置就好,以后在启动 server。

配置Desired Capabilities

能够参考:github.com/appium/appi…

例如:

{
  "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开始会话。

相关文章
相关标签/搜索