Appium+RF测试框架在Mac平台上IOS真机自动化测试环境的搭建

1.打开当前目录下的WebDriverAgent.xcodeproj文件(工程文件在第1步的目录下)

# build时需要指定一个Development team,可以用个人Apple ID账号,生成个人证书和team(在Xcode->Preferences->Account中配置)

2. PROJECT->WebDriverAgent、TARGETS->WebDriverAgentLib和WebDriverAgentRunner的Signing使用个人的证书和Team

3. TARGETS->WebDriverAgentLib和WebDriverAgentRunner的Product Bundle Identifier使用一个新名字,因为Bundle ID不能重复

4. 点击Product->Build,将工程文件编译一下

5. 然后手机上信任证书

还是在WebDriverAgent目录下,执行下面的命令来测试一下是否生效了

xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=你的udid' test

如果没有报错证明安装成功,同时手机上会安装一个WebDriverAgent软件

说明:如果编译WebDriverAgent时使用了自己的证书,需要再手机设置->通用里信任一下证书

六,开始测试

1. 终端启动Appium

appium -U 设备Udid --app buildId

#示例appium -U c2017160c746f96861946bc28feccadbc86a09d8 --app com.shunwang.appdemo

1. 终端启动robot Freamwork

** Settings **

Library AppiumLibrary

** Variables **

$

Unknown macro: {REMOTE_URL}

http://192.168.173.24:4723/wd/hub

$

Unknown macro: {PLATFORM_NAME}

iOS

$

Unknown macro: {PLATFORM_VERSION}

10.3

$

Unknown macro: {DEVICE_NAME}

iPhone6

$

Unknown macro: {APP}

com.shunwang.appdemo

** Keywords **

OpenApplication remote_url=$

platformName=$

Unknown macro: {PLATFORM_NAME}

platformVersion=$

Unknown macro: {PLATFORM_VERSION}

deviceName=$

Unknown macro: {DEVICE_NAME}

app=$

Unknown macro: {APP}

Click Element xpath=//UIAApplication[1]/UIAWindow[1]/UIAButton[1]

Short Sleep

Close All Applications

七,安装环境过程中遇到的一些问题

1.

[Xcode] 2017-08-31 09:23:07.056 xcodebuild[974:31523] Error Domain=NSCocoaErrorDomain Code=260 \“WebDriverAgentRunner-Runner.app” couldn’t be opened because there is no such file.\ibrary/Developer/Xcode/DerivedData/WebDriverAgent-ckpasrwhosmhymbuuzzlflsqpfhz/Build/Products/Debug-iphoneos/WebDriverAgentRunner-Runner.app, NSUnderlyingError=0x7f9329dda2a0 {Error Domain=NSPOSIXErrorDomain Code=2 \No such file or directory\

解决方案:

首先确定下WebDriverAgentRunner在xcode上是否编译成功,如果编译成功了,则在mac上搜索编译成功的WebDriverAgentRunner-Runner.app文件,把它拷贝到报错信息中的路径下,然后重新执行用例

2. 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 \capability instead.

解决方案:

在--capability添加automationName=XCUITest参数

3. 2017-09-04 16:06:51.511 xcodebuild[2143:177994] Error

Domain=com.apple.platform.iphoneos Code=-12 \com.apple.test.WebDriverAgentRunner-Runner\UserInfo={NSLocalizedDescription=Unable to launch

com.apple.test.WebDriverAgentRunner-Runner, NSUnderlyingError=0x7fe93aa074e0 {Error Domain=DTXMessage Code=1 \

Unknown macro: {DTXExceptionKey=The operation couldn’t be completed. Unable to launch com.apple.test.WebDriverAgentRunner-Runner because it has an invalid code signature, inadequate entitlements or its profile has not been explicitly trusted by the user. }

}}

解决方案:

打开ios手机,在设置>通用>设备管理中将开发者账号添加为可信任设备

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4