Authored by 陈林

增加UFO 浏览相关的自动化埋点用例,包括UFO首页、UFO品类、UFO系列列表、UFO商品详情页面。

  1 +//寻找View的超时时间
  2 +module.exports.FIND_VIEW_OVER_TIME = 5000;
  3 +
  4 +//操作暂停时间
  5 +module.exports.ACTION_PAUSE_TIME = 3000;
@@ -9,3 +9,4 @@ module.exports.iOS_TAB_GUANG = 'iOS_TAB_GUANG'; @@ -9,3 +9,4 @@ module.exports.iOS_TAB_GUANG = 'iOS_TAB_GUANG';
9 module.exports.ANDROID_PRODUCT_DETAIL = 'ANDROID_PRODUCT_DETAIL'; 9 module.exports.ANDROID_PRODUCT_DETAIL = 'ANDROID_PRODUCT_DETAIL';
10 module.exports.ANDROID_UFO_PRODUCT_DETAIL = 'ANDROID_UFO_PRODUCT_DETAIL'; 10 module.exports.ANDROID_UFO_PRODUCT_DETAIL = 'ANDROID_UFO_PRODUCT_DETAIL';
11 module.exports.ANDROID_PRODUCT_CART = 'ANDROID_PRODUCT_CART'; 11 module.exports.ANDROID_PRODUCT_CART = 'ANDROID_PRODUCT_CART';
  12 +module.exports.ANDROID_CASE_UFO_BROWSE = 'ANDROID_CASE_UFO_BROWSE';
  1 +/*
  2 + * UFO 浏览场景匹配规则,包括UFO首页、UFO品类、UFO系列列表、UFO商品详情页面
  3 + * author: chenlin
  4 + *
  5 + */
  6 +const {
  7 + ANDROID_CASE_UFO_BROWSE
  8 +} = require('../../scene-types/scene-types');
  9 +
  10 +module.exports = {
  11 + [ANDROID_CASE_UFO_BROWSE]:[
  12 + { op: 'YB_UFO', name: 'TAB BAR 点击UFO'},
  13 + { op: 'UFO_BROWSE_HOME', name: 'UFO首页浏览上报'},
  14 + { op: 'UFO_MAIN_START', name: "UFO频道打开", single: true},
  15 + { op: 'YB_SHOW_EVENT', name: "曝光事件", types: { DATA: Array } },
  16 +
  17 + { op: 'UFO_CATEGORY_C', name: "分类点击" },
  18 + { op: 'YB_PAGE_ENTER', name: "进入分类页面", equals: {"TYPE_ID":"ufo_category"} },
  19 +
  20 + { op: 'YB_PAGE_EXIT', name: "退出分类页面", equals: {"TYPE_ID":"ufo_category"} },
  21 +
  22 + { op: 'UFO_MAIN_EVENT', name: "首页楼层点击" },
  23 + { op: 'YB_PAGE_ENTER', name: "进入商品列表页面", equals: {"TYPE_ID":"ufo_productList"} },
  24 + { op: 'UFO_PRD_LIST_L', name: "商品列表第一页商品ID曝光", types: { PRD_LIST: String } },
  25 +
  26 + { op: 'YB_PAGE_EXIT', name: "退出商品列表页面", equals: {"TYPE_ID":"ufo_productList"} },
  27 +
  28 + { op: 'UFO_MAIN_EVENT', name: "商品点击", types: { PRD_ID: String } },
  29 + { op: 'YB_PAGE_ENTER', name: "进入商品详情页面", equals: {"TYPE_ID":"ufo_productDetail"} },
  30 + { op: 'UFO_PRD_DT_INFO', name: "商品详情页面上报", equals: {"FP_NAME":"aFP_UFOHome"}, types: {PRD_ID: String} },
  31 +
  32 + { op: 'YB_PAGE_EXIT', name: "退出商品详情页面", equals: {"TYPE_ID":"ufo_productDetail"} },
  33 +
  34 +
  35 + ]
  36 +};
  1 +/*
  2 + * UFO 浏览场景,包括UFO首页、UFO品类、UFO系列列表、UFO商品详情页面
  3 + * author: chenlin
  4 + *
  5 + */
  6 +
  7 +const wd = require('wd');
  8 +const {describe} = require('../../libs/driver');
  9 +const {ANDROID_CASE_UFO_BROWSE} = require('../../scene-types/scene-types');
  10 +const {FIND_VIEW_OVER_TIME, ACTION_PAUSE_TIME} = require('../../config/constant');
  11 +
  12 +describe(ANDROID_CASE_UFO_BROWSE, 'Android UFO首页测试用例', async(driver) => {
  13 +
  14 + //点击UFO tab,进入UFO首页
  15 + let ufoTab = await driver.waitForElementById('com.yoho:id/tabMain_radioImage_ufo_rl', FIND_VIEW_OVER_TIME);
  16 + await ufoTab.click();
  17 +
  18 + // 暂停
  19 + await driver.sleep(ACTION_PAUSE_TIME);
  20 +
  21 + //点击进入分类列表
  22 + let categoryView = await driver.waitForElementByXPath('/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[1]/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout[1]/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[1]/android.view.ViewGroup[3]/android.widget.ImageView', FIND_VIEW_OVER_TIME);
  23 + await categoryView.click();
  24 +
  25 + // 暂停
  26 + await driver.sleep(ACTION_PAUSE_TIME);
  27 +
  28 + //退出分类列表
  29 + let quitCategoryView = await driver.waitForElementByXPath('/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[1]/android.view.ViewGroup/android.view.ViewGroup[1]/android.widget.ImageView', FIND_VIEW_OVER_TIME);
  30 + await quitCategoryView.click();
  31 +
  32 + //点击进入系列列表
  33 + let searialView = await driver.waitForElementByXPath('/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[1]/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout[1]/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup/android.widget.ScrollView/android.view.ViewGroup/android.view.ViewGroup[2]/android.widget.ScrollView/android.view.ViewGroup/android.view.ViewGroup[3]/android.view.ViewGroup/android.view.ViewGroup/android.widget.ImageView', FIND_VIEW_OVER_TIME);
  34 + await searialView.click();
  35 +
  36 + // 暂停
  37 + await driver.sleep(ACTION_PAUSE_TIME);
  38 +
  39 + //退出系列列表
  40 + let quitSearialView = await driver.waitForElementByXPath('/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[1]/android.view.ViewGroup/android.widget.ImageView', FIND_VIEW_OVER_TIME);
  41 + await quitSearialView.click();
  42 +
  43 + // 暂停
  44 + await driver.sleep(ACTION_PAUSE_TIME);
  45 +
  46 + //进入商品详情
  47 + let goodsView = await driver.waitForElementByXPath('/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[1]/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout[1]/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup/android.widget.ScrollView/android.view.ViewGroup/android.view.ViewGroup[6]/android.view.ViewGroup', FIND_VIEW_OVER_TIME);
  48 + await goodsView.click();
  49 +
  50 + // 暂停
  51 + await driver.sleep(ACTION_PAUSE_TIME);
  52 +
  53 + //退出商品详情
  54 + let quitGoodsView = await driver.waitForElementById('com.yoho:id/back_btn', FIND_VIEW_OVER_TIME);
  55 + await quitGoodsView.click();
  56 +
  57 + // 暂停
  58 + await driver.sleep(ACTION_PAUSE_TIME);
  59 +
  60 +
  61 + // await new Promise(r => {
  62 + // setTimeout(() => {
  63 + // r()
  64 + // }, 3000);
  65 + // })
  66 +
  67 +
  68 +
  69 +
  70 +});