case_product_detail.js
5 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
const wd = require('wd');
const {describe} = require('../../libs/driver');
const {ANDROID_PRODUCT_DETAIL} = require('../../scene-types/scene-types');
const {FIND_VIEW_OVER_TIME, ACTION_PAUSE_TIME} = require('../../config/constant');
describe(ANDROID_PRODUCT_DETAIL, 'Android 商品详情进入用例', async(driver) => {
// 暂停
await driver.sleep(ACTION_PAUSE_TIME);
//点击首页的tab bar 分类按钮
let categoryTab = await driver.waitForElementById('com.yoho:id/tabMain_radioImage_sort_rl', 10000);
await categoryTab.click();
// 暂停
await driver.sleep(ACTION_PAUSE_TIME);
//点击分类中的第一个子分类:比如男装
let categorySubSortFirst = await driver.waitForElementByXPath("/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[1]/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout[1]/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.LinearLayout[1]/android.widget.TextView", FIND_VIEW_OVER_TIME);
await categorySubSortFirst.click();
//点击分类中的 其中一个品类
let category = await driver.waitForElementByXPath("/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[1]/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout[1]/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.view.ViewGroup/android.support.v7.widget.RecyclerView/android.widget.LinearLayout[1]/android.widget.GridView/android.widget.RelativeLayout[1]/android.widget.ImageView", FIND_VIEW_OVER_TIME);
await category.click();
// 暂停
await driver.sleep(ACTION_PAUSE_TIME);
//点击其中的一个商品
let firstProduct = await driver.waitForElementByXPath("/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[1]/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.ScrollView/android.widget.LinearLayout/android.support.v4.view.ViewPager/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[1]/android.widget.LinearLayout/android.widget.FrameLayout/android.support.v7.widget.RecyclerView/android.widget.RelativeLayout[1]/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.ImageView[1]");
await firstProduct.click();
// 暂停
await driver.sleep(ACTION_PAUSE_TIME);
//点击分享
let tapShare = await driver.waitForElementById('com.yoho:id/sharebtn', FIND_VIEW_OVER_TIME);
await tapShare.click();
//取消分享
let cancelShare = await driver.waitForElementById('com.yoho:id/share_cancle_lly', FIND_VIEW_OVER_TIME);
await cancelShare.click();
//点击加入购物车(弹出尺码选择框)
let addToCart = await driver.waitForElementById('com.yoho:id/product_detail_add', FIND_VIEW_OVER_TIME);
await addToCart.click();
//选择颜色
/*let chooseColor = await driver.waitForElementByXPath('/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.ScrollView/android.widget.LinearLayout/android.widget.LinearLayout[1]/android.view.ViewGroup/android.widget.LinearLayout/android.widget.TextView', FIND_VIEW_OVER_TIME);
await chooseColor.click();*/
//选择尺码
let chooseSize = await driver.waitForElementByXPath('/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.ScrollView/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.view.ViewGroup/android.widget.LinearLayout[2]/android.widget.TextView', FIND_VIEW_OVER_TIME);
await chooseSize.click();
//加一下
let chooseAdd = await driver.waitForElementById('com.yoho:id/tv_pro_info_num_add', FIND_VIEW_OVER_TIME);
await chooseAdd.click();
//减一下
let chooseReduce = await driver.waitForElementById('com.yoho:id/tv_pro_info_num_sub', FIND_VIEW_OVER_TIME);
await chooseReduce.click();
//点击加入购物车
let add = await driver.waitForElementById('com.yoho:id/btn_pro_info_submit', FIND_VIEW_OVER_TIME);
await add.click();
//进入购物车
let goToShopCart = await driver.waitForElementById('com.yoho:id/activity_product_detail_sv', FIND_VIEW_OVER_TIME);
await goToShopCart.click();
// 暂停
await driver.sleep(ACTION_PAUSE_TIME);
//返回商品详情
let backPrdDetail = await driver.waitForElementById('com.yoho:id/back_imgbtn', FIND_VIEW_OVER_TIME);
await backPrdDetail.click();
});