class LoginTest(MyTest): """登录测试""" def setUp(self): # super(LoginTest, self).setUp() self.driver = AppiumDriver().start_appium('4723', 0) # 如果有系统更新的话,直接取消更新 self.cancle_dialog = CancleDialog(self.driver) self.cancle_dialog.cancle_update() # 用户名密码登陆的实例 self.lp = LoginPage(self.driver) # 三方登陆的实例 self.tp = ThirdLogin(self.driver) def user_login_verify(self, phone='', password=''): self.lp.user_login(phone, password) def test_login1(self): """用户名、密码为空""" self.user_login_verify() try: self.assertEqual(self.lp.get_message(), u'请输入正确的手机号码', '手机号输入格式错误的提示不正确') except AssertionError, msg: screenshot() print msg finally:
class UserToolsTest(MyTest): """用户关注 粉丝 剧点 赏金 测试""" def setUp(self): self.driver = AppiumDriver().start_appium('4723', 1) self.cancle_dialog = CancleDialog(self.driver) self.cancle_dialog.cancle_update() self.cancle_dialog.cancle_daily_share() self.cancle_dialog.cancle_vote() self.tools = UserToolsPage(self.driver) self.tools.login_user_info_btn() self.attentions_num = int(self.tools.get_amount(0)) # 关注数 self.fans_num = int(self.tools.get_amount(1)) # 粉丝数 self.jpoint_num = int(self.tools.get_amount(2)) # 剧点数 self.coupon_num = int(self.tools.get_amount(3)) # 代金券 self.reward_num = int(self.tools.get_amount(4)) # 赏金数 def test_tool1(self): """关注列表内搜索测试""" try: if self.attentions_num == 0: self.skipTest('该用户没有关注别人') self.tools.tv_amount_btn(0) # 进入关注列表 self.tools.set_search() # 搜索框输入内容 num = self.tools.get_attentions_list() # 获取搜索之后列表 self.assertEqual('1', str(len(num)), '搜索失败') except AssertionError, msg: screenshot() print msg
class UserPostingLogTest(MyTest): def setUp(self): self.driver = AppiumDriver().start_appium('4723', 1) self.cancle_dialog = CancleDialog(self.driver) self.cancle_dialog.cancle_update() self.cancle_dialog.cancle_daily_share() self.cancle_dialog.cancle_vote() self.uplp = UserPostingLogPage(self.driver) self.uplp.login_user_info_btn() # 进入个人中心 self.uplp.login_posting_btn() # 进入发帖记录 # 获得页面信息 评论数和点赞数 self.comment_num = self.uplp.get_comment_num() self.priase_num = self.uplp.get_praise_num() def test_post1(self): """发帖记录页点赞测试""" try: if len(self.uplp.get_all_log()) == 0: Logger.info('跳过测试,该用户没有发过帖子') self.skipTest('该用户没有发过帖子') self.uplp.click_priase() # 点赞按钮 new_priase_num = self.uplp.get_praise_num() self.assertTrue(abs(new_priase_num - self.priase_num) == 1, '点赞失败') Logger.info('点赞测试成功') except AssertionError, msg: screenshot() print msg Logger.error(msg)
class EditUserInfoTest(MyTest): """用户个人信息编辑""" def setUp(self): self.driver = AppiumDriver().start_appium('4723', 1) self.cancle_dialog = CancleDialog(self.driver) self.cancle_dialog.cancle_update() self.eui = EditUserInfoPage(self.driver) self.eui.login_user_info_btn() self.eui.login_edit_btn() def test_edit1(self): """昵称编辑""" self.old_name = self.eui.get_name() self.eui.name_btn() self.eui.set_name(u'龙龙') self.eui.name_ok_btn() try: self.eui.back_user_info_btn() self.eui.login_edit_btn() self.new_name = self.eui.get_name() self.assertNotEqual(self.old_name, self.new_name, '昵称修改失败') except AssertionError, msg: screenshot() print msg