Authored by 孟顺

拼团商品详情自动测试用例

review by 枪兵
@@ -11,21 +11,21 @@ module.exports = { @@ -11,21 +11,21 @@ module.exports = {
11 return log.param.PRD_SKN.length > 0; 11 return log.param.PRD_SKN.length > 0;
12 } 12 }
13 }, 13 },
14 - {  
15 - op: 'YB_GDS_COLOR_C', name: '点击颜色(可以没有 如果只有一个颜色是不可点击的)', validate: (log) => {  
16 - return log.param.PRD_ID.length > 0 && log.param.COLOR.length > 0;  
17 - }  
18 - },  
19 - {  
20 - op: 'YB_GDS_SIZE_C', name: '点击尺码(可以没有 如果只有一个尺码是不可点击的)', validate: (log) => {  
21 - return log.param.PRD_ID.length > 0 && log.param.SIZE.length > 0;  
22 - }  
23 - },  
24 - {  
25 - op: 'YB_GDS_DT_SEL', name: '加入购物车', validate: (log) => {  
26 - return log.param.PRD_SKU > 0;  
27 - }  
28 - }, 14 + // {
  15 + // op: 'YB_GDS_COLOR_C', name: '点击颜色(可以没有 如果只有一个颜色是不可点击的)', validate: (log) => {
  16 + // return log.param.PRD_ID.length > 0 && log.param.COLOR.length > 0;
  17 + // }
  18 + // },
  19 + // {
  20 + // op: 'YB_GDS_SIZE_C', name: '点击尺码(可以没有 如果只有一个尺码是不可点击的)', validate: (log) => {
  21 + // return log.param.PRD_ID.length > 0 && log.param.SIZE.length > 0;
  22 + // }
  23 + // },
  24 + // {
  25 + // op: 'YB_GDS_DT_SEL', name: '加入购物车', validate: (log) => {
  26 + // return log.param.PRD_SKU > 0;
  27 + // }
  28 + // },
29 29
30 // //套餐商品接口上报 30 // //套餐商品接口上报
31 // { 31 // {
1 const {describe} = require('../../libs/driver'); 1 const {describe} = require('../../libs/driver');
2 const {IOS_PRODUCT_DETAIL} = require('../../scene-types/scene-types'); 2 const {IOS_PRODUCT_DETAIL} = require('../../scene-types/scene-types');
  3 +const { FIND_VIEW_OVER_TIME, ACTION_PAUSE_TIME } = require('../../config/constant');
3 4
4 describe(IOS_PRODUCT_DETAIL, '商品详情页埋点测试', async(driver) => { 5 describe(IOS_PRODUCT_DETAIL, '商品详情页埋点测试', async(driver) => {
5 //点击首页的tab bar 分类按钮 6 //点击首页的tab bar 分类按钮
@@ -11,7 +12,7 @@ describe(IOS_PRODUCT_DETAIL, '商品详情页埋点测试', async(driver) => { @@ -11,7 +12,7 @@ describe(IOS_PRODUCT_DETAIL, '商品详情页埋点测试', async(driver) => {
11 console.log("点击分类完成"); 12 console.log("点击分类完成");
12 13
13 //点击其中的一个商品 14 //点击其中的一个商品
14 - 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[4]', 3000); 15 + let firstProduct = await driver.waitForElementByAccessibilityId('yh_prd_cell_0_3', 3000);
15 await firstProduct.click(); 16 await firstProduct.click();
16 console.log("点击其中一个商品完成"); 17 console.log("点击其中一个商品完成");
17 //进入购物车 18 //进入购物车
1 const wd = require('wd'); 1 const wd = require('wd');
2 const { describe } = require('../../libs/driver'); 2 const { describe } = require('../../libs/driver');
3 const { IOS_PRODUCT_DETAIL_GROUP } = require('../../scene-types/scene-types'); 3 const { IOS_PRODUCT_DETAIL_GROUP } = require('../../scene-types/scene-types');
4 -const IOS_SLEEP_WAIT_TIME = 3000; 4 +const { FIND_VIEW_OVER_TIME, ACTION_PAUSE_TIME } = require('../../config/constant');
5 5
6 -describe(IOS_PRODUCT_DETAIL_GROUP, '拼团商品详情页埋点测试', async (driver) => {  
7 - //点击我的 tab 6 +describe(IOS_PRODUCT_DETAIL_GROUP, '拼团商品详情页埋点测试(未登录)', async (driver) => {
  7 + console.log("点击TAB 我的");
8 let tapView = await driver.waitForElementByXPath('//XCUIElementTypeApplication[@name="Yoho!Buy有货"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther[1]/XCUIElementTypeOther[2]/XCUIElementTypeTabBar/XCUIElementTypeButton[5]', 10000); 8 let tapView = await driver.waitForElementByXPath('//XCUIElementTypeApplication[@name="Yoho!Buy有货"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther[1]/XCUIElementTypeOther[2]/XCUIElementTypeTabBar/XCUIElementTypeButton[5]', 10000);
9 tapView.click(); 9 tapView.click();
10 - //暂停  
11 - await driver.sleep(IOS_SLEEP_WAIT_TIME);  
12 - // //模拟向上滚动  
13 - // driver.execute('mobile: scroll', { direction: 'down'});  
14 - // await new Promise(r => {  
15 - // setTimeout(() => {  
16 - // r()  
17 - // }, 2000);  
18 - // });  
19 -  
20 - //点击5折拼团 10 + await driver.sleep(ACTION_PAUSE_TIME);
  11 + console.log("点击5折 拼团");
21 tapView = await driver.waitForElementByXPath('//XCUIElementTypeApplication[@name="Yoho!Buy有货"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeCollectionView/XCUIElementTypeCell[16]', 3000); 12 tapView = await driver.waitForElementByXPath('//XCUIElementTypeApplication[@name="Yoho!Buy有货"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeCollectionView/XCUIElementTypeCell[16]', 3000);
22 tapView.click(); 13 tapView.click();
23 - //暂停  
24 - await driver.sleep(IOS_SLEEP_WAIT_TIME);  
25 - //点击19元专区  
26 - tapView = await driver.waitForElementByXPath('//XCUIElementTypeApplication[@name="Yoho!Buy有货"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeWebView/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[3]', 3000); 14 + await driver.sleep(ACTION_PAUSE_TIME);
  15 + console.log("点击返回");
  16 + tapView = await driver.waitForElementByAccessibilityId('yh_base_vc_back_btn', FIND_VIEW_OVER_TIME);
27 tapView.click(); 17 tapView.click();
28 - //暂停  
29 - await driver.sleep(IOS_SLEEP_WAIT_TIME);  
30 - //点击列表第一个  
31 - tapView = 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/XCUIElementTypeOther[1]/XCUIElementTypeScrollView/XCUIElementTypeOther/XCUIElementTypeOther[1]', 3000); 18 + await driver.sleep(ACTION_PAUSE_TIME);
  19 + console.log("点击首页TAB");
  20 + tapView = await driver.waitForElementByXPath('//XCUIElementTypeApplication[@name="Yoho!Buy有货"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther[1]/XCUIElementTypeOther[2]/XCUIElementTypeTabBar/XCUIElementTypeButton[1]', 10000);
32 tapView.click(); 21 tapView.click();
33 - //暂停  
34 - await driver.sleep(IOS_SLEEP_WAIT_TIME);  
35 - // driver.execute('mobile: scroll', { direction: 'down' });  
36 - 22 + await driver.sleep(ACTION_PAUSE_TIME);
  23 + console.log("点击首页顶部搜索框");
  24 + tapView = await driver.waitForElementByAccessibilityId('homeSearch', FIND_VIEW_OVER_TIME);
  25 + tapView.click();
  26 + await driver.sleep(ACTION_PAUSE_TIME);
  27 + console.log("输入指定的拼团SKN");
  28 + tapView = await driver.waitForElementByAccessibilityId('yh_search_vc_search', FIND_VIEW_OVER_TIME);
  29 + tapView.sendKeys("51905716");
  30 + await driver.sleep(ACTION_PAUSE_TIME);
  31 + console.log("点击搜索");
  32 + tapView = await driver.waitForElementByAccessibilityId('Search', FIND_VIEW_OVER_TIME);
  33 + tapView.click();
  34 + await driver.sleep(ACTION_PAUSE_TIME);
  35 + console.log("点击指定的拼团商品");
  36 + tapView = await driver.waitForElementByAccessibilityId('yh_prd_cell_0_1', FIND_VIEW_OVER_TIME);
  37 + tapView.click();
  38 + await driver.sleep(ACTION_PAUSE_TIME);
  39 + console.log("点击分享");
  40 + tapView = await driver.waitForElementByAccessibilityId('shareActionBtn', 3000);
  41 + await tapView.click();
  42 + await driver.sleep(ACTION_PAUSE_TIME);
  43 + console.log("取消分享");
  44 + tapView = await driver.waitForElementByAccessibilityId('取消', 3000);
  45 + await tapView.click();
  46 + await driver.sleep(ACTION_PAUSE_TIME);
  47 + console.log("点击更多");
  48 + tapView = await driver.waitForElementByAccessibilityId('moreActionBtn', 3000);
  49 + tapView.click();
  50 + await driver.sleep(ACTION_PAUSE_TIME);
  51 + console.log("回到首页");
  52 + tapView = await driver.waitForElementByAccessibilityId('yh_quick_jump_menu_1', FIND_VIEW_OVER_TIME);
  53 + tapView.click();
  54 + await driver.sleep(ACTION_PAUSE_TIME);
37 }); 55 });