product-detail.js
4.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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("点击分类完成");
await driver.sleep(ACTION_PAUSE_TIME);
//点击其中的一个商品
let firstProduct = await driver.waitForElementByAccessibilityId('yh_prd_cell_0_3', FIND_VIEW_OVER_TIME);
await firstProduct.click();
console.log("点击其中一个商品完成");
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);
});