def reserved_pay(self,
                     reserved_pay_amount,
                     trade_password,
                     use_coupon=None):
        bank = self.get_text(BANK_NAME)
        ASSERT_DICT.update({"bank": bank})
        actual_pay_amount = decimal.Decimal(reserved_pay_amount)

        self.perform_actions(
            RESERVED_PAY_AMOUNT,
            reserved_pay_amount,
            RESERVED_PAY_DATE,
            RESERVED_PAY_DATE_COMPLETED,
        )

        if use_coupon is not None:
            self.perform_actions(USE_COUPON)
            coupon_amount = 1

            self.perform_actions("swipe_accId_//",
                                 SUPER_COMPOSED_COUPON_SWIPE_STOP, 'U', COUPON,
                                 COUPON_CONFIRM)
            actual_pay_amount = (decimal.Decimal(reserved_pay_amount) -
                                 decimal.Decimal(coupon_amount)).quantize(
                                     decimal.Decimal('0.00'))

        self.perform_actions(RESERVED_PAY_CONFIRM)

        if use_coupon is not None:
            self.assert_values(
                str(actual_pay_amount),
                self.get_text(
                    "//UIAStaticText[@label='请输入交易密码']/following-sibling::UIAStaticText[1]"
                ), "==")

        self.perform_actions(TRADE_PASSWORD, trade_password)

        page = huaxin_ui.ui_ios_xjb_3_0.credit_card_add_finish_page.CreditCardAddFinishPage(
            self.web_driver)
        return page
    def make_repay_loan_plan(self,
                             trade_password,
                             last_no,
                             repay_amount,
                             repay_type,
                             other_purpose=None):

        if repay_type == 'car_loan':
            self.perform_actions(REPAY_CAR_LOAN)
        elif repay_type == 'others':
            self.perform_actions(REPAY_OTHERS)
            self.perform_actions(
                # this is just for work-around, no response after type words,
                # first, click word in the keyboard, then input words makes effect.
                OTHER_PURPOSE,
                other_purpose)

            self.perform_actions("accId_UIAKey_t", "accId_UIAButton_Return",
                                 OTHER_PURPOSE, other_purpose)

        self.perform_actions(CHOOSE_BANK_CARD, BANK_CARD % last_no,
                             REPAY_AMOUNT, repay_amount, HIDE_KEYBOARD,
                             REPAY_DATE, SWIPE_BEGIN, REPAY_DATA_SCROLL, 'U',
                             REPAY_DATE_COMPLETE, REPAY_COUNT, SWIPE_BEGIN,
                             REPAY_COUNT_SCROLL, 'U', REPAY_COUNT_COMPLETE)

        date = self.get_text(DATE)
        count = self.get_text(NUMBER)

        ASSERT_DICT.update({"repay_date": date, "repay_count": count})

        self.perform_actions(
            REPAY_HOUSING_LOAN_CONFIRM,
            TRADE_PASSWORD,
            trade_password,
        )

        page = huaxin_ui.ui_ios_xjb_3_0.trade_complete_page.TradeCompletePage(
            self.web_driver)
        return page
Esempio n. 3
0
    def risk_evaluating(self, flag=1):
        self.perform_actions(
            RISK_EVALUATING,
            BEGIN_TESTING,
        )

        for i in range(21):
            print '题目%s' % (i + 1)
            if self.element_exist(C_ANSWER_B):
                self.perform_actions("xpathIOS_UIAImage_%s" % C_ANSWER_B, NEXT)
            else:
                if i != 19 or flag == 0:
                    # 未实名需要选中年龄段
                    self.perform_actions("xpathIOS_UIAStaticText_%s" %
                                         R_ANSWER_B)
                elif i == 19 and flag == 1:
                    # 已实名, 直接点下一题
                    self.perform_actions(NEXT)

        time.sleep(1)
        self.perform_actions(COMMIT)

        result = self.get_text(
            "//UIAStaticText[@label='您的投资类型']/following-sibling::UIAStaticText"
        )
        ASSERT_DICT.update({"risk_result": result})
        self.perform_actions(ANSWER_CONFIRM)

        page = self

        self.assert_values(
            True, self.element_exist('账户信息',
                                     'find_element_by_accessibility_id'))
        self.assert_values(
            ASSERT_DICT['risk_result'],
            self.get_text(
                "//UIAStaticText[@label='风险测评']/following-sibling::UIAStaticText"
            ).split('(')[0])

        return page
    def reserved_pay(self, reserved_pay_amount, trade_password, coupon=None):
        coupon_amount = 0
        self.perform_actions(RESERVED_PAY_AMOUNT, reserved_pay_amount,
                             RESERVED_PAY_DATE, RESERVED_PAY_DATE_MONTH,
                             RESERVED_PAY_DATE_DAY,
                             RESERVED_PAY_DATE_COMPELETED)

        if coupon == 'nonsuperposed':
            self.perform_actions(COUPONS_INFO)

            self.perform_actions(SWIPE_BEGIN,
                                 NONSUPERCOMPOSED_COUPON_SWIPE_STOP, 'U',
                                 COUPONS, COUPONS_CONFIRM)

            coupon_amount_text = self.get_text(
                'com.shhxzq.xjb:id/tv_coupons_module_info',
                'find_element_by_id')
            coupon_amount = float(
                filter(lambda ch: ch in '0123456789.', coupon_amount_text))

        amount_repay = float(reserved_pay_amount) - coupon_amount
        amount_repay_actual = self.get_text(
            'com.shhxzq.xjb:id/tv_amount_repay',
            'find_element_by_id').replace(',', '')
        self.assert_values('%.2f' % amount_repay, amount_repay_actual)

        deduction_date = self.get_text(
            'com.shhxzq.xjb:id/tv_cr_deduction_date', 'find_element_by_id')
        ASSERT_DICT.update({'deduction_date': deduction_date})

        self.perform_actions(RESERVED_PAY_COMFIRM, TRADE_PASSWORD,
                             trade_password)

        page = huaxin_ui.ui_android_xjb_3_0.user_operation_succeed_page.UserOperationSucceedPage(
            self.web_driver)
        return page
    def buy_finance_product(self, mobile, amount, trade_password, cash_management_product=None, points='N',
                            non_superposed_coupon=None, superposed_coupon=None, cash_management='N'):
        ASSERT_DICT.update({'success_flag': '0'})

        if self.element_exist(AMOUNT_LOCATOR):
            self.perform_actions(AMOUNT, amount)
        else:
            self.perform_actions(FUND_BUY_AMOUNT, amount)

        self.perform_actions(HIDE_KEYBOARD)

        if cash_management == 'Y':
            if self.element_exist('(HXShowPaytypeCell)', 'find_element_by_accessibility_id'):
                self.perform_actions(PAYMENT_TYPE)
            else:
                self.perform_actions(PAYMENT_TYPE_FUND)

            # 获取现金管理产品的余额
            left_amount = self.get_text(
                "//UIAStaticText[@label='%s']/following-sibling::UIAStaticText[1]" % cash_management_product)
            left_amount = '%.2f' % float(filter(lambda ch: ch in '0123456789.', left_amount))
            ASSERT_DICT.update({'left_amount': left_amount})
            self.perform_actions(CASH_MANAGEMENT_PRODUCT % cash_management_product)

        if points == 'Y':
            self.perform_actions(USE_POINTS)

            usable_points = self.get_text("//UIASwitch")
            usable_points = '%.2f' % float(filter(lambda ch: ch in '0123456789.', usable_points))
            ASSERT_DICT.update({'usable_points': usable_points})

        if non_superposed_coupon == 'Y':
            self.perform_actions(USE_COUPON)

            self.perform_actions(
                "swipe_accId_//", COUPON_2_STOP, "U",
                COUPON_2,
                COUPON_CONFIRM,
            )

        if superposed_coupon == 'Y':
            self.perform_actions(
                USE_COUPON,
                "swipe_accId_//", COUPON_1_STOP, "U",
                COUPON_1,
                COUPON_1_STOP, COUPON_1_2_STOP, "U",
                COUPON_1_2,
                COUPON_CONFIRM,
            )

        if self.element_exist("(UIButton_确认)", "find_element_by_accessibility_id"):
            self.perform_actions(BUY_CONFIRM)
        else:
            self.perform_actions(BUY_CONFIRM_FUND)

        if self.element_exist(u'您已经购买过定期宝产品,不能购买新手专享产品', 'find_element_by_accessibility_id'):
            self.perform_actions(
                POP_CONFIRM,
            )

            page = self
            return page

        # 当出现购买产品风险高于用户的风险测评结果, 就会出现风险提示, 有些还需要验证码输入.
        if self.element_exist(u'风险提示', 'find_element_by_accessibility_id'):
            self.perform_actions(
                BUY_CONTINUE,
            )

            if self.element_exist("(UIButton_确认)", "find_element_by_accessibility_id"):
                verify_code = MysqlXjbTools().get_sms_verify_code(mobile=mobile, template_id='as_risk_not_match')

                self.perform_actions(
                    MOBILE_CODE, verify_code,
                    VERIFY_CODE_CONFIRM,
                )

        self.perform_actions(
            TRADE_PASSWORD, trade_password,
            BUY_DONE,
        )

        if self.element_exist(u'UIButton_确定', 'find_element_by_accessibility_id'):
            self.perform_actions(
                FIRST_BUY_INFO,
            )

        page = huaxin_ui.ui_ios_xjb_3_0.trade_complete_page.TradeCompletePage(self.web_driver)
        return page
    def risk_evaluating(self, test='开始测试'):
        self.perform_actions(BEGAIN_TESTING % test)
        answer_cautious = ('B', 'D', 'A', 'B', 'A', 'B', 'C', 'E', 'D', 'A',
                           'D', 'A', 'D', 'D', 'A', 'C', 'E', 'B', 'D', 'B',
                           'E', 'A')
        answer_moderate = ('A', 'B', 'A', 'B', 'A', 'B', 'A', 'B', 'A', 'B',
                           'A', 'B', 'A', 'B', 'A', 'C', 'A', 'B', 'D', 'B',
                           'E', 'A')

        if ASSERT_DICT['risk_type'] == '谨慎型' or ASSERT_DICT[
                'risk_type'] == '未测评':
            for i in range(0, 22):
                time.sleep(2)
                self.perform_actions(ANSWER % answer_moderate[i])

                if i == 1:
                    self.perform_actions(NEXT)
        elif ASSERT_DICT['risk_type'] == '稳健型':
            for i in range(0, 22):
                time.sleep(2)
                self.perform_actions(ANSWER % answer_cautious[i])

                if i == 1:
                    self.perform_actions(NEXT)

        # self.perform_actions(ANSWER_1_A)
        # self.perform_actions(ANSWER_1_D)
        # self.perform_actions(NEXT)
        # time.sleep(2)
        # self.perform_actions(ANSWER_2)
        # time.sleep(2)
        # self.perform_actions(ANSWER_3)
        # time.sleep(2)
        # self.perform_actions(ANSWER_4)
        # time.sleep(2)
        # self.perform_actions(ANSWER_5)
        # time.sleep(2)
        # self.perform_actions(ANSWER_6)
        # time.sleep(2)
        # self.perform_actions(ANSWER_7)
        # time.sleep(2)
        # self.perform_actions(ANSWER_8)
        # time.sleep(2)
        # self.perform_actions(ANSWER_9)
        # time.sleep(2)
        # self.perform_actions(ANSWER_10)
        # time.sleep(2)
        # self.perform_actions(ANSWER_11)
        # time.sleep(2)
        # self.perform_actions(ANSWER_12)
        # time.sleep(2)
        # self.perform_actions(ANSWER_13)
        # time.sleep(2)
        #
        # self.perform_actions(ANSWER_14)
        # time.sleep(2)
        # self.perform_actions(ANSWER_15)
        # # self.click_screen(x=0.5, y=0.5, try_time=1)
        # time.sleep(2)
        # self.perform_actions(ANSWER_16)
        # time.sleep(2)
        # self.perform_actions(ANSWER_17)
        # time.sleep(2)
        # self.perform_actions(ANSWER_18)
        # time.sleep(2)
        # self.perform_actions(ANSWER_19)
        # time.sleep(2)
        # self.perform_actions(ANSWER_20)
        # # self.perform_actions(NEXT)
        # time.sleep(2)
        # self.perform_actions(ANSWER_21)

        self.perform_actions(SUBMIT)

        self.assert_values(
            True,
            self.element_exist("//android.view.View[@content-desc='您的投资类型']"))
        risk_type = self.get_attribute(
            "//android.view.View[@content-desc='您的投资类型']/following-sibling::android.view.View[1]"
        )

        self.assert_values(
            True, self.assert_values(ASSERT_DICT['risk_type'], risk_type,
                                     '!='))
        ASSERT_DICT.update({'risk_type': risk_type})

        self.perform_actions(ANSWER_CONFIRM)

        page = huaxin_ui.ui_android_xjb_3_0.user_account_information_page.UserAccountInformationPage(
            self.web_driver)
        time.sleep(2)
        return page
Esempio n. 7
0
    def buy_finance_product(self,
                            amount,
                            trade_password=None,
                            mobile=None,
                            cash_management_product=None,
                            points='N',
                            nonsuperposed_coupon='N',
                            superposed_coupon='N',
                            age=None):
        ASSERT_DICT.update({'success_flag': '0'})

        self.perform_actions(AMOUNT, amount)

        if cash_management_product is not None:
            self.perform_actions(
                PAYMENT_TYPE, SWIPE_BEGIN,
                CASH_MANAGEMENT_PRODUCT_SWIPE_STOP % cash_management_product,
                'U')
            if cash_management_product == 'UI作为支付手段异常测试':
                self.assert_values(
                    '余额不足',
                    self.get_text('com.shhxzq.xjb:id/not_sufficient_prompt',
                                  'find_element_by_id'))
                page = self

                return page
            else:
                self.perform_actions(CASH_MANAGEMENT_PRODUCT %
                                     cash_management_product)

        if points == 'Y':
            self.perform_actions(POINT_SWITCH)
            time.sleep(5)

        # if nonsuperposed_coupon == 'Y':
        #     self.perform_actions(COUPONS_INFO)
        #
        #     time.sleep(10)
        #
        #     self.perform_actions(SWIPE_BEGIN, NONSUPERCOMPOSED_COUPON_SWIPE_STOP, 'U',
        #                          COUPONS,
        #                          COUPONS_CONFIRM)
        #
        # if superposed_coupon == 'Y':
        #     self.perform_actions(COUPONS_INFO)
        #
        #     time.sleep(10)
        #     self.perform_actions(COUPON_SWIPE_BEGAIN, SUPERCOMPOSED_COUPON_SWIPE_STOP, 'U',
        #                          SUPERPOSED_COUPON_1,
        #                          SUPERCOMPOSED_COUPON_SWIPE_BEGAIN, SUPERCOMPOSED_COUPON_SWIPE_STOP_1, 'U',
        #                          SUPERPOSED_COUPON_2,
        #                          COUPONS_CONFIRM)

        self.perform_actions(SWIPE_BEGIN, COMFIRM_BUTTON_SWIPE_STOP, 'U',
                             BUY_CONFIRM)

        xjb_assets = ASSERT_DICT['xjb_total_assets_login']
        if 1 <= float(amount) < float(xjb_assets):
            ASSERT_DICT.update({'success_flag': '1'})

            if age >= 70:
                self.assert_values(
                    '风险提示',
                    self.get_text('com.shhxzq.xjb:id/alertTitle',
                                  'find_element_by_id'))
                self.assert_values(
                    '您已满70周岁,确认继续购买?',
                    self.get_text('com.shhxzq.xjb:id/message',
                                  'find_element_by_id'))
                self.perform_actions(KEEP_BUY)

                time.sleep(2)  # 数据库数据更新有点滞后
                verification_code = self._db.get_sms_verify_code(
                    mobile=mobile, template_id='as_risk_match')

                self.perform_actions(VERIFY_CODE_INPUT, verification_code,
                                     VERIFY_CODE_CONFIRM)

            if float(amount) >= 5000000:
                self.assert_values(
                    '风险提示',
                    self.get_text('com.shhxzq.xjb:id/alertTitle',
                                  'find_element_by_id'))
                self.assert_values(
                    '您的交易金额为500万,确认继续购买?',
                    self.get_text('com.shhxzq.xjb:id/message',
                                  'find_element_by_id'))
                self.perform_actions(KEEP_BUY)
                self.assert_values(
                    '输入短信验证码',
                    self.get_text('com.shhxzq.xjb:id/tv_dialog_title',
                                  'find_element_by_id'))
                self.assert_values(
                    True,
                    self.element_exist(
                        "//android.widget.Button[contains(@text,'后重发')]"))
                self.assert_values(
                    True,
                    self.element_exist("//android.widget.Button[@text='确认']"))

                page = self
            else:
                self.perform_actions(TRADE_PASSWORD, trade_password)

                page = huaxin_ui.ui_android_xjb_3_0.user_operation_succeed_page.UserOperationSucceedPage(
                    self.web_driver)
        elif float(amount) > float(xjb_assets):
            self.perform_actions(CANCEL_BUTTON)
            page = self

        else:
            page = self

        return page
    def redeem_product(self,
                       redeem_amount,
                       trade_password,
                       product_type=None,
                       redeem_type='normal'):
        if redeem_type == 'fast':
            self.perform_actions(FAST_REDEEM)
            self.assert_values(
                True,
                self.element_exist(
                    "//android.widget.TextView[@text='极速卖出']/following-sibling::android.widget.RadioButton[@checked='true']"
                ))
            self.assert_values(
                True,
                self.element_exist(
                    "//android.widget.TextView[contains(@text,'实时到账')]"))
        if product_type == "dhb" or product_type == "vip":
            redeem_max_text = self.get_text(
                'com.shhxzq.xjb:id/tv_dqb_redeem_product_max',
                'find_element_by_id')
            self.perform_actions(REDEEM_AMOUNT, redeem_amount)
        else:
            redeem_max_text = self.get_text(
                'com.shhxzq.xjb:id/fund_redeem_max', 'find_element_by_id')
            self.perform_actions(FUND_REDEEM_AMOUNT, redeem_amount)
            if redeem_type == 'fast':
                self.assert_values(
                    True,
                    self.element_exist(
                        "//android.widget.TextView[contains(@text,'预计到账')]"))
                self.assert_values(
                    True,
                    self.element_exist(
                        "//android.widget.TextView[contains(@text,'说明')]"))

        redeem_max = re.findall(r'(\d{1,3}(,\d{3})*.\d+)',
                                redeem_max_text)[0][0].replace(',', '')
        ASSERT_DICT.update({'success_flag': '0'})

        if float(redeem_amount) > 0:
            if float(redeem_amount) > float(redeem_max):
                if product_type == "dhb" or product_type == "vip":
                    amt = self.get_text(
                        'com.shhxzq.xjb:id/cedt_dqb_redeem_product_amt',
                        'find_element_by_id')
                    amt = '%.2f' % float(
                        filter(lambda ch: ch in '0123456789.', str(amt)))
                    self.assert_values(float(amt), float(redeem_max), '==')
                page = self
            else:
                ASSERT_DICT.update({'success_flag': '1'})
                if product_type == 'dhb':
                    redeem_tips = self.get_text(REDEEM_TIPS,
                                                'find_element_by_id')
                    redeem_amount_expected = re.findall(
                        r'(\d{1,3}(,\d{3})*.\d+)',
                        redeem_tips)[1][0].replace(',', '')
                    ASSERT_DICT.update(
                        {'redeem_amount': redeem_amount_expected})
                self.perform_actions(REDEEM_CONFIRM, TRADE_PASSWORD,
                                     trade_password)

                page = huaxin_ui.ui_android_xjb_3_0.user_operation_succeed_page.UserOperationSucceedPage(
                    self.web_driver)

        else:
            self.perform_actions(REDEEM_CONFIRM)
            page = self

            # if product_type == 'DHB':
            #     self.assert_values('取回', self.get_text(self.page_title, 'find_element_by_id'))
            # else:
            #     self.assert_values('卖出', self.get_text(self.page_title, 'find_element_by_id'))

        return page
Esempio n. 9
0
    def recharge(self,
                 recharge_amount,
                 trade_password,
                 nonsuperposed_coupon=None,
                 type='recharge'):
        coupon_amount = 0
        page = self
        self.perform_actions(RECHARGE_AMOUNT, recharge_amount)

        if nonsuperposed_coupon is not None:
            # self.go_to_use_coupon_page()
            # self.coupon.select_coupon(return_page='RechargePage')
            self.perform_actions(COUPONS_INFO)

            self.perform_actions(SWIPE_BEGIN,
                                 NONSUPERCOMPOSED_COUPON_SWIPE_STOP, 'U',
                                 COUPONS, COUPONS_CONFIRM)

            coupon_amount_text = self.get_text(
                'com.shhxzq.xjb:id/tv_coupons_module_info',
                'find_element_by_id')
            coupon_amount = float(
                filter(lambda ch: ch in '0123456789.', coupon_amount_text))

        if type == 'recharge':
            amount_repay = float(recharge_amount) - coupon_amount
            amount_repay_actual = self.get_text(
                'com.shhxzq.xjb:id/tv_amount_repay',
                'find_element_by_id').replace(',', '')
            self.assert_values('%.2f' % amount_repay, amount_repay_actual)

        self.perform_actions(SWIPE_BEGIN, CONFIRM_BUTTON_SWIPE_STOP, 'U')
        self.perform_actions(RECHARGE_CONFIRM_BUTTON)

        if float(recharge_amount) >= 0.01 and float(
                recharge_amount) <= 99999999.99:
            self.perform_actions(
                TRADE_PASSWORD,
                trade_password,
            )

            if type == 'recharge':
                page = huaxin_ui.ui_android_xjb_3_0.user_operation_succeed_page.UserOperationSucceedPage(
                    self.web_driver)

                ASSERT_DICT.update({'success_flag': '1'})

            elif type == 'resign':
                self.assert_values(
                    '提示',
                    self.get_text('com.shhxzq.xjb:id/alertTitle',
                                  'find_element_by_id'))
                self.assert_values(
                    '交易失败,请重新进行签约',
                    self.get_text('com.shhxzq.xjb:id/message',
                                  'find_element_by_id'))
                self.perform_actions(SIGN)
                page = huaxin_ui.ui_android_xjb_3_0.bank_card_resign_page.BankCardResignPage(
                    self.web_driver)

        else:
            ASSERT_DICT.update({'success_flag': '0'})
            if float(recharge_amount) < 0.01:
                self.verify_page_title()
            else:
                self.assert_values(
                    '前往', self.get_text(GO_AHEAD, 'find_element_by_id'))
                self.perform_actions(CANCEL)

        return page
Esempio n. 10
0
    def buy_fund_product(self, amount, mobile, trade_password, points='N', nonsuperposed_coupon='N',
                         superposed_coupon='N'):

        if self.element_exist(u'已售罄', 'find_element_by_accessibility_id'):
            page = self

            return page

        self.perform_actions(
            BUY_NOW,
            BUY_NOW_2,
            BUY_NOW_3,
            BUY_NOW_4,
            BUY_NOW_5,
        )

        # 当出现购买产品风险高于用户的风险测评结果, 就会出现风险提示, 有些还需要验证码输入.
        if self.element_exist(u'风险提示', 'find_element_by_accessibility_id'):
            self.perform_actions(
                BUY_CONTINUE,
            )

        self.perform_actions(
            BUY_AMOUNT, amount,
            HIDE_KEYBOARD
        )

        if not points == 'N':
            self.perform_actions(
                USE_POINTS,
            )

            usable_points = self.get_text("//UIAStaticText[contains(@label, '可用积分')]")
            usable_points = '%.2f' % float(filter(lambda ch: ch in '0123456789.', usable_points))
            ASSERT_DICT.update({'usable_points': usable_points})

        if not nonsuperposed_coupon == 'N':
            self.perform_actions(
                USE_COUPON,
                "swipe_accId_//", COUPON_2_STOP, "U",
                COUPON_2,
                COUPON_CONFIRM,
            )

        if not superposed_coupon == 'N':
            self.perform_actions(
                USE_COUPON,
                "swipe_accId_//", COUPON_1_STOP, "U",
                COUPON_1,
                COUPON_1_STOP, COUPON_1_2_STOP, "U",
                COUPON_1_2,
                COUPON_CONFIRM,
            )

        self.perform_actions(
            BUY_CONFIRM,
        )

        # 当出现购买产品风险高于用户的风险测评结果, 就会出现风险提示, 有些还需要验证码输入.
        if self.element_exist(u'风险提示', 'find_element_by_accessibility_id'):
            self.perform_actions(
                BUY_CONTINUE,
            )

            verify_code = MysqlXjbTools().get_sms_verify_code(mobile=mobile, template_id='as_risk_not_match')

            self.perform_actions(
                MOBILE_CODE, verify_code,
                VERIFY_CODE_CONFIRM,
                TRADE_PASSWORD, trade_password,
            )

        else:
            self.perform_actions(
                TRADE_PASSWORD, trade_password,
                BUY_DONE,
            )

            if self.element_exist(u'UIButton_确定', 'find_element_by_accessibility_id'):
                self.perform_actions(
                    FIRST_BUY_INFO,
                )

        page = huaxin_ui.ui_ios_xjb_3_0.trade_complete_page.TradeCompletePage(self.web_driver)

        return page
Esempio n. 11
0
    def income_calculator(self, amount, product_type='DHB'):
        min_purchase_amount = '0'
        max_purchase_amount = '0'
        max_purchase_amount_text = '0'
        if product_type == 'DHB':
            max_purchase_amount_text = '50,000'
            min_purchase_amount_text = self.get_text(
                'com.shhxzq.xjb:id/tv_product_details_pruchaseamt',
                'find_element_by_id')
            min_purchase_amount = filter(lambda ch: ch in '0123456789.',
                                         min_purchase_amount_text)
            max_purchase_amount = filter(lambda ch: ch in '0123456789.',
                                         max_purchase_amount_text)
        elif product_type == 'VIP':
            max_purchase_amount_text = '100,000'
            min_purchase_amount_text = self.get_text(
                "//android.widget.TextView[@text='起投金额']/following-sibling::android.widget.TextView[1]"
            )
            min_purchase_amount = filter(lambda ch: ch in '0123456789.',
                                         min_purchase_amount_text)
            max_purchase_amount = filter(lambda ch: ch in '0123456789.',
                                         max_purchase_amount_text)
        ASSERT_DICT.update({'min': float(min_purchase_amount)})
        ASSERT_DICT.update({'max': float(max_purchase_amount)})

        self.perform_actions(INCOME_CALCULATOR)

        self.assert_values(
            True,
            self.element_exist("//android.widget.TextView[@text='收益计算器']"))
        self.assert_values(
            True,
            self.element_exist("//android.widget.TextView[@text='买入金额']"))
        if product_type == 'DHB':
            self.assert_values(
                '预估累计收益(12个月)',
                self.get_text('com.shhxzq.xjb:id/forecast_profit_title',
                              'find_element_by_id'))
        elif product_type == 'VIP':
            self.assert_values(
                '预估累计收益',
                self.get_text('com.shhxzq.xjb:id/forecast_profit_title',
                              'find_element_by_id'))
            self.assert_values(
                True,
                self.element_exist(
                    "//android.widget.TextView[@text='同类货币基金']"))

        default_amount = self.get_text('com.shhxzq.xjb:id/amount_edit',
                                       'find_element_by_id')
        self.assert_values(min_purchase_amount, default_amount)

        if product_type == 'DHB':
            key_code_dict = {
                '1': [0.185, 0.534],
                '2': [0.5, 0.534],
                '3': [0.815, 0.534],
                '4': [0.185, 0.604],
                '5': [0.5, 0.604],
                '6': [0.815, 0.604],
                '7': [0.185, 0.674],
                '8': [0.5, 0.674],
                '9': [0.815, 0.674],
                '.': [0.185, 0.75],
                '0': [0.5, 0.75],
                'delete': [0.815, 0.75],
            }

        elif product_type == 'VIP':
            key_code_dict = {
                '1': [0.185, 0.663],
                '2': [0.5, 0.663],
                '3': [0.815, 0.663],
                '4': [0.185, 0.736],
                '5': [0.5, 0.736],
                '6': [0.815, 0.736],
                '7': [0.185, 0.807],
                '8': [0.5, 0.807],
                '9': [0.815, 0.807],
                '.': [0.185, 0.888],
                '0': [0.5, 0.888],
                'delete': [0.815, 0.888],
            }

        # 删除默认值
        for arg in min_purchase_amount:
            self.click_screen(x=key_code_dict['delete'][0],
                              y=key_code_dict['delete'][1])

        # 输入购买金额
        for arg in amount:
            self.click_screen(x=key_code_dict[arg][0], y=key_code_dict[arg][1])

        # 购买金额小于最小值
        if float(amount) < float(min_purchase_amount):
            self.assert_values(
                min_purchase_amount + '元起投',
                self.get_text('com.shhxzq.xjb:id/bt_ok', 'find_element_by_id'))
        elif float(min_purchase_amount) < float(amount) <= float(
                max_purchase_amount):  # 购买金额正常
            self.assert_values(
                '按此金额买入',
                self.get_text('com.shhxzq.xjb:id/bt_ok', 'find_element_by_id'))
        elif float(amount) > float(max_purchase_amount):  # 购买金额大于最大值
            self.assert_values(
                '最高买入' + max_purchase_amount_text + '元',
                self.get_text('com.shhxzq.xjb:id/bt_ok', 'find_element_by_id'))
        page = self

        return page
Esempio n. 12
0
    def buy_fund_product(self,
                         amount=None,
                         trade_password=None,
                         points='N',
                         coupon=None,
                         risk=None,
                         user_type=None,
                         phone_number=None,
                         cash_management_product=None,
                         age=None):
        ASSERT_DICT.update({'success_flag': '0'})
        if risk == 'high' and user_type == 'conservative':
            self.assert_values(
                '风险提示',
                self.get_text('com.shhxzq.xjb:id/alertTitle',
                              'find_element_by_id'))
            self.assert_values(
                '再考虑一下',
                self.get_text('com.shhxzq.xjb:id/button1',
                              'find_element_by_id'))
            # self.assert_values('重新测试', self.get_text('com.shhxzq.xjb:id/button2', 'find_element_by_id'))
            self.assert_values(
                '去测试',
                self.get_text('com.shhxzq.xjb:id/button2',
                              'find_element_by_id'))
            self.perform_actions(THINK)

            page = huaxin_ui.ui_android_xjb_3_0.fund_page_fund_detail.FundPageFundDetail(
                self.web_driver)
            return page

        self.perform_actions(BUY_AMOUNT, amount)

        if cash_management_product is not None:
            self.perform_actions(
                PAYMENT_TYPE, SWIPE_BEGIN,
                CASH_MANAGEMENT_PRODUCT_SWIPE_STOP % cash_management_product,
                'U', CASH_MANAGEMENT_PRODUCT % cash_management_product)

        if points == 'Y':
            self.perform_actions(POINT_SWITCH)

            time.sleep(5)

        if coupon is not None:
            self.go_to_use_coupon_page(coupon=coupon)

        self.perform_actions(SWIPE_BEGIN, COMFIRM_BUTTON_SWIPE_STOP, 'U')

        self.perform_actions(BUY_CONFIRM)

        if risk == 'high':
            if user_type == 'moderate':
                self.assert_values(
                    '风险提示',
                    self.get_text('com.shhxzq.xjb:id/alertTitle',
                                  'find_element_by_id'))
                self.perform_actions(BUY)
                # self.perform_actions(GET_VERIFICATION_CODE)
                self.assert_values(
                    '输入短信验证码',
                    self.get_text('com.shhxzq.xjb:id/tv_dialog_title',
                                  'find_element_by_id'))
                time.sleep(1)
                verification_code = MysqlXjbTools().get_sms_verify_code(
                    mobile=phone_number, template_id='as_risk_not_match')
                self.perform_actions(VERIFY_CODE_INPUT, verification_code)
            elif user_type == 'radical':
                if age >= 70:
                    if float(amount) >= 5000000:  # 激进型用户,年龄大于70岁,购买金额超过500万
                        self.assert_values(
                            '风险提示',
                            self.get_text('com.shhxzq.xjb:id/alertTitle',
                                          'find_element_by_id'))
                        self.assert_values(
                            '您购买的是高风险产品、您已满70周岁且交易金额超过500万,确认继续购买?',
                            self.get_text('com.shhxzq.xjb:id/message',
                                          'find_element_by_id'))
                        self.assert_values(
                            '再考虑一下',
                            self.get_text('com.shhxzq.xjb:id/button1',
                                          'find_element_by_id'))
                        self.assert_values(
                            '继续买入',
                            self.get_text('com.shhxzq.xjb:id/button2',
                                          'find_element_by_id'))
                        self.perform_actions(BUY)
                        self.assert_values(
                            '输入短信验证码',
                            self.get_text('com.shhxzq.xjb:id/tv_dialog_title',
                                          'find_element_by_id'))
                        self.assert_values(
                            True,
                            self.element_exist(
                                "//android.widget.Button[contains(@text,'后重发')]"
                            ))
                        self.assert_values(
                            True,
                            self.element_exist(
                                "//android.widget.Button[@text='确认']"))
                else:
                    self.assert_values(
                        '风险提示',
                        self.get_text('com.shhxzq.xjb:id/alertTitle',
                                      'find_element_by_id'))
                    self.assert_values(
                        '您购买的是高风险产品,确认继续购买?',
                        self.get_text('com.shhxzq.xjb:id/message',
                                      'find_element_by_id'))
                    self.assert_values(
                        '再考虑一下',
                        self.get_text('com.shhxzq.xjb:id/button1',
                                      'find_element_by_id'))
                    self.assert_values(
                        '继续买入',
                        self.get_text('com.shhxzq.xjb:id/button2',
                                      'find_element_by_id'))
                    self.perform_actions(BUY)
                    # self.perform_actions(GET_VERIFICATION_CODE)
                    self.assert_values(
                        '输入短信验证码',
                        self.get_text('com.shhxzq.xjb:id/tv_dialog_title',
                                      'find_element_by_id'))
                    verification_code = MysqlXjbTools().get_sms_verify_code(
                        mobile=phone_number, template_id='as_risk_match')
                    self.perform_actions(VERIFY_CODE_INPUT, verification_code)

            self.perform_actions(COMFIRM)

        # elif risk == 'middle_high':
        #     if user_type == 'cautious':
        #         self.assert_values('风险提示', self.get_text('com.shhxzq.xjb:id/alertTitle', 'find_element_by_id'))
        #         self.assert_values('再考虑一下', self.get_text('com.shhxzq.xjb:id/button1', 'find_element_by_id'))
        #         self.assert_values('继续买入', self.get_text('com.shhxzq.xjb:id/button2', 'find_element_by_id'))
        #         self.perform_actions(BUY)

        if 1 <= float(amount) < 50000:
            self.perform_actions(
                TRADE_PASSWORD,
                trade_password,
            )
            ASSERT_DICT.update({'success_flag': '1'})
            page = huaxin_ui.ui_android_xjb_3_0.user_operation_succeed_page.UserOperationSucceedPage(
                self.web_driver)

        elif float(amount) >= 100000000:
            page = self
            self.perform_actions(CANCEL_BUTTON)

        else:
            page = self
        return page
Esempio n. 13
0
    def buy_dqb_product(self,
                        product_name,
                        amount,
                        trade_password,
                        mobile,
                        points='N',
                        nonsuperposed_coupon='N',
                        superposed_coupon='N'):
        # if not product_name is None:
        #     self.perform_actions(
        #         REGULAR_START, REGULAR_PRODUCT_STOP % product_name, 'U',
        #                        REGULAR_PRODUCT % product_name,
        #     )

        # self.perform_actions(DHB_PRODUCT)

        # if self.element_exist(u'已售罄', 'find_element_by_accessibility_id'):
        #     page = self
        #
        #     return page

        self.perform_actions(BUY_NOW, BUY_NOW_2, BUY_NOW_3, AMOUNT, amount,
                             HIDE_KEYBOARD)

        if not points == 'N':
            self.perform_actions(USE_POINTS, )

            usable_points = self.get_text("//UIASwitch")
            usable_points = '%.2f' % float(
                filter(lambda ch: ch in '0123456789.', usable_points))
            ASSERT_DICT.update({'usable_points': usable_points})

        if not nonsuperposed_coupon == 'N':
            self.perform_actions(USE_COUPON)

            self.perform_actions(
                "swipe_accId_//",
                COUPON_2_STOP,
                "U",
                COUPON_2,
                COUPON_CONFIRM,
            )

        if not superposed_coupon == 'N':
            self.perform_actions(
                USE_COUPON,
                "swipe_accId_//",
                COUPON_1_STOP,
                "U",
                COUPON_1,
                COUPON_1_STOP,
                COUPON_1_2_STOP,
                "U",
                COUPON_1_2,
                COUPON_CONFIRM,
            )

        self.perform_actions(BUY_CONFIRM, )

        if self.element_exist(u'您已经购买过定期宝产品,不能购买新手专享产品',
                              'find_element_by_accessibility_id'):
            self.perform_actions(POP_CONFIRM, )

            page = self

            return page

        # 当出现购买产品风险高于用户的风险测评结果, 就会出现风险提示, 有些还需要验证码输入.
        if self.element_exist(u'风险提示', 'find_element_by_accessibility_id'):
            self.perform_actions(BUY_CONTINUE, )

            verify_code = MysqlXjbTools().get_sms_verify_code(
                mobile=mobile, template_id='as_risk_not_match')

            self.perform_actions(
                MOBILE_CODE,
                verify_code,
                VERIFY_CODE_CONFIRM,
                TRADE_PASSWORD,
                trade_password,
            )

        else:
            self.perform_actions(
                TRADE_PASSWORD,
                trade_password,
                BUY_DONE,
            )

            if self.element_exist(u'UIButton_确定',
                                  'find_element_by_accessibility_id'):
                self.perform_actions(FIRST_BUY_INFO, )

        page = huaxin_ui.ui_ios_xjb_3_0.trade_complete_page.TradeCompletePage(
            self.web_driver)

        return page
    def buy_high_end_product(self,
                             product_name,
                             amount,
                             trade_password,
                             points='N',
                             nonsuperposed_coupon='N',
                             superposed_coupon='N',
                             mobile=None):

        if self.element_exist(u'已售罄', 'find_element_by_accessibility_id'):
            page = self

            return page

        self.perform_actions(HIGH_END_START,
                             HIGH_END_PRODUCT_STOP % product_name, 'U',
                             HIGH_END_PRODUCT % product_name, BUY_NOW,
                             BUY_NOW_2, BUY_NOW_3)

        # 当出现购买产品风险高于用户的风险测评结果, 就会出现风险提示, 有些还需要验证码输入.
        if self.element_exist(u'风险提示', 'find_element_by_accessibility_id'):
            self.perform_actions(BUY_CONTINUE, )

        title = self.get_text("//UIAStaticText[@label='买入']")
        self.assert_values('买入', title)

        self.perform_actions(AMOUNT, amount, HIDE_KEYBOARD)

        if not points == 'N':
            self.perform_actions(USE_POINTS, )
            usable_points = self.get_text("//UIASwitch")
            usable_points = '%.2f' % float(
                filter(lambda ch: ch in '0123456789.', usable_points))
            ASSERT_DICT.update({'usable_points': usable_points})

            # amount_new = float(amount) - float(ASSERT_DICT['usable_points'])

            # label = self.get_text('(btnNext)', 'find_element_by_accessibility_id')
            # self.assert_values('¥', label)
            # self.perform_actions('assert_IOS_(btnNext)[@label=¥]')
            # self.perform_actions('assert_IOS_(btnNext)[@label=确认买入]')
            # self.perform_actions('assert_IOS_(btnNext)[@label==%.2f]' % float(amount_new))

        if not nonsuperposed_coupon == 'N':
            self.perform_actions(
                USE_COUPON,
                "swipe_accId_//",
                COUPON_2_STOP,
                "U",
                COUPON_2,
                COUPON_CONFIRM,
            )

        if not superposed_coupon == 'N':
            self.perform_actions(
                USE_COUPON,
                "swipe_accId_//",
                COUPON_1_STOP,
                "U",
                COUPON_1,
                COUPON_1_STOP,
                "swipe_xpathIOS_//UIATableCell/UIAStaticText[@label='满10减1所有产品可叠加' and @visible='true'][2]",
                "U",
                COUPON_1_2,
                COUPON_CONFIRM,
            )

        self.perform_actions(BUY_CONFIRM)

        if self.element_exist(u'风险提示', 'find_element_by_accessibility_id'):
            self.perform_actions(BUY_CONTINUE, )
            verify_code = MysqlXjbTools().get_sms_verify_code(
                mobile=mobile, template_id='as_risk_not_match')

            self.perform_actions(
                MOBILE_CODE,
                verify_code,
                VERIFY_CODE_CONFIRM,
            )

        self.perform_actions(TRADE_PASSWORD, trade_password)

        page = huaxin_ui.ui_ios_xjb_3_0.trade_complete_page.TradeCompletePage(
            self.web_driver)

        return page