product-detail.js 4.94 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) => {
  await driver.sleep(ACTION_PAUSE_TIME);
  console.log("点击首页TAB");
  tapView = await driver.waitForElementByXPath('//XCUIElementTypeApplication[@name="Yoho!Buy有货"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther[1]/XCUIElementTypeOther[2]/XCUIElementTypeTabBar/XCUIElementTypeButton[1]', 10000);
  tapView.click();
  await driver.sleep(ACTION_PAUSE_TIME);
  console.log("点击首页顶部搜索框");
  tapView = await driver.waitForElementByAccessibilityId('homeSearch', FIND_VIEW_OVER_TIME);
  tapView.click();
  await driver.sleep(ACTION_PAUSE_TIME);
  console.log("输入指定的搜索词");
  tapView = await driver.waitForElementByAccessibilityId('yh_search_vc_search', FIND_VIEW_OVER_TIME);
  tapView.sendKeys("52090140");
  await driver.sleep(ACTION_PAUSE_TIME);
  console.log("点击搜索");
  tapView = await driver.waitForElementByAccessibilityId('Search', FIND_VIEW_OVER_TIME);
  tapView.click();
  await driver.sleep(ACTION_PAUSE_TIME);
  console.log("点击指定的商品");
  tapView = await driver.waitForElementByAccessibilityId('yh_prd_cell_0_1', FIND_VIEW_OVER_TIME);
  tapView.click();

  await driver.sleep(ACTION_PAUSE_TIME);
  //进入购物车
  let goToShopCart = await driver.waitForElementByAccessibilityId('yh_prd_detail_shopcart_btn', FIND_VIEW_OVER_TIME);
  await goToShopCart.click();
  console.log("进入购物车完成");

  await driver.sleep(ACTION_PAUSE_TIME);

  //返回商品详情
  let backPrdDetail = await driver.waitForElementByAccessibilityId('yh_base_vc_back_btn', FIND_VIEW_OVER_TIME);
  await backPrdDetail.click();
  console.log("返回详情完成");

  await driver.sleep(ACTION_PAUSE_TIME);

  //点击分享
  let tapShare = await driver.waitForElementByAccessibilityId('shareActionBtn', FIND_VIEW_OVER_TIME);
  await tapShare.click();
  console.log("点击分享完成");

  await driver.sleep(ACTION_PAUSE_TIME);

  //取消分享
  let cancelShare = await driver.waitForElementByAccessibilityId('取消', FIND_VIEW_OVER_TIME);
  await cancelShare.click();
  console.log("取消完成");
  await driver.sleep(ACTION_PAUSE_TIME);

  let tapMore = await driver.waitForElementByAccessibilityId('moreActionBtn', FIND_VIEW_OVER_TIME);
  await tapMore.click();
  console.log("点击更多");
  await driver.sleep(ACTION_PAUSE_TIME);
  
  let cancelMore = await driver.waitForElementByAccessibilityId('quick_jump_bg_view', FIND_VIEW_OVER_TIME);
  await cancelMore.click();
  console.log("取消更多");
  await driver.sleep(ACTION_PAUSE_TIME);
  //点击加入购物车
  let addToCart = await driver.waitForElementByAccessibilityId('加入购物车', FIND_VIEW_OVER_TIME);
  await addToCart.click();
  console.log("点击选择颜色尺码弹窗完成");
  await driver.sleep(ACTION_PAUSE_TIME);
  //选择颜色
  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("完成选择颜色");
  await driver.sleep(ACTION_PAUSE_TIME);
  //选择尺码
  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("完成选择尺码");
  await driver.sleep(ACTION_PAUSE_TIME);
  //加一下
  let chooseAdd = await driver.waitForElementByAccessibilityId('yh_choose_view_add_btn', FIND_VIEW_OVER_TIME);
  await chooseAdd.click();
  console.log("点击加一件");
  await driver.sleep(ACTION_PAUSE_TIME);
  //减一下
  let chooseReduce = await driver.waitForElementByAccessibilityId('yh_choose_view_reduce_btn', FIND_VIEW_OVER_TIME);
  await chooseReduce.click();
  console.log("点击减一件");
  await driver.sleep(ACTION_PAUSE_TIME);
  //点击加入购物车
  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);
});