搜索
您的当前位置:首页mac下Appium环境配置

mac下Appium环境配置

来源:爱问旅游网
mac下Appium环境配置

⼀、Appium环境搭建

1、xcode(需要OS X版本⽀持):

下载对应版本的xcode(⽀持对应⼿机系统),解压,拖⼊应⽤程序。xcode下载地址:2、安装appium:

安装node、brew、nmp、carthage等:

1)如果有旧版本的appium,需要先卸载旧版本的appium:npm uninstall -g appium2)下载appium1.6.5正式版:,终端进⼊⽂件⽬录,命令⾏安装:npm install。 验证安装成功:终端输⼊“appium -v”,出现版本号表⽰安装成功。

  此处有坑:appium-desktop 1.6.4及以下不⽀持xcode9.0.1,(请注意⾃⼰的xcode版本和appium版本,要不然会报错)3)与系统进⾏关联:npm link

4)安装appium桌⾯程序:,下载zip包,解压,拖⼊应⽤程序。

5)Appium⾃带的WebDriverAgent存在bug,改使⽤FaceBook的WebDriverAgent(WebDriverAgent下载:):

从git上下载WebDriverAgent,进⼊/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent ⽬录,命令⾏运⾏:./Scripts/bootstrap.sh,下载依赖,然后将该⽂件替换appium应⽤中的

WebDriverAgent(⽬录:/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent )

使⽤xcode打开WebDriverAgent程序,在真机上安装WebDriverAgent程序,⼿机上出现WebDriverAgent应⽤表⽰安装成功。(在通⽤-> 描述⽂件⽂件中信任xcode使⽤的开发者证书)参考:   

3、检测appium环境:终端输⼊:appium-doctor4、启动appium桌⾯程序:AppiumDesktop使⽤:

启动Appium。在运⾏⾃动化测试脚本前⼀定要先运⾏Appium,启动测试应⽤。

1)通过下⾯的两种⽅式启动appium服务器。(appium启动会先启动webdriveragent,启动之后不要将webdriverAgent关闭,否则再次启动appium会报错)

⽅式1、通过命令⾏安装的appium可以通过终端启动,终端输⼊:appium,看到终端打印出下⾯⽇志,表⽰服务器启动成功。

⽅式2、已经安装了appium桌⾯程序可以通过启动桌⾯程序来启动appium服务器。打开程序看到如下页⾯:

直接点击Start Server即可启动appium服务器,跟终端命令⾏启动打印出的⽇志⼀样,如下所⽰:

上图三个红⾊框分别表⽰:①查看应⽤元素(inspector)②保存⽇志⽂件③停⽌appium服务器。启动了appium服务器之后。可以直接运⾏⾃动化。)配置⼀些Desired Capabilities信息:

默认会以127.0.0.1ip和4723端⼝启动⼀个session,如果要启动多个session,可以通过修改端⼝号的⽅式:点击Custom Server,服务器ip输⼊127.0.0.1,端⼝输⼊⼀个⽬前未在使⽤的端⼝号就可以了。

⼀般需要填写的参数有platformName(平台)、platformVersion(平台版本)、udid(设备的udid,填错不能启动应⽤)、

deviceName(设备名称)、bundleid(应⽤的bundleid)、automationName(必须填写XCUITest,不写默认是UIAutomation的⽅式,该⽅式不⽀持IOS10)。

要连接iOS真机,必须打开真机的开发者模式。

然后选中要启动的已经配置好的信息,点击Start Session。看到下⾯的画⾯表⽰启动成功,可以查看元素的accessibility_id、xpath、value等和坐标。⽀持录制脚本。

⼆、安装及运⾏过程中遇到的坑坑1、

A new session could not be created. Details: Appium's IosDriver does not support xcode version 8.3.3.Apple has deprecated UIAutomation. Use the \"XCUITest\" automationName capability instead.解决⽅案:

在--capability添加automationName=XCUITest参数

坑2、

AssertionError: Message: An unknown server-side error occurred while processing the command.Original error: Unknown device or simulator UDID: '***'解决⽅案:

Appium使⽤idevice_id(libimobiledevice的⼀部分)来确定设备的可⽤性brew install libimobiledevice --HEAD

坑3、

AssertionError: Message: An unknown server-side error occurred while processing the command. Original error: Could not initialize ios-deploy make sure it is installed (npm install -g ios-deploy) and works on your system解决⽅案:安装ios-deploy

npm install -g ios-deploy

坑5:

appium-desktop 1.6.4及以下不⽀持xcode9.0.1,需要升级appium

坑6:

webdriverAgent安装失败解决⽅案:

重新编译webdriverAgent,参考地址

cd /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgentxcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination'id=3825bba08e5c10c499ddaf0276bac01983ab7119' test

其他⼈发现的坑:

因篇幅问题不能全部显示,请点此查看更多更全内容

Top