Authored by 孟顺

提交商品详情基本自动化测试用例

... ... @@ -4,36 +4,59 @@ const {
module.exports = {
[IOS_PRODUCT_DETAIL]: [
{op: 'YB_LAUNCH_APP', name: '启动app', single: true},
{op: 'YB_PAGE_ENTER', name: '第一次打开页面', equals: { PAGE_ID: 'sy' }},
{op: 'YB_PAGE_ENTER', name: '第一次打开页面2'},
{op: 'YB_PAGE_ENTER'},
{op: 'YB_SHOW_CATEGORY', name: 'YB_SHOW_CATEGORY1', types: {YH_AppChannelBlk: Array, 'YH_AppChannelBlk[0].SUBLIST': Array}},
{op: 'YB_SHOW_CATEGORY', name: 'YB_SHOW_CATEGORY2'},
{op: 'YB_ENTER_CHOICE'},
{op: 'YB_SHOW_CATEGORY', name: 'YB_SHOW_CATEGORY3'},
{op: 'YB_PAGE_EXIT', equals: { PAGE_ID: 'xbxzy' }},
{op: 'YB_PAGE_EXIT'},
{op: 'YB_CATEGORY'},
{op: 'YB_AUTO_TRACK'},
{op: 'YB_PAGE_EXIT', priority: 11},
{op: 'YB_CATEGORY_CLS_TAB', priority: 13},
{op: 'YB_PAGE_ENTER'},
{op: 'YB_SHOW_MAIN_RECOMMEND'},
{op: 'YB_CHOOSE_FOR_YOU'},
{op: 'YB_CATEGORY_CAT_FLR_C', priority: 12},
{op: 'YB_AUTO_TRACK'},
{op: 'YB_GOODS_LIST'},
{op: 'YB_SHOW_GOODS_LIST'},
{op: 'YB_PAGE_EXIT'},
{op: 'YB_PAGE_ENTER'},
{op: 'YB_GOODS_LIST_DT'},
{op: 'YB_AUTO_TRACK'},
{op: 'YB_GDS_DT_INFO'},
{op: 'YB_PAGE_ENTER'},
{op: 'YB_PAGE_EXIT', validate: (log) => {
return log.param.PAGE_ID === 'pl';
}},
{op: 'YB_CHOOSE_FOR_YOU'}
{ op: 'YB_PAGE_ENTER', name: '进入商品详情页', equals: { PAGE_ID: 'spxqy' } },
{
op: 'YB_GDS_DT_INFO', name: '请求商品数据成功', validate: (log) => {
return log.param.PRD_SKN.length > 0;
}
},
{
op: 'YB_GDS_COLOR_C', name: '点击颜色(可以没有 如果只有一个颜色是不可点击的)', validate: (log) => {
return log.param.PRD_ID.length > 0 && log.param.COLOR.length > 0;
}
},
{
op: 'YB_GDS_SIZE_C', name: '点击尺码(可以没有 如果只有一个尺码是不可点击的)', validate: (log) => {
return log.param.PRD_ID.length > 0 && log.param.SIZE.length > 0;
}
},
{
op: 'YB_GDS_DT_SEL', name: '加入购物车', validate: (log) => {
return log.param.PRD_SKU > 0;
}
},
// {op: 'YB_LAUNCH_APP', name: '启动app', single: true},
// {op: 'YB_PAGE_ENTER', name: '第一次打开页面', equals: { PAGE_ID: 'sy' }},
// {op: 'YB_PAGE_ENTER', name: '第一次打开页面2'},
// {op: 'YB_HOME_CHANNEL_TAB_C', name: '自动选择了默认TAB SEGEMENT'},
// {op: 'YB_PAGE_ENTER'},
// {op: 'YB_SHOW_CATEGORY', name: 'YB_SHOW_CATEGORY1', types: {YH_AppChannelBlk: Array, 'YH_AppChannelBlk[0].SUBLIST': Array}},
// {op: 'YB_SHOW_CATEGORY', name: 'YB_SHOW_CATEGORY2'},
// {op: 'YB_ENTER_CHOICE'},
// {op: 'YB_SHOW_CATEGORY', name: 'YB_SHOW_CATEGORY3'},
// {op: 'YB_PAGE_EXIT', equals: { PAGE_ID: 'xbxzy' }},
// {op: 'YB_PAGE_EXIT'},
// {op: 'YB_CATEGORY'},
// {op: 'YB_AUTO_TRACK'},
// {op: 'YB_PAGE_EXIT', priority: 11},
// {op: 'YB_CATEGORY_CLS_TAB', priority: 13},
// {op: 'YB_PAGE_ENTER'},
// {op: 'YB_SHOW_MAIN_RECOMMEND'},
// {op: 'YB_CHOOSE_FOR_YOU'},
// {op: 'YB_CATEGORY_CAT_FLR_C', priority: 12},
// {op: 'YB_AUTO_TRACK'},
// {op: 'YB_GOODS_LIST'},
// {op: 'YB_SHOW_GOODS_LIST'},
// {op: 'YB_PAGE_EXIT'},
// {op: 'YB_PAGE_ENTER'},
// {op: 'YB_GOODS_LIST_DT'},
// {op: 'YB_AUTO_TRACK'},
// {op: 'YB_GDS_DT_INFO'},
// {op: 'YB_PAGE_ENTER'},
// {op: 'YB_PAGE_EXIT', validate: (log) => {
// return log.param.PAGE_ID === 'pl';
// }},
// {op: 'YB_CHOOSE_FOR_YOU'}
]
};
... ...
... ... @@ -2,19 +2,38 @@ const {describe} = require('../../libs/driver');
const {IOS_PRODUCT_DETAIL} = require('../../scene-types/scene-types');
describe(IOS_PRODUCT_DETAIL, '商品详情页埋点测试', async(driver) => {
let categoryTab = await driver.waitForElementByXPath('//XCUIElementTypeApplication[@name="Yoho!Buy有货"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeTabBar/XCUIElementTypeButton[2]', 10000);
//点击首页的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/XCUIElementTypeOther[1]/XCUIElementTypeOther[3]/XCUIElementTypeCollectionView/XCUIElementTypeCell[1]/XCUIElementTypeOther', 10000);
//点击分类中的 其中一个分类
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();
let firstProduct = await driver.waitForElementByXPath('//XCUIElementTypeApplication[@name="Yoho!Buy有货"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeCollectionView/XCUIElementTypeCell[1]/XCUIElementTypeOther/XCUIElementTypeOther', 10000);
//点击其中的一个商品
let firstProduct = await driver.waitForElementByXPath('//XCUIElementTypeApplication[@name="Yoho!Buy有货"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeCollectionView/XCUIElementTypeCell[2]/XCUIElementTypeOther/XCUIElementTypeOther', 3000);
await firstProduct.click();
//点击加入购物车
let addToCart = await driver.waitForElementByAccessibilityId('加入购物车', 3000);
await addToCart.click();
//选择颜色
let chooseColor = await driver.waitForElementByXPath('//XCUIElementTypeApplication[@name="Yoho!Buy有货"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[1]/XCUIElementTypeStaticText[1]', 3000);
await chooseColor.click();
//选择尺码
let chooseSize = await driver.waitForElementByXPath('//XCUIElementTypeApplication[@name="Yoho!Buy有货"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[2]/XCUIElementTypeStaticText[1]', 3000);
await chooseSize.click();
//加一下
let chooseAdd = await driver.waitForElementByXPath('//XCUIElementTypeApplication[@name="Yoho!Buy有货"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[3]/XCUIElementTypeButton[1]', 3000);
await chooseAdd.click();
//减一下
let chooseReduce = await driver.waitForElementByXPath('//XCUIElementTypeApplication[@name="Yoho!Buy有货"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[3]/XCUIElementTypeButton[2]', 3000);
await chooseReduce.click();
//点击加入购物车
let add = await driver.waitForElementByXPath('//XCUIElementTypeApplication[@name="Yoho!Buy有货"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeButton[2]', 3000);
await add.click();
let addToCart = await driver.waitForElementByXPath('//XCUIElementTypeButton[@name="加入购物车"]', 10000);
await new Promise(r => {
setTimeout(() => {
r()
}, 2000);
});
await addToCart.click();
});
});
\ No newline at end of file
... ...