Mac搭建IOS自动化测试环境

1. Introduction

This document was created to give a general walkthrough of setting up an automation test environment for WebLab mobile and web applications.

2. Initial setup

2.1. Software prerequisites

IntelliJ IDEA

Java: JDK 1.8

Maven

Android SDK

Node.js

Appium

2.2. Intellij IDEA

Download Intellij IDEA and install, check if it is working properly.

IntelliJ IDEA

Install plugins in Intellij IDEA

Cucumber for Java

2.3. Java: JDK 1.8

2.3.1. Download Java

Download JDK1.8 and install, check if it is working properly.

https://www.oracle.com/java/technologies/downloads/#java8-mac

2.4. Android studio

2.4.1. Download Android studio package from

https://developer.android.com/studio#downloads

http://www.android-studio.org/index.php/download/hisversion

2.4.2 Install studio

2.4.3 Install virtual device

Open studio,click the button

Click the button as below to create Virtual device

Click Finish Button

start virtual device

When virtual device start success, the Android SDK is ready

2.4.4 verify success

command——adb——Return,

adb devices

Check whether a device is connected

3. Appium Install and setup

3.1. Install node.js

Download node.js , check if it is working properly

https://nodejs.org/en/

3.2.Install Appium

Download Appium and install, check if it is working properly.

https://appium.io/downloads.html

4.Mac set environment

4.1 Edit enviroment file .zhsrc

vi ~/.zshrc

4.2 Enviroment content

export ANDROID_HOME=/Users/jeff.xie/Downloads/sdk

export MAVEN_HOME=/Users/jeff.xie/Documents/apache-maven-3.8.4

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_311.jdk/Contents/Home

export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator:$JAVA_HOME/bin:$MAVEN_HOME/bin

export PATH=${PATH}:${ANDROID_HOME}/platform-tools

export PATH=${PATH}:${ANDROID_HOME}/build-tools

export PATH=${PATH}:${ANDROID_HOME}/tools

export PATH=${PATH}:/Users/jeff.xie/Documents/allure-2.17.2/bin

export PATH=${PATH}:/usr/local/lib/node_modules

export PATH=${PATH}:/usr/local/lib/node_modules/appium

export PATH=${PATH}:/usr/local/lib/node_modules/appium/bin

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.

export PATH="$PATH:$HOME/.rvm/bin"

PATH="/Library/Frameworks/Python.framework/Versions/3.10/bin:${PATH}"

export PATH

alias python="/Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10

4.Git install

brew install git

git -version

5. Maven

Download Maven and set environment variable

https://maven.apache.org/download.cgi

Donwloand Maven and Allure from sharepoint

https://hkwbl.sharepoint.com/sites/Tech/External%20Sharing/Forms/AllItems.aspx?FolderCTID=0x012000E00430E5CA4C5B4BB2390BBF9C82FB32&OR=Teams%2DHL&CT=1665559707049&clickparams=eyJBcHBOYW1lIjoiVGVhbXMtRGVza3RvcCIsIkFwcFZlcnNpb24iOiIyNy8yMjA5MDQwMDcxMiIsIkhhc0ZlZGVyYXRlZFVzZXIiOnRydWV9&id=%2Fsites%2FTech%2FExternal%20Sharing%2FWDL%20Vendors%2FEPAM%2Fsetup&viewid=b4e1f124%2Db8eb%2D4d0b%2D96d0%2Db9e5b7512c05

搭建IOS自动化

1.macOS相关库安装

Mac电脑如何快速安装Homebrew

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

安装libimobiledevice

brew install libimobiledevice

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

安装ideviceinstaller

brew install ideviceinstaller

获取设备udid、安装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

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

appium-doctor

npm install -g appium-doctor

验证appium环境

appium-doctor

2.XCode

Xcode 是iOS开发环境,可以到app store 下载安装。

3.配置WebDriverAgent

1)打开xcode,并且在xcode路径中打开WebDriverAgent, 其路径如下所示,下载xcode后就会有这个路径,有可能这个路径是在/user/jeff.xie/document路径下

/Users/jeff.xie/node_modules/appium/node_modules/appium-webdriveragent/WebDriverAgentRunner

创建账户如下图所示,并配置相关信息

配置账户

配置手机版本

配置 welab bank app bundle ID: welab.bank.mobile.stage

配置完成后,需要进行build

build之后需要执行product > Test

最后打appium-desktop,启动appium server,然后在Appium Inspector配置手机信息,启动后就可以开始定位元素

{

"platformName": "iOS",

"appium:platformVersion": "14.6",

"appium:deviceName": "iPhone Jeff",

"appium: bundleId": "welab.bank.mobile.stage",

"appium:automationName": "XCUITest",

"appium:udid": "00008030-000A09C81A43802E"

}

查看手机的udid,查看android模拟器的name

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值