iOS自动化之WDA(WebDriverAgent)安装

1、WDA介绍

WebDriverAgent 在 iOS 端实现了一个 WebDriver server ,借助这个 server 我们可以远程控制 iOS 设备。你可以启动、杀死应用,点击、滚动视图,或者确定页面展示是否正确。

facebook的WDA在iOS 10 时代苹果已经废弃了,目前依然在更新的是Appium官方的WDA,官方链接如下:https://github.com/appium/WebDriverAgent,安装配置和facebook类似,配置好签名证书即可,不需要修改代码,也不需要修改Bundle ID.如果想查看iOS的应用界面,安装使用Appium的Inspector即可

2、部署环境

OS: 11.6

Xcode:13 (需要系统更新最新才能在appstore下载xcode)

3、安装步骤


1、安装基础依赖
brew install git

brew install carthage

2、下载WDA 
安装appiium就带有WebDriverAgent (/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent)

3、执行bootstrap.sh

./Scripts/bootstrap.sh

ERROR in ./js/app.js
Module parse failed: /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/js/app.js Unexpected token (67:6)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (67:6)
at Parser.pp$4.raise (/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/webpack/node_modules/acorn/dist/acorn.js:2221:15)
at Parser.pp.unexpected (/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/webpack/node_modules/acorn/dist/acorn.js:603:10)

解决方法:cd /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/webpack.config.js

webpack.config.js 文件里去掉 exclude: /node_modules/(忽略node_modules)

修改前:

module: {
    loaders: [
      { test: /\.js?$/, loaders: ['babel-loader'], exclude: /node_modules/ }, 
      { test: /\.js?$/, loaders: ['babel-loader'] },
      { test: /\.css?$/, loader: 'style-loader!css-loader' },
    ]
  },

 修改后:

loaders: [
      { test: /\.js?$/, loaders: ['babel-loader'] },
      { test: /\.css?$/, loader: 'style-loader!css-loader' },
    ]

重新执行 ./Scripts/bootstrap.sh

 

4、打开WebDriverAgent工程配置

终端cd /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent,通过open  WebDriverAgent.xcodeproj(xcdoe打开方式)

1、ios自动化所需的WebDriverAgent需要签名产生,找开发要p12证书和描述文件.mobileprovision

  1、点击p12输入密码之后,要先选中登陆,导入p12文件即可

  2、双击.mobileprovision描述文件,会自动安装到xcode中

2、选择WebDriverAgent进入

iOS自动化之WDA(WebDriverAgent)安装

 

 

 

 

3、除了tv_os的target都进行重签配置,如下图所示修改配置

WebDriverAgentLib 如下图:

iOS自动化之WDA(WebDriverAgent)安装

 

 

 

WebDriverAgentRunner 配置如下图:

iOS自动化之WDA(WebDriverAgent)安装

 

 检查WebDriverAgentRunner-signing&Capabilities

iOS自动化之WDA(WebDriverAgent)安装

 

 

 4、选择product,scheme选择WebDriverRunner

iOS自动化之WDA(WebDriverAgent)安装

 

 

 5、构建项目build

选择iphone

iOS自动化之WDA(WebDriverAgent)安装

 

 点击build

iOS自动化之WDA(WebDriverAgent)安装

 

 

6、检测是否安装wda成功

由于国内手机设置需要转发下端口,命令行执行:iproxy 8300 8100

然后再浏览器里请求:http://localhost:8300/,如果返回一串json字符,那么WDA安装成功了

iOS自动化之WDA(WebDriverAgent)安装

 

http://localhost:8300/status可以查看当前设备的状态,获取与wda通信session id

iOS自动化之WDA(WebDriverAgent)安装

 

 

http://localhost:8300/inspector 打开WDA 的inspector,在该界面点击home则手机返回主页面

iOS自动化之WDA(WebDriverAgent)安装

 

上一篇:webpack 生产/开发环境配置文件分离


下一篇:webpack开发服务器运作过程