def verify_xjb_total_assets(self, amount, operate_type=None): xjb_total_assets_content = self.get_text(XJB_TOTAL_ASSETS, 'find_element_by_id') xjb_total_assets_actual = '%.2f' % float( filter(lambda ch: ch in '0123456789.', xjb_total_assets_content)) if operate_type is None: xjb_total_assets_expected = float( Decimal( float( str(ASSERT_DICT['xjb_total_assets_login']).replace( ',', ''))).quantize( Decimal('0.00'))) + float(amount) else: # xjb_total_assets_login='******' % float(filter(lambda ch: ch in '0123456789.', xjb_total_assets_content)) # xjb_total_assets_expected = float(xjb_total_assets_login)- float(amount) xjb_total_assets_expected = float( Decimal( float( str(ASSERT_DICT['xjb_total_assets_login']).replace( ',', ''))).quantize( Decimal('0.00'))) - float(amount) ASSERT_DICT.update({'xjb_total_assets': xjb_total_assets_expected}) self.assert_values('%.2f' % xjb_total_assets_expected, xjb_total_assets_actual, '==') page = self return page
def repay(self, repay_amount, trade_password, non_superposed_coupon=None): self.perform_actions(CREDIT_CARD_SELECTED, REPAY_AMOUNT, repay_amount) bank = self.get_text(BANK_NAME) ASSERT_DICT.update({"bank": bank}) if non_superposed_coupon is not None: self.perform_actions(USE_COUPON) coupon_amount = 1 self.perform_actions("swipe_accId_//", NON_SUPER_COMPOSED_COUPON_SWIPE_STOP, 'U', COUPON, COUPON_CONFIRM) actual_pay_amount = (decimal.Decimal(repay_amount) - decimal.Decimal(coupon_amount)).quantize( decimal.Decimal('0.00')) self.assert_values( str(actual_pay_amount), self.get_text( "//UIAStaticText[@label='应付金额']/following-sibling::UIAStaticText" ), '==') self.perform_actions(REPAY_CONFIRM, TRADE_PASSWORD, trade_password) page = huaxin_ui.ui_ios_xjb_3_0.credit_card_add_finish_page.CreditCardAddFinishPage( self.web_driver) return page
def pledge_repay(self, pledge_repay_amount, trade_password): pledge_repay_amount_require_text = self.get_text( "//UIAStaticText[contains(@label, '最低还款本金为')]") pledge_repay_amount_min = float( re.findall(r'(\d{1,3}(,\d{3})*.\d+)', pledge_repay_amount_require_text)[0][0].replace( ',', '')) pledge_repay_amount_threshold = float( re.findall(r'(\d{1,3}(,\d{3})*.\d+)', pledge_repay_amount_require_text)[1][0].replace( ',', '')) interest_text = self.get_text( "//UIAStaticText[@label='已产生利息(元)']/following-sibling::UIAStaticText" ) interest = '%.2f' % float( filter(lambda ch: ch in '0123456789.', interest_text)) ASSERT_DICT.update({'interest': interest}) self.perform_actions(REPAY_AMOUNT, pledge_repay_amount) # self.perform_actions(SWIPE_BEGIN, CONFIRM_SWIPE_STOP, 'U') self.perform_actions(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
def get_xjb_total_assets(self): xjb_total_assets = self.get_text(XJB_TOTAL_ASSETS, 'find_element_by_id') ASSERT_DICT.update({'xjb_total_assets': xjb_total_assets}) page = self return page
def pledge_repay(self, pledge_repay_amount, trade_password): pledge_repay_amount_require_text = self.get_text( 'com.shhxzq.xjb:id/repay_explain_tv', 'find_element_by_id') pledge_repay_amount_min = float( re.findall(r'(\d{1,3}(,\d{3})*.\d+)', pledge_repay_amount_require_text)[0][0].replace( ',', '')) pledge_repay_amount_threshold = float( re.findall(r'(\d{1,3}(,\d{3})*.\d+)', pledge_repay_amount_require_text)[1][0].replace( ',', '')) interest_text = self.get_text('com.shhxzq.xjb:id/interest_tv', 'find_element_by_id') interest = '%.2f' % float( filter(lambda ch: ch in '0123456789.', interest_text)) ASSERT_DICT.update({'interest': interest}) # if pledge_repay_amount<pledge_repay_amount_min: # page = self # elif pledge_repay_amount>= pledge_repay_amount_min and pledge_repay_amount self.perform_actions(REPAY_AMOUNT, pledge_repay_amount) self.perform_actions(SWIPE_BEGIN, COMFIRM_SWIPE_STOP, 'U') self.perform_actions(COMFIRM) self.perform_actions(TRADE_PASSWORD, trade_password) page = huaxin_ui.ui_android_xjb_3_0.user_operation_succeed_page.UserOperationSucceedPage( self.web_driver) return page
def get_fund_plan_details(self): amount = self.get_text(AMOUNT_INVEST_PERIOD) ASSERT_DICT.update({'amount': amount}) page = self return page
def verify_xjb_total_assets(self, amount, operate_type=None): xjb_total_assets = str( self.get_text( '//android.widget.TextView[@text=\'现金宝\']/./following-sibling::android.widget.TextView[1]' )).replace(',', '') xjb_total_assets_actual = Decimal(float(xjb_total_assets)).quantize( Decimal('0.00')) if operate_type is None: xjb_total_assets_expected = float( Decimal( float( str(ASSERT_DICT['xjb_total_assets_login']).replace( ',', ''))).quantize( Decimal('0.00'))) + float(amount) else: xjb_total_assets_expected = float( Decimal( float( str(ASSERT_DICT['xjb_total_assets_login']).replace( ',', ''))).quantize( Decimal('0.00'))) - float(amount) ASSERT_DICT.update({'xjb_total_assets': xjb_total_assets_expected}) self.assert_values('%.2f' % xjb_total_assets_expected, str(xjb_total_assets_actual), '==') page = self return page
def login(self, user_name=None, password=None, return_page=None, flag=None): if flag is None or flag == 'setting_page_login': self.perform_actions(ACCOUNT_SWITCH) else: self.perform_actions(MODIFIED_USER_NAME_CLICK) self.perform_actions(USER_NAME, user_name, PASSWORD, password, LOGIN_BUTTON, POP_CANCEL, POP_DIALOG_CLOSE, PERMISSION_CLOSE) time.sleep(3) if flag is None: associator_center = str( self.get_text('//android.widget.TextView[@text=\'会员中心\']')) # self.perform_actions(SWIPE_BEGIN, SWIPE_STOP, 'U') total_asset = str( self.get_text('com.shhxzq.xjb:id/total_assets', 'find_element_by_id')).replace(',', '') xjb_total_assets = str( self.get_text( '//android.widget.TextView[@text=\'现金宝\']/./following-sibling::android.widget.TextView[1]' )).replace(',', '') fund_asset = str( self.get_text( '//android.widget.TextView[@text=\'基金\']/./following-sibling::android.widget.TextView[1]' )).replace(',', '') dhb_asset = str( self.get_text( '//android.widget.TextView[@text=\'定活宝\']/./following-sibling::android.widget.TextView[1]' )).replace(',', '') vip_asset = str( self.get_text( '//android.widget.TextView[@text=\'高端\']/./following-sibling::android.widget.TextView[1]' )).replace(',', '') # associator_center = str(self.get_text('com.shhxzq.xjb:id/user_level'), 'find_element_by_id').replace(',', '') ASSERT_DICT.update({ 'total_asset': total_asset, # 'xjb_total_assets': xjb_total_assets, 'xjb_total_assets_login': xjb_total_assets, # 'dhb_asset': dhb_asset, 'dhb_asset_login': dhb_asset, # 'fund_asset': fund_asset, 'fund_asset_login': fund_asset, # 'vip_asset': vip_asset, 'vip_asset_login': vip_asset, 'associator_center': associator_center, }) page = self._return_page[return_page] return page
def go_to_trade_records_page(self): available_amount = float(filter(lambda ch: ch in '0123456789.', self.get_text(AVAILABLE_AMOUNT))) ASSERT_DICT.update({'available_amount': available_amount}) self.perform_actions(RECORD) page = huaxin_ui.ui_android_xjb_3_0.trade_detail_page.TradeDetailPage(self.web_driver) return page
def go_to_select_convert_to_fund_page(self): available_amount = float(filter(lambda ch: ch in '0123456789.', self.get_text(AVAILABLE_AMOUNT))) ASSERT_DICT.update({'available_amount': available_amount}) self.perform_actions(TRANSFER) page = huaxin_ui.ui_android_xjb_3_0.select_convert_to_fund_page.SelectConvertToFundPage(self.web_driver) return page
def verify_risk_evaluation_result(self, risk_type=None): risk_result = self.get_text(RISK_RESULT).split('(')[0] if risk_type is not None: self.assert_values(risk_type, risk_result) ASSERT_DICT.update({'risk_type': risk_result}) page = self return page
def get_fund_plan_details(self): amount = self.get_text( "//android.widget.TextView[@text='每期定投(元)']/../following-sibling::android.widget.LinearLayout[1]/android.widget.TextView[@resource-id='com.shhxzq.xjb:id/content']" ) ASSERT_DICT.update({'amount': amount}) page = self return page
def go_to_fund_redeem_page(self, fund_product): self.perform_actions(TITLE_START, FUND_REDEEM_STOP % fund_product, 'U') holding_amount = self.get_text(HOLDING_AMOUNT) ASSERT_DICT.update({'holding_amount': holding_amount}) self.perform_actions(FUND_REDEEM % fund_product) page = huaxin_ui.ui_android_xjb_3_0.fund_redeem_page.FundRedeemPage(self.web_driver) return page
def verify_risk_evaluation_status(self): status = self.get_text( "//android.widget.TextView[@text='风险测评']/following-sibling::android.widget.LinearLayout[1]/android.widget.TextView" ) self.assert_values('未测评', status) ASSERT_DICT.update({'risk_type': '未测评'}) page = self return page
def exchange_coupon(self): ASSERT_DICT.update({ "yb": self.get_text(YB_NUMBER), "points": self.get_text(POINTS_NUMBER) }) self.perform_actions(COUPON_ITEM) page = huaxin_ui.ui_ios_xjb_3_0.goods_detail_page.GoodsDetailPage( self.web_driver) return page
def go_to_confirmed_fund_holding_detail_page(self, product_name): holding_amount = self.get_text(HOLDING_AMOUNT % product_name) ASSERT_DICT.update({'holding_amount': holding_amount}) self.perform_actions(SELECT_PRODUCT_1 % product_name) page = huaxin_ui.ui_ios_xjb_3_0.fund_holding_detail_page.FundHoldingDetailPage( self.web_driver) return page
def withdraw(self, withdraw_amount, trade_password, type=None): if type == 'regular_withdraw': self.perform_actions(REGULAR_WITHDRAW_RADIO) else: self.perform_actions(FAST_WITHDRAW_RADIO) money_fast_max = self.get_text( 'com.shhxzq.xjb:id/tv_enchashment_bank_card_balance', 'find_element_by_id').replace(',', '') money_fast_max = '%.2f' % float( filter(lambda ch: ch in '0123456789.', str(money_fast_max))) self.perform_actions(AMOUNT, withdraw_amount, CONFIRM_BUTTON) if float(withdraw_amount) >= 0.01 and float(withdraw_amount) <= float( money_fast_max): self.perform_actions(TRADE_PASSWORD, trade_password) page = huaxin_ui.ui_android_xjb_3_0.user_operation_succeed_page.UserOperationSucceedPage( self.web_driver) ASSERT_DICT.update({'success_flag': '1'}) # total_asset_beforehand = float(filter(lambda ch: ch in '0123456789.', ASSERT_DICT['total_asset'])) # xjb_asset_beforehand = float(filter(lambda ch: ch in '0123456789.', ASSERT_DICT['xjb_asset'])) # total_asset = total_asset_beforehand - float(withdraw_amount) # xjb_asset = xjb_asset_beforehand - float(withdraw_amount) # # ASSERT_DICT.update({'total_asset': total_asset}) # ASSERT_DICT.update({'xjb_asset': xjb_asset}) # # page = huaxin_ui.ui_android_xjb_3_0.xjb_trade_detail_page.XjbTradeDetailPage(self.web_driver) # # if source == '0': # self.perform_actions(ASSETS) # # time.sleep(3) # # self.assert_values(str(ASSERT_DICT['total_asset']), # self.get_text('com.shhxzq.xjb:id/total_assets', 'find_element_by_id').replace(',', '')) # self.assert_values(str(ASSERT_DICT['xjb_asset']), # self.get_text('com.shhxzq.xjb:id/desc', 'find_element_by_id').replace(',', '')) # # self.perform_actions(XJB_DETAIL) # balance = float(self.get_text('com.shhxzq.xjb:id/xjb_home_balance', 'find_element_by_id').replace(',', '')) # self.assert_values(float(xjb_asset), balance, '==') # self.perform_actions(XJB_TRADE_DETAIL) else: ASSERT_DICT.update({'success_flag': '0'}) self.verify_page_title() page = self time.sleep(5) return page
def add_repayment_warn(self): self.perform_actions(REPAYMENT_WARN_SWITCH, REPAYMENT_WARN_DATE, SWIPE_BEGIN, DAY_SCROLL, 'U', REPAYMENT_WARN_DATE_COMPELETED) repay_day = self.get_text('com.shhxzq.xjb:id/warn_date_txt', 'find_element_by_id') ASSERT_DICT.update({'repay_day_reminder': repay_day}) page = self return page
def fund_convert(self, amount, trade_password): available = ASSERT_DICT['available_amount'] self.perform_actions(AMOUNT, amount, FUND_CONVERT_CONFIRM, TRADE_PASSWORD, trade_password) available_amount = available - float(amount) ASSERT_DICT.update({'available_amount': available_amount}) page = huaxin_ui.ui_android_xjb_3_0.user_operation_succeed_page.UserOperationSucceedPage( self.web_driver) return page
def go_to_my_fund_plan_page(self): self.perform_actions(TITLE_START, MY_FUND_PLAN_STOP, 'U') self.perform_actions(MY_FUND_PLAN) if self.element_exist("//android.widget.TextView[@text='我的定投计划']"): page = huaxin_ui.ui_android_xjb_3_0.my_fund_plan_page.MyFundPlanPage(self.web_driver) ASSERT_DICT.update({'page': 'MyFundPlanPage'}) else: ASSERT_DICT.update({'page': 'StartFundPlanPage'}) page = huaxin_ui.ui_android_xjb_3_0.start_fund_plan_page.StartFundPlanPage(self.web_driver) return page
def redeem_dqb_product(self, redeem_amount, trade_password, dqb_product): time.sleep(3) self.perform_actions( # TITLE_START, DQB_PRODUCT_STOP % dqb_product, 'U', DQB_PRODUCT % dqb_product, REDEEM) most_redeem = self.get_text( "//UIATextField[@value='请输入取回金额']/./following-sibling::UIAStaticText[1]" ) most_redeem = re.findall(r'(\d{1,3}(,\d{3})*.\d+)', most_redeem)[0][0].replace(',', '') self.perform_actions( REDEEM_AMOUNT, redeem_amount, ) input_redeem = self.get_text( "/AppiumAUT/UIAApplication/UIAWindow/UIATextField").replace( ',', '') if input_redeem is not '0': redeem_amount_actual = self.get_text(REDEEM_AMOUNT_ACTUAL) redeem_amount_actual = re.findall( r'(\d{1,3}(,\d{3})*.\d+)', redeem_amount_actual)[1][0].replace(',', '') ASSERT_DICT.update({'dhb_redeem_actual': redeem_amount_actual}) if input_redeem == most_redeem: page = self # 验证还在卖出页面 self.assert_values( True, self.element_exist("//UIAButton[@label='全部取回']")) return page if input_redeem == '0': self.perform_actions(REDEEM_CONFIRM) # message = self.get_text('(取回金额要大于0元哦)', 'find_element_by_accessibility_id') self.assert_values( True, self.element_exist("//UIAButton[@label='全部取回']")) page = self return page self.perform_actions( REDEEM_CONFIRM, TRADE_PASSWORD, trade_password, ) page = huaxin_ui.ui_ios_xjb_3_0.trade_complete_page.TradeCompletePage( self.web_driver) return page
def go_to_my_fund_plan_page(self): self.perform_actions(MY_FUND_PLAN) if self.element_exist("//UIAStaticText[@label='我的定投计划']"): page = huaxin_ui.ui_ios_xjb_3_0.my_fund_plan_page.MyFundPlanPage( self.web_driver) ASSERT_DICT.update({'page': 'MyFundPlanPage'}) else: ASSERT_DICT.update({'page': 'StartFundPlanPage'}) page = huaxin_ui.ui_ios_xjb_3_0.start_fund_plan_page.StartFundPlanPage( self.web_driver) page.verify_page_title() return page
def cancel_order(self, trade_password, trade_type=None): if trade_type == 'fund_normal_convert': trade_amount = float( filter( lambda ch: ch in '0123456789.', self.get_text('com.shhxzq.xjb:id/trade_amount', 'find_element_by_id'))) available_amount = ASSERT_DICT['available_amount'] + trade_amount ASSERT_DICT.update({'available_amount': available_amount}) self.perform_actions(CANCEL_ORDER, 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_high_end_product(self, amount, trade_password, points='N', nonsuperposed_coupon='N', superposed_coupon='N'): 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}) 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, "swipe_accId_//", "swipe_xpathIOS_//UIATableCell/UIAStaticText[@label='满10减1所有产品可叠加' and @visible='true'][2]", "U", COUPON_1_2, COUPON_CONFIRM, ) self.perform_actions(BUY_CONFIRM, BUY_CONTINUE, TRADE_PASSWORD, trade_password) page = huaxin_ui.ui_ios_xjb_3_0.trade_complete_page.TradeCompletePage( self.web_driver) return page
def check_in(self): yb = self.get_text(YB_NUMBER) ASSERT_DICT.update({"yb": yb}) if self.element_exist("//UIAButton[@label='签到']"): self.perform_actions(CHECK_IN) self.assert_values("签到成功", self.get_text("//UIAStaticText[@label='签到成功']")) # 关闭弹出框 self.perform_actions( "xpathIOS_UIAImage_//UIAStaticText[@label='签到成功']/following-sibling::UIAImage" ) yb_update = self.get_text(YB_NUMBER) self.assert_values( decimal.Decimal(yb).quantize(decimal.Decimal('0.00')) + decimal.Decimal(5.00), decimal.Decimal(yb_update), "==") self.assert_values('已签到', self.get_text("//UIAButton[@label='已签到']"))
def go_to_repay_loan_plan_detail_page(self, repay_type=None, other_purpose=None): loans = self.web_driver.find_elements_by_xpath("//UIATableCell") ASSERT_DICT.update({"loan_count": len(loans)}) if repay_type == 'housing_loan': self.perform_actions(REPAY_HOUSING_LOAN) elif repay_type == 'car_loan': self.perform_actions(REPAY_CAR_LOAN) else: self.perform_actions(OTHER_LOAN % other_purpose) page = huaxin_ui.ui_ios_xjb_3_0.repay_loan_plan_detail_page.RepayLoanPlanDetailPage( self.web_driver) return page
def login(self, user_name, password, return_page): # 切换到账号密码登陆, 现在首次登陆默认是短信验证码登陆, 之后就是用第一次登陆的方式 self.perform_actions(ACCOUNT_LOGIN_BUTTON) self.perform_actions( USER_NAME, user_name, PASSWORD, password, LOGIN_BUTTON, POP_MESSAGE_CANCEL, # POP_MESSAGE_DELETE, ) self.perform_actions(ASSETS) total_asset = str(self.get_text(TOTAL_ASSET)).replace(',', '') time.sleep(1) xjb_asset = str(self.get_text(XJB_ASSET)).replace(',', '') fund_asset = str(self.get_text(FUND_ASSET)).replace(',', '') dhb_asset = str(self.get_text(DHB_ASSET)).replace(',', '') vip_asset = str(self.get_text(VIP_ASSET)).replace(',', '') ASSERT_DICT.update({ 'total_asset': total_asset, 'xjb_asset': xjb_asset, 'fund_asset': fund_asset, 'dhb_asset': dhb_asset, 'vip_asset': vip_asset }) self.perform_actions( HOME, # POP_MESSAGE_CANCEL, POP_MESSAGE_DELETE, ) self.assert_values( '存入', self.get_text('(UIButton_存入)', 'find_element_by_accessibility_id')) page = self._return_page[return_page] return page
def modify_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 inputing words makes effect. OTHER_PURPOSE, other_purpose, "accId_UIAKey_t", "accId_UIAButton_Return", OTHER_PURPOSE, other_purpose) else: self.perform_actions(REPAY_HOUSING_LOAN) 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
def binding_card(self, bank_card_no, mobile): self.perform_actions( CARD_NO, bank_card_no, PHONE_NO, mobile, GET_VERIFY_CODE, ) last_card_no = bank_card_no[-4:] ASSERT_DICT.update({'last_card_no': last_card_no}) verification_code = self._db.get_sms_verify_code( mobile=mobile, template_id='cif_bindBankCard') self.perform_actions(VERIFY_CODE_INPUT, verification_code, BINDIND_CARD_CONFIRM) page = huaxin_ui.ui_android_xjb_3_0.user_operation_succeed_page.UserOperationSucceedPage( self.web_driver) return page
def fund_convert(self, amount, trade_password): available = float( filter( lambda ch: ch in '0123456789.', self.get_text( '//UIAStaticText[@label=\'可转出份额(份)\']/following-sibling::UIAStaticText' )).replace(',', '')) self.perform_actions( AMOUNT, amount, FUND_CONVERT_CONFIRM, TRADE_PASSWORD, trade_password, ) available_amount = available - float(amount) ASSERT_DICT.update({'available_amount': available_amount}) page = huaxin_ui.ui_ios_xjb_3_0.trade_complete_page.TradeCompletePage( self.web_driver) return page