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)