product-detail.js 4.1 KB
const {describe} = require('../../libs/driver');
const {IOS_PRODUCT_DETAIL} = require('../../scene-types/scene-types');
const { FIND_VIEW_OVER_TIME, ACTION_PAUSE_TIME } = require('../../config/constant');

describe(IOS_PRODUCT_DETAIL, '商品详情页埋点测试', async(driver) => {
  //点击首页的tab bar 分类按钮
  let categoryTab = await driver.waitForElementByXPath('//XCUIElementTypeApplication[@name="Yoho!Buy有货"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther[1]/XCUIElementTypeOther[2]/XCUIElementTypeTabBar/XCUIElementTypeButton[2]', FIND_VIEW_OVER_TIME);
  await categoryTab.click();
  //点击分类中的 其中一个分类
  let category = await driver.waitForElementByAccessibilityId('yh_categoryCell_0', FIND_VIEW_OVER_TIME);
  await category.click();
  console.log("点击分类完成");
  
  //点击其中的一个商品
  let firstProduct = await driver.waitForElementByAccessibilityId('yh_prd_cell_0_3', FIND_VIEW_OVER_TIME);
  await firstProduct.click();
  console.log("点击其中一个商品完成");
  //进入购物车
  let goToShopCart = await driver.waitForElementByAccessibilityId('yh_prd_detail_shopcart_btn', FIND_VIEW_OVER_TIME);
  await goToShopCart.click();
  console.log("进入购物车完成");
  //返回商品详情
  let backPrdDetail = await driver.waitForElementByAccessibilityId('yh_base_vc_back_btn', FIND_VIEW_OVER_TIME);
  await backPrdDetail.click();
  console.log("返回详情完成");
  //点击分享
  let tapShare = await driver.waitForElementByAccessibilityId('shareActionBtn', FIND_VIEW_OVER_TIME);
  await tapShare.click();
  console.log("点击分享完成");
  //取消分享
  let cancelShare = await driver.waitForElementByAccessibilityId('取消', FIND_VIEW_OVER_TIME);
  await cancelShare.click();
  console.log("取消完成");
  let tapMore = await driver.waitForElementByAccessibilityId('moreActionBtn', FIND_VIEW_OVER_TIME);
  await tapMore.click();
  console.log("点击更多");
  let cancelMore = await driver.waitForElementByAccessibilityId('quick_jump_bg_view', FIND_VIEW_OVER_TIME);
  await cancelMore.click();
  console.log("取消更多");
  //点击加入购物车
  let addToCart = await driver.waitForElementByAccessibilityId('加入购物车', FIND_VIEW_OVER_TIME);
  await addToCart.click();
  console.log("点击选择颜色尺码弹窗完成");
  //选择颜色
  let chooseColor = await driver.waitForElementByXPath('//XCUIElementTypeApplication[@name="Yoho!Buy有货"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[1]/XCUIElementTypeStaticText[1]', FIND_VIEW_OVER_TIME);
  await chooseColor.click();
  console.log("完成选择颜色");
  //选择尺码
  let chooseSize = await driver.waitForElementByXPath('//XCUIElementTypeApplication[@name="Yoho!Buy有货"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[2]/XCUIElementTypeStaticText[1]', FIND_VIEW_OVER_TIME);
  await chooseSize.click();
  console.log("完成选择尺码");
  //加一下
  let chooseAdd = await driver.waitForElementByAccessibilityId('yh_choose_view_add_btn', FIND_VIEW_OVER_TIME);
  await chooseAdd.click();
  console.log("点击加一件");
  //减一下
  let chooseReduce = await driver.waitForElementByAccessibilityId('yh_choose_view_reduce_btn', FIND_VIEW_OVER_TIME);
  await chooseReduce.click();
  console.log("点击减一件");
  //点击加入购物车
  let add = await driver.waitForElementByXPath('//XCUIElementTypeApplication[@name="Yoho!Buy有货"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeButton[2]', FIND_VIEW_OVER_TIME);
  await add.click();
  console.log("点加购物车");
  await driver.sleep(4000);
  console.log("点击返回列表");
  let backBtn = await driver.waitForElementByAccessibilityId('backActionBtn', FIND_VIEW_OVER_TIME);
  await backBtn.click();
  await driver.sleep(ACTION_PAUSE_TIME);
  console.log("点击返回品类页");
  backBtn = await driver.waitForElementByAccessibilityId('yh_base_vc_back_btn', FIND_VIEW_OVER_TIME);
  await backBtn.click();
  await driver.sleep(ACTION_PAUSE_TIME);
});