android和ios测试环境搭建,iOS自动化测试环境搭建

macOS相关库安装

* libimobiledevice

brew install libimobiledevice

使用本机与iOS设备的服务进行通信的库。

* ideviceinstaller

brew install ideviceinstaller

获取设备uuid、安装app、卸载app、获取bundleid。

* carthage

brew install carthage

第三方库管理工具。

* ios-deploy

brew install ios-deploy

ios-deploy不依赖于xcode进行安装和调试iOS应用程序。

* node & npm

brew install node

brew install npm

* appium-doctor

npm install -g appium-doctor

* 验证appium环境

> appium-doctor

info AppiumDoctor Appium Doctor v.1.16.0

info AppiumDoctor ### Diagnostic for necessary dependencies starting ###

info AppiumDoctor ✔ The Node.js binary was found at: /usr/local/bin/node

info AppiumDoctor ✔ Node version is 15.5.1

info AppiumDoctor ✔ Xcode is installed at: /Applications/Xcode.app/Contents/Developer

info AppiumDoctor ✔ Xcode Command Line Tools are installed in: /Applications/Xcode.app/Contents/Developer

info AppiumDoctor ✔ DevToolsSecurity is enabled.

info AppiumDoctor ✔ The Authorization DB is set up properly.

info AppiumDoctor ✔ Carthage was found at: /usr/local/bin/carthage. Installed version is: 0.36.0

info AppiumDoctor ✔ HOME is set to: /Users/sven

WARN AppiumDoctor ✖ ANDROID_HOME environment variable is NOT set!

WARN AppiumDoctor ✖ JAVA_HOME environment variable is NOT set!

WARN AppiumDoctor ✖ adb, android, emulator could not be found because ANDROID_HOME or ANDROID_SDK_ROOT is NOT set!

WARN AppiumDoctor ✖ Cannot check $JAVA_HOME requirements since the environment variable itself is not set

info AppiumDoctor ### Diagnostic for necessary dependencies completed, 4 fixes needed. ###

info AppiumDoctor

info AppiumDoctor ### Diagnostic for optional dependencies starting ###

WARN AppiumDoctor ✖ opencv4nodejs cannot be found.

info AppiumDoctor ✔ ffmpeg is installed at: /usr/local/bin/ffmpeg. ffmpeg version N-100459-ga7f9b3b954 Copyright (c) 2000-2020 the FFmpeg developers

WARN AppiumDoctor ✖ mjpeg-consumer cannot be found.

WARN AppiumDoctor ✖ set-simulator-location is not installed

WARN AppiumDoctor ✖ idb and idb_companion are not installed

WARN AppiumDoctor ✖ applesimutils cannot be found

info AppiumDoctor ✔ ios-deploy is installed at: /usr/local/bin/ios-deploy. Installed version is: 1.11.3

WARN AppiumDoctor ✖ bundletool.jar cannot be found

WARN AppiumDoctor ✖ gst-launch-1.0 and/or gst-inspect-1.0 cannot be found

info AppiumDoctor ### Diagnostic for optional dependencies completed, 7 fixes possible. ###

info AppiumDoctor

info AppiumDoctor ### Manual Fixes Needed ###

info AppiumDoctor The configuration cannot be automatically fixed, please do the following first:

WARN AppiumDoctor ➜ Make sure the environment variable ANDROID_HOME is properly configured for the Appium process. Refer https://github.com/appium/java-client/blob/master/docs/environment.md for more details.

WARN AppiumDoctor ➜ Make sure the environment variable JAVA_HOME is properly configured for the Appium process. Refer https://github.com/appium/java-client/blob/master/docs/environment.md for more details.

WARN AppiumDoctor ➜ Manually configure ANDROID_HOME and run appium-doctor again.

WARN AppiumDoctor ➜ Set $JAVA_HOME environment variable to the root folder path of your local JDK installation

info AppiumDoctor

info AppiumDoctor ### Optional Manual Fixes ###

info AppiumDoctor The configuration can install optionally. Please do the following manually:

WARN AppiumDoctor ➜ Why opencv4nodejs is needed and how to install it: https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/image-comparison.md

WARN AppiumDoctor ➜ mjpeg-consumer module is required to use MJPEG-over-HTTP features. Please install it with 'npm i -g mjpeg-consumer'.

WARN AppiumDoctor ➜ set-simulator-location is needed to set location for Simulator. Please read https://github.com/lyft/set-simulator-location to install it

WARN AppiumDoctor ➜ Why idb is needed and how to install it: https://github.com/appium/appium-idb

WARN AppiumDoctor ➜ Why applesimutils is needed and how to install it: http://appium.io/docs/en/drivers/ios-xcuitest/

WARN AppiumDoctor ➜ bundletool.jar is used to handle Android App Bundle. Please read http://appium.io/docs/en/writing-running-appium/android/android-appbundle/ to install it

WARN AppiumDoctor ➜ gst-launch-1.0 and gst-inspect-1.0 are used to stream the screen of the device under test. Please read https://appium.io/docs/en/writing-running-appium/android/android-screen-streaming/ to install them and for more details

info AppiumDoctor

info AppiumDoctor ###

info AppiumDoctor

info AppiumDoctor Bye! Run appium-doctor again when all manual fixes have been applied!

info AppiumDoctor

xcode

xcode是iOS开发环境,可以到appstore下载安装。

xcode的安装需要macOS升级到最新的版本,如果你的系统不是最新版本需要升级。

webDriverAgent

在模拟器中运行的用于iOS的WebDriver服务器。

https://github.com/appium/WebDriverAgent

该项目由facebook开发,appium拉了个分支来维护,更新上超过了facebook,所以我们用appium的分支。

* 通过git clone将项目克隆下来。

* 进入项目目录执行shell脚本:

../WebDriverAgent> ./Scripts/bootstrap.sh

* 通过xcode导入WebDriverAgent项目

找到build Setting -->packaging --> Product Bundle Identifier 选项,将值修改为唯一识别的字符串。

Build Phases --> Copy frameworks -->检查框架。

*RoutingHTTPServer.framework

*YYCache.framework

如果没有这些框架,点击下方加号+添加。

iPhone

准备一部iPhone手机,通过数据线与PC进行连接。

1、选择连接的手机

2、菜单栏:product --> Scheme --> WebDriverAgentRunner

3、在iPhone手机上打开设置:通用 --> 描述文件与设备管理 --> 开发者App,设置 App Development xxxxxx在此iPhone上受信任。

4、菜单栏: procudt -- > Test

5、检查日志是否有错误。

iproxy

安装usbmuxd,他自带了iproxy小工具,iproxy将设备上的端口映射到电脑上的某个端口。

brew install usbmuxd

iproxy 8100 8100

http://localhost:8100/status

开始测试

可以开始测试了,可以有如下几种选择:

* appium

https://github.com/appium/python-client

* Openatx

https://github.com/openatx/facebook-wda

我选 openatx/fackbook-wda,因为他更加简单。

安装:

pip3 install -U facebook-wda

测试脚本:

import wda

c = wda.Client('http://localhost:8100')

print (c.status())

结果

AttrDict({'message': 'WebDriverAgent is ready to accept commands', 'state': 'success', 'os': {'testmanagerdVersion': 28, 'name': 'iOS', 'sdkVersion': '14.2', 'version': '14.1'}, 'ios': {'ip': '192.168.118.140'}, 'ready': True, 'build': {'time': 'Mar 25 2021 14:22:55', 'productBundleIdentifier': 'com.facebook.WebDriverAgentRunner'}, 'sessionId': None})

好了,到此环境就搭建完毕!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值