product-detail.js 4.19 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]', 10000);
  await categoryTab.click();
  //点击分类中的 其中一个分类
  let category = await driver.waitForElementByXPath('//XCUIElementTypeApplication[@name="Yoho!Buy有货"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[1]/XCUIElementTypeOther[3]/XCUIElementTypeCollectionView/XCUIElementTypeCell[4]/XCUIElementTypeOther', 3000);
  await category.click();
  console.log("点击分类完成");
  
  //点击其中的一个商品
  let firstProduct = await driver.waitForElementByAccessibilityId('yh_prd_cell_0_3', 3000);
  await firstProduct.click();
  console.log("点击其中一个商品完成");
  //进入购物车
  let goToShopCart = await driver.waitForElementByAccessibilityId('yh_prd_detail_shopcart_btn', 3000);
  await goToShopCart.click();
  console.log("进入购物车完成");
  //返回商品详情
  let backPrdDetail = await driver.waitForElementByAccessibilityId('yh_base_vc_back_btn', 3000);
  await backPrdDetail.click();
  console.log("返回详情完成");
  //点击分享
  let tapShare = await driver.waitForElementByAccessibilityId('shareActionBtn', 3000);
  await tapShare.click();
  console.log("点击分享完成");
  //取消分享
  let cancelShare = await driver.waitForElementByAccessibilityId('取消', 3000);
  await cancelShare.click();
  console.log("取消完成");
  let tapMore = await driver.waitForElementByAccessibilityId('moreActionBtn', 3000);
  await tapMore.click();
  console.log("点击更多");
  let cancelMore = await driver.waitForElementByAccessibilityId('quick_jump_bg_view', 3000);
  await cancelMore.click();
  console.log("取消更多");
  //点击加入购物车
  let addToCart = await driver.waitForElementByAccessibilityId('加入购物车', 3000);
  await addToCart.click();
  console.log("点击选择颜色尺码弹窗完成");
  //选择颜色
  let chooseColor = await driver.waitForElementByXPath('//XCUIElementTypeApplication[@name="Yoho!Buy有货"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[1]/XCUIElementTypeStaticText[1]', 3000);
  await chooseColor.click();
  console.log("完成选择颜色");
  //选择尺码
  let chooseSize = await driver.waitForElementByXPath('//XCUIElementTypeApplication[@name="Yoho!Buy有货"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[2]/XCUIElementTypeStaticText[1]', 3000);
  await chooseSize.click();
  console.log("完成选择尺码");
  //加一下
  let chooseAdd = await driver.waitForElementByAccessibilityId('yh_choose_view_add_btn', 3000);
  await chooseAdd.click();
  console.log("点击加一件");
  //减一下
  let chooseReduce = await driver.waitForElementByAccessibilityId('yh_choose_view_reduce_btn', 3000);
  await chooseReduce.click();
  console.log("点击减一件");
  //点击加入购物车
  let add = await driver.waitForElementByXPath('//XCUIElementTypeApplication[@name="Yoho!Buy有货"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeButton[2]', 3000);
  await add.click();
  console.log("点加购物车");
  await driver.sleep(3000);
  console.log("点击返回列表");
  let backBtn = await driver.waitForElementByAccessibilityId('backActionBtn', 3000);
  await backBtn.click();
  await driver.sleep(3000);
  console.log("点击返回品类页");
  backBtn = await driver.waitForElementByAccessibilityId('yh_base_vc_back_btn', 3000);
  await backBtn.click();
  await driver.sleep(3000);
});