class C31034_DFCP_Backpack_Interface_GetPro(TestCase): ''' 购买道具,商城购买道具,查看物品箱 ''' owner = "LucyLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 5 def pre_test(self): self.common = Common() self.luadriver = self.common.setupdriver() self.hall_page = Hall_Page() self.mall_page = Mall_Page() self.sign_page = Sign_Page() self.backpack_page = Backpack_Page() self.personinfo_page = Personinfo_Page() time.sleep(1) PHPInterface.add_money(self.casedata['mid'], 53000) # 每个用例都需要关闭活动,把这个放在初始化里面实现 self.common.closeactivityprepublish(self.luadriver) self.hall_page.wait_element("头像").click() time.sleep(2) if self.personinfo_page.wait_element("账号ID").get_attribute('text') != self.casedata['cid']: self.common.loginuser(self.casedata['user'], self.casedata['password']) try: self.personinfo_page.wait_element("关闭").click() except: print "已关闭窗口" def run_test(self): self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") self.start_step("进入物品箱页面") time.sleep(2) self.hall_page.wait_element("物品箱").click() time.sleep(2) self.hall_page.screenshot('Backpack_Enterpack1.png') self.luadriver.keyevent(4) self.start_step("进入商城页面") self.hall_page.wait_element("商城").click() time.sleep(2) self.mall_page.wait_element("道具页签").click() time.sleep(2) self.start_step("购买道具") self.mall_page.wait_element("提示卡").click() time.sleep(5) self.sign_page.wait_element("购买").click() time.sleep(3) self.mall_page.wait_element("返回").click() time.sleep(3) self.start_step("进入物品箱页面") time.sleep(2) self.hall_page.wait_element("物品箱").click() time.sleep(2) self.hall_page.screenshot('Backpack_Enterpack2.png') def post_test(self): self.common.deletefile(self.luadriver) self.common.closedriver()
def pre_test(self): self.start_step("初始化环境") self.common = Common() # 初始化Luadriver self.luadriver = self.common.setupdriver() self.hall_page = Hall_Page() self.personinfo_page = Personinfo_Page() self.sign_page = Sign_Page() # PHPInterface.set_env(PHPInterface.PRE_REPUBLISH_ENV) return1 = PHPInterface.set_notice('公告自动化测试', "1111", id=103000, end_time=int(time.time() + 60 * 4), is_html=1) print return1 time.sleep(10) self.start_step("配置公告") try: self.luadriver.find_element_by_name("允许").click() except: print "未出现按钮" time.sleep(15) try: self.hall_page.wait_element("确认登陆").click() except: print "未出现登陆按钮"
def pre_test(self): self.common = Common() # global user_info # user_info = self.common.get_user() # print user_info self.hall_page = Hall_Page() self.mall_page = Mall_Page() self.sign_page = Sign_Page() self.backpack_page = Backpack_Page() self.personinfo_page = Personinfo_Page() self.start_step("初始化driver") self.luadriver = self.common.setupdriver() self.start_step("关闭活动") self.common.closeactivity_switchserver(self.luadriver) self.start_step("获取用户mid") cid = self.common.get_cid() mid = PHPInterface.get_mid(cid, region=1) print "用户mid为:%s" % mid user_info1 = PHPInterface.get_user_info(mid) # 获取玩家信息 coin = json.loads(user_info1).get('result', {'coin': None}).get('coin') # 获取当前银币值 AddMoney = 53000 - coin PHPInterface.add_money(mid, AddMoney) # 将银币值设为3000 PHPInterface.add_money(mid, 53000) self.hall_page.wait_element("头像").click() time.sleep(2)
def pre_test(self): self.start_step("初始化环境") self.common = Common() # 初始化Luadriver self.luadriver = self.common.setupdriver() self.hall_page = Hall_Page() self.personinfo_page = Personinfo_Page() self.sign_page = Sign_Page() # PHPInterface.set_env(PHPInterface.PRE_REPUBLISH_ENV) return1 = PHPInterface.set_notice('公告自动化测试', "文本公告测试", app_id=103000, end_time=int(time.time() + 60 * 2), is_html=1, conditions={"poptype": 2}) print return1 self.start_step("配置公告") self.common.closeactivity_switchserver(self.luadriver) Flag = True while Flag: # 关闭干扰活动弹框,找到公告弹框 try: self.hall_page.wait_element('公告标题') print '找到公告标题' Flag = False except: try: self.sign_page.wait_element("关闭1").click() except: print '未找到关闭按钮' time.sleep(2)
def pre_test(self): self.start_step("初始化环境") self.common = Common() # 初始化Luadriver self.luadriver = self.common.setupdriver() self.hall_page = Hall_Page() self.personinfo_page = Personinfo_Page() self.sign_page = Sign_Page() # PHPInterface.set_env(PHPInterface.PRE_REPUBLISH_ENV) return1 = PHPInterface.set_notice( title='666666', content={ "htmlpic": "https://dfqppic.266.com/dfqp/pic/notice/mycff2zj.png" }, app_id=103000, end_time=int(time.time() + 60 * 2), is_html=2, conditions={"poptype": 2}) print return1 time.sleep(10) self.start_step("配置公告") self.common.closeactivity_switchserver(self.luadriver) Flag = True while Flag: # 关闭干扰活动弹框,找到公告弹框 try: self.hall_page.wait_element('公告图片') print '找到公告图片' Flag = False except: try: self.sign_page.wait_element("关闭1").click() except: print '未找到关闭按钮' time.sleep(2)
class C33364_DFQP_Notice_Picture(TestCase): ''' 图片公告,不配置跳转 ''' owner = "LucyLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 5 def pre_test(self): self.start_step("初始化环境") self.common = Common() # 初始化Luadriver self.luadriver = self.common.setupdriver() self.hall_page = Hall_Page() self.personinfo_page = Personinfo_Page() self.sign_page = Sign_Page() # PHPInterface.set_env(PHPInterface.PRE_REPUBLISH_ENV) return1 = PHPInterface.set_notice( title='666666', content={ "htmlpic": "https://dfqppic.266.com/dfqp/pic/notice/mycff2zj.png" }, app_id=103000, end_time=int(time.time() + 60 * 2), is_html=2, conditions={"poptype": 2}) print return1 time.sleep(10) self.start_step("配置公告") self.common.closeactivity_switchserver(self.luadriver) Flag = True while Flag: # 关闭干扰活动弹框,找到公告弹框 try: self.hall_page.wait_element('公告图片') print '找到公告图片' Flag = False except: try: self.sign_page.wait_element("关闭1").click() except: print '未找到关闭按钮' time.sleep(2) def run_test(self): ''' 测试用例 ''' self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") time.sleep(5) self.hall_page.screenshot("notice.png") self.sign_page.wait_element("关闭1").click() def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' self.common.closedriver()
def pre_test(self): global UserID UserID = self.casedata.get('mid2') print 'UserID:%s' % UserID # PHPInterface.set_env(PHPInterface.PRE_REPUBLISH_ENV) user_info = PHPInterface.get_user_info(UserID) # 获取玩家信息 coin = json.loads(user_info).get('result', { 'coin': None }).get('coin') # 获取当前银币值 AddMoney = 60000 - coin PHPInterface.add_money(UserID, AddMoney) # 将银币值设为60000 self.common = Common() # 初始化Luadriver self.luadriver = self.common.setupdriver() self.hall_page = Hall_Page() self.sign_page = Sign_Page() self.personinfo_page = Personinfo_Page() self.common.closeactivity_switchserver(self.luadriver, '预发布') self.hall_page.wait_element("头像").click() time.sleep(5) self.common.loginuser(self.casedata['user2'], self.casedata['password2']) i = 0 while i < 3: i += 1 try: self.personinfo_page.wait_element("关闭").click() except: print "已关闭窗口"
def pre_test(self): global UserID UserID = self.casedata.get('mid') print 'UserID:%s' % UserID dict = PHPInterface.get_user_info(UserID) # 获取玩家信息 coin = eval(dict).get('result', {'coin': None}).get('coin') # 获取当前银币值 AddMoney = 60000 - coin PHPInterface.add_money(UserID, AddMoney) # 将银币值设为60000 self.common = Common() # 初始化Luadriver self.luadriver = self.common.setupdriver() self.hall_page = Hall_Page() self.sign_page = Sign_Page() self.personinfo_page = Personinfo_Page() self.common.closeactivitytest(self.luadriver) self.hall_page.wait_element("头像").click() time.sleep(5) if self.personinfo_page.wait_element("账号ID").get_attribute( 'text') != self.casedata['cid']: self.common.loginuser(self.casedata['user'], self.casedata['password']) try: self.personinfo_page.wait_element("关闭").click() except: print "已关闭窗口"
def pre_test(self): self.start_step("初始化环境") self.common = Common() # 初始化Luadriver self.luadriver = self.common.setupdriver() self.hall_page = Hall_Page() self.personinfo_page = Personinfo_Page() self.sign_page = Sign_Page() # PHPInterface.set_env(PHPInterface.PRE_REPUBLISH_ENV) return1 = PHPInterface.set_notice( title='666666', content={ "htmlpic": "https://dfqppic.266.com/dfqp/pic/notice/mycff2zj.png", "cmd": 1022, "gameid": 203, "level": 12 }, app_id=103000, end_time=int(time.time() + 60 * 2), is_html=2, conditions={"poptype": 2}) print return1 time.sleep(10) self.start_step("配置公告") self.common.closeactivity_switchserver(self.luadriver)
def closeActivity(self): ''' 关闭进入大厅各种弹框 :return: ''' self.hall_page = Hall_Page() self.sign_page = Sign_Page() #关闭首先出现的新手任务按钮 try: self.hall_page.wait_element("新手任务", 5).click() except: print "未出现新手任务按钮" try: self.hall_page.wait_element("确认登陆", 5).click() except: print "未出现确认登陆按钮" try: self.hall_page.wait_element("立即升级绑定账号", 5).click() self.sign_page.wait_element("关闭1").click() except: print "未出现立即升级绑定账号按钮" #添加破产奖励领取,由于目前只能在正式服测试 导致所有接口不能用 先领取破产奖励,避免弹框对其他场景影响 try: self.hall_page.wait_element("破产领奖按钮", 5).click() self.platformLog("领取破产奖励") except: print "没有破产按钮" self.closeActivityBtn(False)
def pre_test(self): self.common = Common() self.hall_page = Hall_Page() self.sign_page = Sign_Page() self.personinfo_page = Personinfo_Page() # global user_info,UserID # user_info = self.common.get_user() # print user_info # UserID = user_info.get('mid') # print 'UserID:%s' % UserID # PHPInterface.set_env(PHPInterface.PRE_REPUBLISH_ENV) # 初始化Luadriver self.luadriver = self.common.setupdriver() self.start_step("关闭活动,并切换到预发布") self.common.closeactivity_switchserver(self.luadriver) cid = self.common.get_cid() global mid mid = PHPInterface.get_mid(cid, region=1) print "用户mid为:%s" % mid user_info1 = PHPInterface.get_user_info(mid) # 获取玩家信息 coin = json.loads(user_info1).get('result', { 'coin': None }).get('coin') # 获取当前银币值 AddMoney = 60000 - coin PHPInterface.add_money(mid, AddMoney) # 将银币值设为60000
def pre_test(self): self.common = Common() self.luadriver = self.common.setupdriver() self.hall_page = Hall_Page() self.mall_page = Mall_Page() self.sign_page = Sign_Page() self.backpack_page = Backpack_Page() self.personinfo_page = Personinfo_Page() time.sleep(1) UserID = self.casedata.get('mid') print 'UserID:%s' % UserID dict = PHPInterface.get_user_info(UserID) # 获取玩家信息 crystal = eval(dict).get('result', { 'crystal': None }).get('crystal') # 获取当前金条值 AddCrystal = 1000 - crystal PHPInterface.add_crystal(UserID, AddCrystal) # 将金条数目置1000 # 每个用例都需要关闭活动,把这个放在初始化里面实现 self.common.closeactivitytest(self.luadriver) self.hall_page.wait_element("头像").click() time.sleep(2) if self.personinfo_page.wait_element("账号ID").get_attribute( 'text') != self.casedata['cid']: self.common.loginuser(self.casedata['user'], self.casedata['password']) try: self.personinfo_page.wait_element("关闭").click() except: print "已关闭窗口"
def pre_test(self): self.common = Common() # 初始化Luadriver self.luadriver = self.common.setupdriver() # 每个用例都需要关闭活动,把这个放在初始化里面实现 self.common.closeactivity_switchserver(self.luadriver, "环境切换") self.hall_page = Hall_Page() self.sign_page = Sign_Page()
def pre_test(self): self.common = Common() self.hall_page = Hall_Page() self.yuepai_page = Yuepai_Page() self.game_page = Game_Page() self.sign_page = Sign_Page() self.start_step("初始化driver") self.luadriver = self.common.setupdriver() self.common.closeactivity(self.luadriver)
def pre_test(self): self.common = Common() # 初始化Luadriver self.luadriver = self.common.setupdriver() self.common.deletefile(self.luadriver) # 每个用例都需要关闭活动,把这个放在初始化里面实现 self.common.closeactivity(self.luadriver) self.hall_page = Hall_Page() self.sign_page = Sign_Page()
class C225_DFQP_Broadcast(TestCase): ''' 注册15级玩家银币足够,点击广播输入文字点击发送,查看 ''' owner = "YoungLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 5 def pre_test(self): UserID = self.casedata.get('mid') print 'UserID:%s' % UserID PHPInterface.set_level(UserID, 16) dict = PHPInterface.get_user_info(UserID) #获取玩家信息 coin = eval(dict).get('result', {'coin': None}).get('coin') #获取当前银币值 AddMoney = 40000 - coin PHPInterface.add_money(UserID, AddMoney) #将银币值设为40000 self.common = Common() # 初始化Luadriver self.luadriver = self.common.setupdriver() self.hall_page = Hall_Page() self.sign_page = Sign_Page() self.game_page = Game_Page() self.setting_page = Setting_Page() self.personinfo_page = Personinfo_Page() self.broadcast_page = Broadcast_Page() self.common.closeactivitytest(self.luadriver) def run_test(self): self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") self.start_step('进入头像界面') self.hall_page.wait_element('头像').click() self.common.loginuser(self.casedata['user'], self.casedata['password']) self.start_step('关闭弹框') time.sleep(4) i = 0 while (i < 3): try: self.sign_page.wait_element('关闭1').click() i += 1 except: i = 3 self.start_step('进入广播界面') self.broadcast_page.wait_element('广播').click() self.broadcast_page.wait_element('输入文字').send_keys('11') self.start_step('点击发送') self.broadcast_page.wait_element('发送').click() time.sleep(1) self.personinfo_page.screenshot('.png') def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' self.common.closedriver()
class C31053_DFCP_Mall_Interface_GetPro(TestCase): ''' 金条购买银币 ''' owner = "LucyLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 5 def pre_test(self): self.common = Common() self.luadriver = self.common.setupdriver() self.hall_page = Hall_Page() self.mall_page = Mall_Page() self.sign_page = Sign_Page() self.backpack_page = Backpack_Page() self.personinfo_page = Personinfo_Page() time.sleep(1) UserID = self.casedata.get('mid') print 'UserID:%s' % UserID dict = PHPInterface.get_user_info(UserID) # 获取玩家信息 crystal = eval(dict).get('result', { 'crystal': None }).get('crystal') # 获取当前金条值 AddCrystal = 1000 - crystal PHPInterface.add_crystal(UserID, AddCrystal) # 将金条数目置1000 # 每个用例都需要关闭活动,把这个放在初始化里面实现 self.common.closeactivitytest(self.luadriver) self.hall_page.wait_element("头像").click() time.sleep(2) if self.personinfo_page.wait_element("账号ID").get_attribute( 'text') != self.casedata['cid']: self.common.loginuser(self.casedata['user'], self.casedata['password']) try: self.personinfo_page.wait_element("关闭").click() except: print "已关闭窗口" def run_test(self): self.start_step("等待页面加载完成") self.start_step("进入商城页面") self.hall_page.wait_element("商城").click() time.sleep(2) self.mall_page.wait_element("银币页签").click() time.sleep(2) self.start_step("购买道具") self.mall_page.wait_element("提示卡").click() time.sleep(5) self.sign_page.wait_element("购买").click() time.sleep(2) self.hall_page.screenshot('bug.png') def post_test(self): self.common.deletefile(self.luadriver) self.common.closedriver()
class C33362_DFQP_Notice_Text(TestCase): ''' 查看文本公告 ''' owner = "LucyLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 5 def pre_test(self): self.start_step("初始化环境") self.common = Common() # 初始化Luadriver self.luadriver = self.common.setupdriver() self.hall_page = Hall_Page() self.personinfo_page = Personinfo_Page() self.sign_page = Sign_Page() # PHPInterface.set_env(PHPInterface.PRE_REPUBLISH_ENV) return1 = PHPInterface.set_notice('yyyy', "tttt", app_id=103000, weight=1, end_time=int(time.time() + 60 * 2), is_html=0, conditions={"poptype": 2}) print return1 self.start_step("配置公告") self.common.closeactivity_switchserver(self.luadriver) Flag = True while Flag: # 关闭干扰活动弹框,找到公告弹框 try: self.hall_page.wait_element('公告标题') print '找到公告标题' Flag = False except: try: self.sign_page.wait_element("关闭1").click() except: print '未找到关闭按钮' time.sleep(2) def run_test(self): ''' 测试用例 ''' self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") time.sleep(5) self.hall_page.screenshot("notice_text.png") self.sign_page.wait_element("关闭1").click() def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' self.common.closedriver()
class C31060_DFCP_Mall_Interface_GetPro(TestCase): ''' 商城购买道具 ''' owner = "LucyLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 5 def pre_test(self): self.common = Common() # global user_info # user_info = self.common.get_user() # print user_info self.luadriver = self.common.setupdriver() # 每个用例都需要关闭活动,把这个放在初始化里面实现 self.common.closeactivity_switchserver(self.luadriver) self.hall_page = Hall_Page() self.mall_page = Mall_Page() self.sign_page = Sign_Page() self.backpack_page = Backpack_Page() self.personinfo_page = Personinfo_Page() time.sleep(1) cid = self.common.get_cid() global mid mid = PHPInterface.get_mid(cid, region=1) print "用户mid为:%s" % mid PHPInterface.add_money(mid, 53000) # self.hall_page.wait_element("头像").click() # time.sleep(2) # if self.personinfo_page.wait_element("账号ID").get_attribute('text') != user_info['cid']: # self.common.loginuser(user_info['user'], user_info['password']) # try: # self.personinfo_page.wait_element("关闭").click() # except: # print "已关闭窗口" def run_test(self): self.start_step("等待页面加载完成") self.start_step("进入商城页面") self.hall_page.wait_element("商城").click() time.sleep(2) self.mall_page.wait_element("道具页签").click() time.sleep(2) self.start_step("购买道具") self.mall_page.wait_element("提示卡").click() time.sleep(5) self.sign_page.wait_element("购买").click() time.sleep(2) self.hall_page.screenshot('bug.png') def post_test(self): # self.common.release_user(user_info['mid']) # self.common.deletefile(self.luadriver) self.common.closedriver()
def pre_test(self): self.common = Common() global mid mid = self.common.get_config_value("casecfg", "mid") self.common.set_coin(mid=mid, value='60000') self.hall_page = Hall_Page() self.sign_page = Sign_Page() self.personinfo_page = Personinfo_Page() self.luadriver = self.common.setupdriver() self.start_step("关闭活动,并切换到预发布") self.common.closeactivity(self.luadriver)
def pre_test(self): self.common = Common() global mid mid = self.common.get_config_value("casecfg", "mid") PHPInterface.set_vip(mid, 4) # 设置用户为vip # 初始化Luadriver self.luadriver = self.common.setupdriver() self.hall_page = Hall_Page() self.sign_page = Sign_Page() self.personinfo_page = Personinfo_Page() self.common.closeactivity(self.luadriver)
class C227_DFQP_Broadcast(TestCase): ''' 发送两条广播,查看广播消息界面显示 ''' owner = "YoungLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 5 def pre_test(self): global UserID UserID = self.casedata.get('mid') print 'UserID:%s' % UserID dict = PHPInterface.get_user_info(UserID) #获取玩家信息 coin = eval(dict).get('result', {'coin': None}).get('coin') #获取当前银币值 AddMoney = 300000 - coin PHPInterface.add_money(UserID, AddMoney) #将银币值设为300000 self.common = Common() # 初始化Luadriver self.luadriver = self.common.setupdriver() self.hall_page = Hall_Page() self.sign_page = Sign_Page() self.game_page = Game_Page() self.setting_page = Setting_Page() self.personinfo_page = Personinfo_Page() self.broadcast_page = Broadcast_Page() self.common.closeactivitytest(self.luadriver) def run_test(self): self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") self.start_step('进入头像界面') self.hall_page.wait_element('头像').click() self.common.loginuser(self.casedata['user'], self.casedata['password']) self.start_step('关闭弹框') time.sleep(4) i = 0 while (i < 3): try: self.sign_page.wait_element('关闭1').click() i += 1 except: i = 3 PHPInterface.broadcast(UserID, content='地方棋牌测试专用1') time.sleep(1) PHPInterface.broadcast(2188068, content='地方棋牌测试专用2') time.sleep(1) self.personinfo_page.screenshot('.png') def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' self.common.closedriver()
def pre_test(self): self.common = Common() # 初始化Luadriver self.luadriver = self.common.setupdriver() self.hall_page = Hall_Page() self.sign_page = Sign_Page() self.game_page = Game_Page() self.setting_page = Setting_Page() self.personinfo_page = Personinfo_Page() self.broadcast_page = Broadcast_Page() self.common.closeactivitytest(self.luadriver)
def closeActivity(self): ''' 关闭活动页面,切换到指定服,然后再关闭弹出的活动页面 :param switchserver: :return: ''' driver = singleGlobalVar.get("luaDriver") self.hall_page = Hall_Page() self.sign_page = Sign_Page() #性能测试中启动完成后才开始关闭活动弹框,sleep可省略 # time.sleep(8) try: driver.find_element_by_name("允许").click() except: print "未出现允许按钮" try: driver.find_element_by_tag_name("允许").click() except: print "未出现允许按钮" try: driver.find_elements_by_class_name( "android.widget.Button")[1].click() except: print "未出现android.widget.Button按钮" time.sleep(10) try: self.hall_page.wait_element("确认登陆").click() except: print "未出现确认登陆按钮" try: self.hall_page.wait_element("立即升级绑定账号").click() time.sleep(1) self.sign_page.wait_element("关闭1").click() except: print "未出现立即升级绑定账号按钮" #添加破产奖励领取,由于目前只能在正式服测试 导致所有接口不能用 先领取破产奖励,避免弹框对其他场景影响 try: self.hall_page.wait_element("破产领奖按钮").click() self.platformLog("领取破产奖励") except: print "没有破产按钮" self.closeActivityBtn() try: self.hall_page.wait_element("新手任务").click() time.sleep(2) except: print "未出现新手任务按钮" try: driver.find_element_by_name("允许").click() except: print "未出现允许按钮"
def closeactivity_switchserver(self, luadriver, switchserver): self.hall_page = Hall_Page() self.sign_page = Sign_Page() time.sleep(10) try: luadriver.find_element_by_name("允许").click() except: print "未出现按钮" time.sleep(5) try: self.hall_page.wait_element("确认登陆").click() except: print "未出现登陆按钮" i = 0 while (i < 3): i += 1 try: self.sign_page.wait_element("关闭1").click() time.sleep(1) except: try: self.sign_page.wait_element("关闭1").click() time.sleep(1) except: print "关闭对话框" try: self.hall_page.wait_element("新手任务").click() time.sleep(2) except: print "未出现新手任务按钮" try: self.hall_page.wait_element(switchserver).click() time.sleep(1) except: print "未出现正式服按钮" time.sleep(13) try: luadriver.find_element_by_name("允许").click() except: "未出现按钮" time.sleep(2) i = 0 while (i < 3): i += 1 try: self.sign_page.wait_element("关闭1").click() time.sleep(1) except: try: self.sign_page.wait_element("关闭1").click() time.sleep(1) except: print "关闭对话框"
class C33363_DFQP_Notice_HTML(TestCase): ''' 查看富文本公告 ''' owner = "LucyLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 5 def pre_test(self): self.start_step("初始化环境") self.common = Common() # 初始化Luadriver self.luadriver = self.common.setupdriver() self.hall_page = Hall_Page() self.personinfo_page = Personinfo_Page() self.sign_page = Sign_Page() # PHPInterface.set_env(PHPInterface.PRE_REPUBLISH_ENV) return1 = PHPInterface.set_notice('公告自动化测试', "1111", id=103000, end_time=int(time.time() + 60 * 4), is_html=1) print return1 time.sleep(10) self.start_step("配置公告") try: self.luadriver.find_element_by_name("允许").click() except: print "未出现按钮" time.sleep(15) try: self.hall_page.wait_element("确认登陆").click() except: print "未出现登陆按钮" # print self.casedata['mid'] def run_test(self): ''' 测试用例 ''' self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") time.sleep(5) self.hall_page.screenshot("notice.png") self.sign_page.wait_element("关闭1").click() def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' self.common.closedriver()
class C30962_DFQP_Sign_VIPtab(TestCase): ''' 签到界面vip购买 ''' owner = "Lucyliu" status = EnumStatus.Design priority = EnumPriority.High timeout = 5 def pre_test(self): self.common = Common() # 初始化Luadriver self.luadriver = self.common.setupdriver() # 每个用例都需要关闭活动,把这个放在初始化里面实现 self.common.closeactivity_switchserver(self.luadriver) self.hall_page = Hall_Page() self.sign_page = Sign_Page() def run_test(self): self.start_step("等待页面加载完成") time.sleep(1) self.hall_page.wait_element("同步标志") self.start_step("进入任务页面") self.hall_page.wait_element("任务").click() time.sleep(4) self.hall_page.wait_element("每日任务页面") time.sleep(1) self.start_step("切换每日签到页面") self.sign_page.get_element("每日签到tag").click() time.sleep(2) try: self.sign_page.wait_element("签到页面返回").click() time.sleep(2) except: print "签到无需返回" self.start_step("点击开通vip") try: self.sign_page.wait_element("开通vip").click() except: print "无此按钮" try: self.sign_page.wait_element("续费vip").click() except: print "无此按钮" time.sleep(2) self.sign_page.screenshot('VIPtab.png') def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' self.common.closedriver()
def pre_test(self): self.common = Common() self.hall_page = Hall_Page() self.mall_page = Mall_Page() self.sign_page = Sign_Page() self.backpack_page = Backpack_Page() self.personinfo_page = Personinfo_Page() global mid mid = self.common.get_config_value("casecfg","mid") self.common.set_coin(mid,value=50000) self.start_step("初始化driver") self.luadriver = self.common.setupdriver() self.common.closeactivity(self.luadriver)
def closeActivityBtn(self): ''' 关闭活动弹框 :return: ''' self.sign_page = Sign_Page() i = 0 while (i < 4): i += 1 try: self.sign_page.wait_element("关闭1",8).click() except: print "关闭对话框"
class C010_DFQP_Sign(TestCase): ''' 每日签到 ''' owner = "Lucyliu" status = EnumStatus.Design priority = EnumPriority.High timeout = 5 def pre_test(self): self.common = Common() # 初始化Luadriver self.luadriver = self.common.setupdriver() self.sign_page = Sign_Page() self.hall_page = Hall_Page() def run_test(self): ''' 测试用例 ''' time.sleep(4) try: self.luadriver.find_element_by_xpath('//*[contains(@text, "允许")]').click() except: "未出现按钮" self.start_step("等待页面加载完成") time.sleep(10) #声明方法 self.start_step("开始签到") try: self.hall_page.wait_element("确认登陆").click() except: "未出现登陆按钮" try: if (self.sign_page.wait_element("每日签到页面")): self.sign_page.wait_element("签到").click() self.sign_page.screenshot('C010_DFQP_Sign.png') print "签到成功" time.sleep(2) except: print "没有签到" self.common.closeactivity(self.luadriver) self.common.closefloatBall() self.start_step("验证签到是否成功") self.hall_page.wait_element("任务").click() time.sleep(3) self.start_step("切换每日签到页面") self.sign_page.get_element("每日签到页面").click() time.sleep(3) self.sign_page.wait_element("获取") def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' self.common.closedriver()