Пример #1
0
def step_impl(context, webapp_user_name, webapp_owner_name, category_name):
    home_page = WAHomePage(context.webapp_driver)
    home_page.load()

    product_list_page = home_page.enter_product_list_page()
    if category_name != u'全部':
        product_list_page.switch_category(category_name)
    context.page = product_list_page
Пример #2
0
def step_impl(context, webapp_user_name, webapp_owner_name, product_name):
    home_page = WAHomePage(context.webapp_driver)
    home_page.load()

    product_list_page = home_page.enter_product_list_page()
    product_detail_page = product_list_page.enter_product_detail_page(
        product_name)

    context.page = product_detail_page
def step_impl(context, webapp_user_name, webapp_owner_name, integral_count):
    home_page = WAHomePage(context.webapp_driver)
    home_page.load()

    user_center_page = home_page.enter_user_center_page()
    actual = user_center_page.get_integral()

    expected = integral_count

    context.tc.assertEquals(expected, actual)
def step_impl(context, webapp_user_name, webapp_owner_name):
    home_page = WAHomePage(context.webapp_driver)
    home_page.load()

    user_center_page = home_page.enter_user_center_page()
    integral_log_page = user_center_page.enter_integral_log_page()
    actual = integral_log_page.get_logs()

    expected = json.loads(context.text)

    context.tc.assertEquals(expected, actual)
Пример #5
0
def step_impl(context, webapp_user_name, product_name):
    page = getattr(context, 'page', None)
    if page and page.is_shopping_cart_page():
        #在购物车页面再次获取信息时,不需要重新进入
        shopping_cart_page = page
    else:
        home_page = WAHomePage(context.webapp_driver)
        home_page.load()

        product_list_page = home_page.enter_product_list_page()
        shopping_cart_page = user_center_page.enter_shopping_cart_page()
    shopping_cart_page.delete_product(product_name)
Пример #6
0
def step_impl(context, webapp_user_name):
    page = getattr(context, 'page', None)
    if page and page.is_shopping_cart_page():
        #在购物车页面再次获取信息时,不需要重新进入
        shopping_cart_page = page
    else:
        home_page = WAHomePage(context.webapp_driver)
        home_page.load()
        product_list_page = home_page.enter_product_list_page()
        shopping_cart_page = product_list_page.enter_shopping_cart_page()
    # if getattr(context, 'text', None):
    # 	args = json.loads(context.text)
    # 	products = args['products']
    # 	if products == 'all':
    # 		shopping_cart_page.select_products('all')
    # 	else:
    # 		for product in products:
    # 			shopping_cart_page.select_products(product['name'])
    # 			shopping_cart_page.increase_purchase_count_to(product['name'], product['count'])
    # else:
    # 	args = {}

    #判断是否需要填充默认的收货地址
    has_ship_info = __has_ship_info(webapp_user_name,
                                    context.webapp_owner_name)
    # if (not has_ship_info) and (not 'ship_info' in args):
    # 	#数据库中无ship info,且购买参数中也无ship info,创建默认ship info
    # 	__create_default_ship_info(webapp_user_name, context.webapp_owner_name)
    # 	has_ship_info = True

    #获得提交后的page,可能情况:
    #1. 购物车page
    #2. 编辑收货地址page
    #3. 编辑订单page
    page = shopping_cart_page.submit_order()

    if page.is_shopping_cart_page():
        context.page = page
    else:
        if not has_ship_info:
            edit_ship_address_page = WAEditShipAddressPage(
                context.webapp_driver)
            edit_ship_address_page.input_ship_info(args['ship_info'])
            edit_ship_address_page.click_submit_button()
            edit_order_page = WAEditOrderPage(context.webapp_driver)
            context.page = edit_order_page
        else:
            edit_order_page = WAEditOrderPage(context.webapp_driver)
            context.page = edit_order_page
Пример #7
0
def step_impl(context, webapp_user_name, webapp_owner_name):
    products = json.loads(context.text)

    for product in products:
        home_page = WAHomePage(context.webapp_driver)
        home_page.load()

        product_list_page = home_page.enter_product_list_page()
        product_detail_page = product_list_page.enter_product_detail_page(
            product['name'])
        product_detail_page.show_purchase_panel()
        #这里必须先选择规格,再调整数量
        if product.get('model', None):
            product_detail_page.select_model(product['model'])
        if product.get('count', None):
            product_detail_page.increase_purchase_count_to(product['count'])
        product_detail_page.add_to_shopping_cart()
Пример #8
0
def step_impl(context, webapp_user_name):
    page = getattr(context, 'page', None)
    if page and page.is_shopping_cart_page():
        #在购物车页面再次获取信息时,不需要重新进入
        shopping_cart_page = page
    else:
        home_page = WAHomePage(context.webapp_driver)
        home_page.load()
        product_list_page = home_page.enter_product_list_page()
        shopping_cart_page = product_list_page.enter_shopping_cart_page()
        context.page = shopping_cart_page
    actual = {
        "product_groups": shopping_cart_page.get_product_groups(),
        "total_product_count": shopping_cart_page.get_total_product_count(),
        "total_price": shopping_cart_page.get_total_price()
    }

    expected = json.loads(context.text)
    bdd_util.assert_dict(expected, actual)
Пример #9
0
def step_impl(context, webapp_user_name, webapp_owner_name):
    if context.text:
        args = json.loads(context.text)
    else:
        args = {}

    home_page = WAHomePage(context.webapp_driver)
    home_page.load()

    product = args['product']
    product_list_page = home_page.enter_product_list_page()
    product_detail_page = product_list_page.enter_product_detail_page(
        product['name'])
    product_detail_page.show_purchase_panel()
    product_detail_page.increase_purchase_count_to(product['count'])
    product_detail_page.do_purchase()

    edit_order_page = WAEditOrderPage(context.webapp_driver)
    context.page = edit_order_page
Пример #10
0
def step_impl(context, webapp_user_name, pay_interface_type,
              webapp_owner_name):
    if context.text:
        args = json.loads(context.text)
    else:
        args = {}

    if webapp_owner_name == u'订单中':
        edit_order_page = context.page
    else:
        home_page = WAHomePage(context.webapp_driver)
        home_page.load()

        product = args['products'][0]
        product_list_page = home_page.enter_product_list_page()
        product_detail_page = product_list_page.enter_product_detail_page(
            product['name'])
        product_detail_page.show_purchase_panel()
        product_detail_page.increase_purchase_count_to(product['count'])
        has_ship_info = __has_ship_info(webapp_user_name, webapp_owner_name)
        if (not has_ship_info) and (not 'ship_name' in args):
            #数据库中无ship info,且购买参数中也无ship info,创建默认ship info
            __create_default_ship_info(webapp_user_name, webapp_owner_name)
            has_ship_info = True
        product_detail_page.do_purchase()

        #判断是否有收货地址
        if has_ship_info:
            edit_order_page = WAEditOrderPage(context.webapp_driver)
        else:
            edit_ship_address_page = WAEditShipAddressPage(
                context.webapp_driver)
            edit_ship_address_page.input_ship_info(args)
            edit_ship_address_page.click_submit_button()
            edit_order_page = WAEditOrderPage(context.webapp_driver)

    #使用积分
    if args.get('use_integral', False):
        edit_order_page.use_integral()

    #使用优惠券
    if 'coupon' in args:
        if args['coupon_type'] == u'选择':
            edit_order_page.use_coupon(args['coupon'])
        else:
            edit_order_page.input_coupon(args['coupon'])

    #输入商家留言
    if 'customer_message' in args:
        edit_order_page.input_customer_message(
            args['customer_message'].strip())

    if edit_order_page.is_encounter_error():
        #编辑订单过程中出错
        context.error_message = edit_order_page.get_error_message()
    else:
        edit_order_page.select_pay_interface(pay_interface_type)
        page = edit_order_page.submit_order()
        if page.is_webapp_pay_interface_list_page():
            #进入订单支付
            if pay_interface_type == u'不支付':
                context.page = page
                pay_result_page = None
            else:
                pay_interface_list_page = page
                pay_result_page = pay_interface_list_page.select_pay_interface(
                    pay_interface_type)
        elif page.is_webapp_pay_result_page():
            #订单直接支付完成
            pay_result_page = page
        else:
            #提交订单出错
            pay_result_page = None
            context.error_message = page.err_message
        context.pay_result_page = pay_result_page