appium安装

2017-03-17  本文已影响583人  Jackson_Z

研究好久ios10的真机测试今天算是成功了。原文地址

运行Python脚本

python hp_b.py

1.有一个MAC机器,或者虚拟机,能够联网,要求Xcode8+ MAC系统10.11+(我用的是Xcode8.2 , MAC系统10.12)有一个Apple ID账号
2.安装brew

$ usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

3.安装libimobiledevice

$ brew install libimobiledevice --HEAD 

4.安装carthage

$ brew install carthage

5.安装node(目的是安装npm)按照官方的地址https://nodejs.org/en/download/。 下载.pkg文件安装
6.安装cnpm(由于某种原因,直接用npm下载安装会有好多网络问题,安装淘宝的cnpm要比npm好用) https://npm.taobao.org/

$ npm install -g cnpm --registry=https://registry.npm.taobao.org

7.安装ios-deploy

$ cnpm install -g ios-deploy

8.安装xcpretty

$ gem install xcpretty

9.安装appium1.6.3(到发帖为止,最新版本是1.6.3,要其他版本的跟上版本号就行了)这一步骤若出现安装jDK弹出框忽略就好

$ cnpm install -g appium@1.6.3

以上安装不要在root用户下安装。若出现权限问题,进入root用户将文件权限更改下。然后退出root用户继续安装即可

$ chmod -R 777 pathForFile

重点

10.安装appium-xcuitest-driver依赖 进入WebDriverAgent安装目录。运行bootstrap

$ cd  /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent

(如果WebDriverAgent 所在路径和此不同,请自行查找)

$ mkdir -p Resources/WebDriverAgent.bundle
$ sh ./Scripts/bootstrap.sh -d

在运行sh ./Scripts/bootstrap.sh -d很可能会有因为某种原因而网络连接失败。方法就是去App store下载了一个VPN代理软件。

11.用Xcode打开WebDriverAgent,并且编译,进入WebDriverAgent 文件夹

双击WebDriverAgent.xcodeproj打开此项目,这个项目由facebook开源在这里我们的目的就是更改一些配置,让他能够编译成功

编译WebDriverAgentLib
编译WebDriverAgentLib
编译WebDriverAgentRunner
编译WebDriverAgentRunner 编译WebDriverAgentRunner

关于为什么要设置Deployment Target,苹果官方宣称XCUItest支持9.3.4以上。但实际经过我测试9.0以上是没问题的,但是如果不调低最小安装的ios版本,会面临着WebDriverAgentRunner无法安装到ios9.0的手机上去的,所以无法测试ios9。

若果编译的过程中有语法错误,应该是10步没有安装好

12.建立服务WebDriverAgent (手机和MAC都在同一个网段下,且都能连接外网)关闭Xcode,进入WebDriverAgent 文件夹

$ cd  /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
$ xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=真机的udid' test

运行到最后会发现


而iphone多了一个WebDriverAgentRunner的app。手动启动那个app的时候


原因是我们手机并并没有信任这个apple id的开发者,到设置-通用-设备管理(描述文件) 信任你的apple id就可以了。再次运行上述命令,看到如下图,就成功了,

13.运行appium

appium
```
14.安装 Selenium WebDriver
因为是Python版,所以就去[Selenium官网下载](https://pypi.python.org/pypi/selenium)Python的WebDriver(selenium-2.39.0.tar.gz)



解压:
```
$ gzip -dc selenium-2.39.0.tar.gz | tar xvf -
```
安装:
```
$ cd selenium-2.39.0
$ sudo python setup.py install  
```
这样,WebDriver就安装成功了。


##### 如果手机没有安装app时
```
app = '/WorkSpace/SRC/CreditProject/build/Release-iphoneos/CreditProject.app'
        self.driver = webdriver.Remote(
                command_executor='http://10.2.129.241:4723/wd/hub',
                desired_capabilities={
                    'deviceName':'',
                    'platformName': 'iOS',
                   #'bundleId':'com.ctcf.CreditProject',
                    'app':app,
                    'udid':'c6a91a858c33b5e00601d9aa5348302dbeadf8e5'
                })
```
如果手机已经安装app时
```
        self.driver = webdriver.Remote(
                command_executor='http://10.2.129.241:4723/wd/hub',
                desired_capabilities={
                    'deviceName':'',
                    'platformName': 'iOS',
                    'bundleId':'com.ctcf.CreditProject',
                    'udid':'c6a91a858c33b5e00601d9aa5348302dbeadf8e5'
                })
```

[Appium 用源码安装 appium](https://testerhome.com/topics/5874)
[Appium-安装](http://www.jianshu.com/p/b043043ee119)
[配置appium 1.6.3 for MAC](http://www.cnblogs.com/lynnhq/p/6187021.html)
[Appium 在 MAC 上搭建 appium1.6.3 过程](http://blog.csdn.net/wuxuehong0306/article/details/54377957)
[1.6.4DMG下载](https://github.com/appium/appium-desktop/releases/tag/v1.0.0-beta.4)
[1.6.4源码](https://github.com/appium/appium-desktop)
[Appium探索——Mac OS Python版](http://www.cnblogs.com/enjoytesting/p/3513637.html)
[]()
上一篇 下一篇

猜你喜欢

热点阅读