def test_04_recharge(self, amount=None): """ 充值 """ global recharge_amount recharge_amount = amount or random.randrange(1, 50000) print('充值金额{}'.format(recharge_amount)) HomePage().click_mine_view() MinePage().recharge_view.click() if Driver.d(text='徽商存管开户提醒').exists(timeout=4): time.sleep(4) Driver.d.click('确定') open_account_steps(Driver.d, name="李一") elements = [Driver.d(description='完成'), Driver.d(text='完成')] for ele in elements: if ele.exists(timeout=3): ele.click() break MinePage().recharge_view.click() Driver.d(resourceId="com.nonoapp:id/et_recharge_amount").set_text( recharge_amount) Driver.d.click(0.862, 0.856) Driver.d(resourceId="com.nonoapp:id/btn_recharge_next").click() time.sleep(3) elements = [Driver.d(description=u"确定"), Driver.d(text='确定')] for ele in elements: if ele.exists(timeout=4): ele.click() break time.sleep(4) Driver.screenshot()
def test_08_check_my_welfare(self): """ 新手福利发放 """ HomePage().click_mine_view() scroll('up').click(resourceId="com.nonoapp:id/iv") assert Driver.d(text="新客福利(不可叠加)").exists(timeout=3) assert Driver.d(text="立即使用").exists(timeout=3) Driver.screenshot()
def test_03_set_password(self, name=None, id_no=None): """ 设置交易密码 """ HomePage().click_mine_view() MinePage().recharge_view.click() """判断是否开户""" if Driver.d(text='徽商存管开户提醒').exists(timeout=4): time.sleep(4) Driver.d('确定').click() open_account_steps(Driver.d, name="李一") elements = [Driver.d(description='完成'), Driver.d(text='完成')] for ele in elements: if ele.exists(timeout=3): ele.click() break MinePage().recharge_view.click() #todo:充值steps Driver.d(text="请输入充值金额").set_text("100") # d(text='确定').click() Driver.d.click(0.862, 0.856) Driver.d(text='立即充值').click() if Driver.d(text=u"身份信息验证", className="android.views.View").exists(timeout=3): Driver.d(resourceId="realname").set_text(name) Driver.d(resourceId="id_no").set_text(id_no) Driver.d(resourceId="btn_send").click() Driver.d(resourceId="valide_code").set_text('888888') Driver.d(resourceId="btn_next").click() time.sleep(2) elements = [Driver.d(description=u"确定"), Driver.d(text='确定')] for ele in elements: if ele.exists: ele.click() break time.sleep(2)
def test_03_activity_center(self): """ 活动中心 """ HomePage().discover_view.click(timeout=20) DiscoverPage().activity_center_view.click() Driver.screenshot() back() Driver.screenshot()
def logout(d): '''退出''' HomePage().mine_view.click() d(text='先去逛逛').click_exists(timeout=4) MinePage().setting_view.click() scroll('up').click(text='安全退出') d(text='确定').click()
def set_env(d, env='sit'): '''设置测试环境''' d(resourceId="com.nonoapp:id/tv_splash_skip").click_exists(timeout=2) HomePage().mine_view.click() LoginPage().switch_env_view.click() d(text="{}".format(env.upper())).click() d(text="确认").click() WelcomePage().button.click()
def test_02_sign_in(self): """ 每日签到 """ HomePage().discover_view.click(timeout=20) DiscoverPage().sign_in_view.click() if Driver.d(text='签到成功').exists(timeout=3): Driver.d(text='确定').click() assert Driver.d(text='恭喜你签到成功').exists(timeout=3) Driver.screenshot()
def set_env(cls): WelcomePage().button.click_exists(timeout=8) time.sleep(3) HomePage().mine_view.click() # LoginPage().switch_env_steps(env) cls.d(text="切换测试环境").click() cls.d(text="SIT").click() cls.d(text="确认").click() cls.d(text="立即注册领1888新手福利").click()
def test_06_check_shopping(self): """ 检查会员商城页面 """ time.sleep(3) HomePage().discover_view.click(timeout=20) scroll('up').click(text='会员商城') scroll('up').click(text='查看更多') assert Driver.d(text='会员商城').exists(timeout=3) assert Driver.d(text='兑换记录').exists(timeout=3) assert Driver.d(text='会员专区').exists(timeout=3)
def test_05_transaction_records_recharges(self): """充值记录""" HomePage().click_mine_view() SitTester().click("交易记录").click("充值").sleep(2) assert Driver.d( resourceId="com.nonoapp:id/tv_finance_desc").get_text() == "充值" amout_text = Driver.d( resourceId="com.nonoapp:id/tv_finance_actual_amount").get_text() print(amout_text) Driver.screenshot()
def login(d, username, password="******"): '''登录''' HomePage().mine_view.click() if d(resourceId="com.nonoapp:id/tv_mine_setting").exists(timeout=2): logout(d) HomePage().mine_view.click() LoginPage().username_view.set_text(username) LoginPage().password_view.set_text(password) back() LoginPage().login_view.click() ele = Driver.d(text='验证码登录') if ele.exists(timeout=3): ele.click() d(text=u'获取验证码').click() d(text='请输入图形验证码').set_text(text='8888') d(text='确定').click() d(text='请输入验证码').set_text(text='888888') back() LoginPage().login_view.click() d(text=u"跳过").click_exists(timeout=2)
def test_01_page_check(self): """ 发现页元素检查 """ HomePage().discover_view.click(timeout=20) assert Driver.d(text='普通会员').exists(timeout=3) assert Driver.d(text='每日签到').exists(timeout=3) assert Driver.d(text='翻翻乐').exists(timeout=3) assert Driver.d(text='活动中心').exists(timeout=3) assert Driver.d(text='做任务 拿奖励').exists(timeout=3) assert Driver.d(text='我的任务').exists(timeout=3) assert Driver.d(text='邀请好友').exists(timeout=3) Driver.screenshot()
def test_07_risk_evaluation(self): """ 风险评测 """ HomePage().click_mine_view() MinePage().setting_view.click() SettingPage().risk_evaluation_view.click() risk_evaluation_steps(Driver.d) assert Driver.d(text="已测评").exists(timeout=4) print("------完成风险评测------") text = Driver.d( resourceId="com.nonoapp:id/tv_evaluating_result").get_text( timeout=4) print(f"风险等级:{text}")
def test_04_invite_friends(self): """ 邀请好友 - 取消 """ HomePage().discover_view.click(timeout=20) DiscoverPage().invite_friends_view.click() if Driver.d(description="邀请好友 ").exists(timeout=4): Driver.d(description="邀请好友 ").click() else: Driver.d(text="邀请好友 ").click() assert Driver.d(text='微信').exists(timeout=3) assert Driver.d(text='朋友圈').exists(timeout=3) assert Driver.d(text='QQ').exists(timeout=3) assert Driver.d(text='短信').exists(timeout=3) Driver.d(text='取消').click() Driver.screenshot()
def test_01_sign_up(self, username=None): """ 注册 """ if username is None: username = create_iphone_no() HomePage().mine_view.click() LoginPage().register_view.click() sign_up_steps(Driver.d, username) Driver.d(text="跳过").click() global register_user register_user = username print("注册用户:", register_user) Driver.screenshot() Driver.d(text="先去逛逛").click() time.sleep(1)
def test_02_openacc(self): """ 徽商开户 """ HomePage().click_mine_view() MinePage().setting_view.click() SettingPage().open_account_view.click() open_account_steps(Driver.d, name="李一") if Driver.d(description='徽商出借人电子账户开户成功').exists(timeout=4) \ or Driver.d(text='徽商出借人电子账户开户成功').exists(timeout=4): assert True else: assert False Driver.screenshot() elements = [Driver.d(description='完成'), Driver.d(text='完成')] for ele in elements: if ele.exists(timeout=3): ele.click() break
def test_05_check_my_task(self): """ 检查我的任务页面 """ time.sleep(3) #显式的等待... HomePage().discover_view.click(timeout=20) scroll('up').click(text='我的任务') if Driver.d(description='去邀请').exists(timeout=3): assert True elif Driver.d(text='去邀请').exists(timeout=3): assert True else: assert False if Driver.d(description='我的福利').exists(timeout=3): Driver.d(description='我的福利').click() else: Driver.d(text='我的福利').click() # assert self.d(description='去出借').exists(timeout=3) assert Driver.d(text='抵用券').exists(timeout=3) assert Driver.d(text='补贴券').exists(timeout=3) assert Driver.d(text='特权本金').exists(timeout=3) Driver.screenshot()
def test_06_invest_accredition(self): """ 智能出借授权 """ HomePage().click_mine_view() MinePage().setting_view.click() Driver.d(text=u"智能出借授权").click() Driver.d(resourceId="btn_next").click() elements = [Driver.d(description='确定'), Driver.d(text='确定')] for ele in elements: if ele.exists(timeout=4): ele.click() break if Driver.d(description=u"您的徽商存管智能出借开通成功!").exists(timeout=4) \ or Driver.d(text=u"您的徽商存管智能出借开通成功!").exists(timeout=4): assert True else: assert False elements = [Driver.d(description='完成'), Driver.d(text='完成')] for ele in elements: if ele.exists: ele.click() break assert Driver.d(text='已开通').exists(timeout=5) print("------开通智能出借授权------")