环境配置
config.yaml 包含了项目运行时必要参数,结构如下:
| 平台 | 公共参数 | 值 | 必填 | 类型 | 描述 |
|---|---|---|---|---|---|
| 不限 | driver | appium | macaca | selenium | 是 | String | 驱动类型 |
| reStart | true | false | 是 | Boolean | 每条用例执行完毕后是否重新启动 | |
| timeOut | 10 | 否 | Number | 元素查找超时时间,默认10s | |
| saveScreenshot | true | false | 否 | Boolean | 用例步骤是否截图,默认false | |
| desiredCapabilities | 是 | List | 框架所需参数 | ||
| appium 、macaca | platformName | 是 | String | 平台类型 | |
| udid | 是 | String/List | 设备id,多设备运行该配置必须为List | ||
| package/appPackage | 是 | String | Android 应用包名 | ||
| activity/appActivity | 是 | String | Android 应用启动页 | ||
| bundleId | 是 | String | iOS 应用Bundle ID | ||
| macaca | reuse | 否 | Number | 0: 启动并安装 app。1 (默认): 卸载并重装 app。 2: 仅重装 app。3: 在测试结束后保持 app 状态。 | |
| appium | noReset | 否 | Boolean | 在当前 session 下是否重置应用的状态。默认值为false | |
| automationName | 是 | String | Appium引擎 Android:Appium、iOS:XCUITest | ||
| selenium | browser | 是 | String | 浏览器 | |
| remoteUrl | 否 | List | selenium remote url地址,为空时启动本地浏览器 | ||
| maxWindow | 否 | Boolean | 其实最大化窗口,默认值为false | ||
| chrome | 否 | Dictionary | browser对应浏览器配置 chrome: - driver: ‘chromedriver’ # 驱动地址 options: # 浏览器配置 - ‘—headless’ - ‘—dissble-gpu’ - ‘—window-size=1920,1050’ |
||
| 不限 | testcase | case path | 是 | List | TestCase/ 执行全部用例 TestCase/common/ 执行common目录下用例 TestCase/common/common.yaml 执行单条用例 可多种组合 |
参考配置如下:
appium
driver: 'appium'reStart: TruetimeOut: 5saveScreenshot: FalsedesiredCapabilities:platformName : 'Android'udid: 'deviecs_id'package: 'com.eg.android.AlipayGphone'activity: 'com.eg.android.AlipayGphone.AlipayLogin'automationName: 'Appium'deviceName: 'HUAWEI'noReset: TruebundleId: 'com.apple.mobilesafari'testcase:- 'TestCase/OpenWebView.yaml'
macaca
driver: 'macaca'
reStart: True
timeOut: 5
saveScreenshot: True
desiredCapabilities:
platformName : 'Android'
udid: 'deviecs_id'
package: 'com.eg.android.AlipayGphone'
activity: 'com.eg.android.AlipayGphone.AlipayLogin'
bundleId: 'com.apple.mobilesafari'
reuse: 3
testcase:
- 'TestCase/OpenWebView.yaml'
selenium
driver: 'selenium'
reStart: True
saveScreenshot: False
timeOut: 5
desiredCapabilities:
browser: 'chrome'
maxWindow: True
chrome:
driver: '/Users/admin/Desktop/chromedriver' # 驱动地址
options: # chrom 配置
- '--headless'
- '--dissble-gpu'
- '--window-size=1920,1050'
firefox:
river: '/Users/admin/Desktop/geckodriver'
options:
- '--headless'
- '--dissble-gpu'
- '--window-size=1920,1050'
testcase:
- 'TestCase/selenium'
数据配置
data.yaml为数据配置文件,配置结构如下:
variable: 全局变量配置,所有用例均可获取该配置下变量
resource:文件资源配置,所有用例均可获取该配置下文件路径
keywords:扩展函数配置,所有用例均可调用该配置下脚本函数
variable:
userid: "admin"
password: 13456
resource: {
logo: "Resources/logo.png"
logo1: "Resources/logo1.png"
keywords:
- "keyDown"
- "find_elements_by_id"
