一、iOS+Appium环境搭建 1. 需使用macOS系统电脑 2. 安装Xcode -- 打开App Store直接下载 3. 安装Homebrew: 3.1 官网:https://brew.sh/index_zh-cn 3.2 国内镜像源终端命令:$ /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)" 4. 安装node: 4.1 官网:https://nodejs.org/en/download 4.2 终端命令:$ brew install node 5. 安装cnpm: 5.1 终端命令:$ npm install -g cnpm --registry=https://registry.npm.taobao.org 6. 安装Carthage: 6.1 终端命令:$ brew install carthage 7. 安装ios-deploy: 7.1 终端命令:$ cnpm install -g ios-deploy 8. 安装libimobiledevice,ideviceinstaller: 8.1 终端命令:$ brew install --HEAD libimobiledevice 8.2 终端命令:$ brew install ideviceinstaller 9. 安装Appium服务器: 9.1 Appium Server GUI官网:https://github.com/appium/appium-desktop/releases 10. 安装Appium Inspector: 10.1 Appium Inspector官网:https://github.com/appium/appium-inspector(右侧Releases中下载最新版本) 二、配置WebDriverAgent 1. 下载WebDriverAgent包: 1.1 官网:https://github.com/appium/WebDriverAgent/releases 2. 替换Appium中WebDriverAgent包: 2.1 finder/application里找到最新安装的appium app, 右击选择show package contents,定位到WebDriverAgent.xcodeproj所在路径: 如:/opt/homebrew/lib/node_modules/appium/node_modules/appium-webdriveragent 2.2 把下载好的WedDriverAgent里的全部内容替换到2.1的路径下(原内容可全部删除) 2.3 双击替换后的WebDriverAgent.xcodeproj,用Xcode启动打开 3. 配置WebDriverAgent: 3.1 配置WebDriverAgentLib的开发者信息 3.1.1 Signing & Capabilities处,选择Team(个人账号即可) 3.1.2 修改Product Bundle Identifier,在Build settings处,修改成一个不重复的名字(如:我将facebook修改成了richtap) 3.2 配置WebDriverAgentRunner的开发者信息 3.2.1 Signing & Capabilities处,选择Team(个人账号即可) 3.2.2 修改Product Bundle Identifier,在Build settings处,修改成一个不重复的名字(如:我将facebook修改成了richtap) 3.3 配置IntegrationApp的开发者信息 3.3.1 Signing & Capabilities处,选择Team(个人账号即可) 3.3.2 修改Product Bundle Identifier,在Build settings处,修改成一个不重复的名字(如:我将facebook修改成了richtap) 4. 数据线连接真机 5. 选择将要运行的WebDriverAgentRunner和真机设备 6. 使用 command+U 运行 6.1 稍后会在log中输出url地址 6.2 在浏览器中打开该地址会显示一串json数据即为正确连接手机 6.3 真机会自动安装一个WebDriverAgent程序 7. 初次使用需要在真机的 设置 ➡️ 通用 ➡️ VPN与设备管理 中信任该程序,然后再次使用 command+U 运行 三、安装Python和pycharm 1. Python官网:https://www.python.org/ 1.1 下载python3.x版本 2. Pycharm官网:https://www.jetbrains.com/pycharm/ 四、安装JDK(使用allure报告必须依赖java环境) 1. 可从官网,也可以从接下来地址:http://www.codebaoku.com/jdk/jdk-index.html 2. 配置JDK环境变量: 2.1 如果此前建过.bash_profile隐藏配置文件,直接在终端输入$ open -e .bash_profile打开文件即可,如果没有则输入下方命令: $ touch .bash_profile 2.2 输入下方命令打开此文件: $ open -e .bash_profile 2.3 打开.bash_profile文件输入环境配置参数,将下方参数放入其中,并保存 如:JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.17.jdk/Contents/Home PATH=$JAVA_HOME/bin:$PATH:. CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:. xport JAVA_HOME export PATH export CLASSPATH 2.4 输入以下命令使配置文件生效 $ source .bash_profile 2.5 最后检验下环境变量是否配置成功 $ echo $JAVA_HOME 2.6 查询jdk版本 $ java --version 五、下载allure包 1. allure官网:https://github.com/allure-framework/allure2/releases 2. 下载zip包,默认在mac /users/用户/Downloads,然后解压到任意目录 3. 配置allure环境变量 3.1 打开终端 $ open -e .bash_profile 3.2 添加如下内容:(此处下载的版本是2.21.0) 如:#allure 2.21.0 export PATH=${PATH}:/Users/allure-2.21.0/bin 3.3 验证allure环境变量是否安装成功 $ allure --version --------------------------------------------------------------------------------------- 六、Pycharm中用到的第三方库(Settings ➡️ Python Interpreter中可自行安装第三方库) 1. selenium 2. pytest 3. yaml 4. allure 5. rerunfailures 6. Appium-Python-Client --------------------------------------------------------------------------------------- 七、启动Appium Server和Appium Inspector创建会话,Remote Path:/wd/hub(其他不用修改) JSON Representation添加如下: { "platformName": "iOS", "platformVersion": "16.4.1", "deviceName": "iPhone 12 Pro", "app": "xxx", "udid": "xxxxxxxxxx" } 八、udid的查看 1. Xcode打开,连接真机 2. 顶部Window ➡️ Devices and Simulators ➡️ Identifier即为udid参数的值
iOS+Appium实现app自动化的环境搭建
于 2023-08-17 10:55:44 首次发布