def pre_test(self): 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 = Common() # 初始化Luadriver self.luadriver = self.common.setupdriver() self.hall_page = Hall_Page() self.sign_page = Sign_Page() self.personinfo_page = Personinfo_Page() self.safebox_page = Safebox_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.common = Common() global user_info user_info = self.common.get_user() print user_info user_info1 = PHPInterface.get_user_info(user_info['mid']) # 获取玩家信息 coin = json.loads(user_info1).get('result', { 'coin': None }).get('coin') # 获取当前银币值 AddMoney = 60000 - coin PHPInterface.add_money(user_info['mid'], AddMoney) # 将银币值设为60000 crystal = json.loads(user_info1).get('result', { 'crystal': None }).get('crystal') # 获取当前金条值 AddCrystal = 1000 - crystal PHPInterface.add_crystal(user_info['mid'], AddCrystal) # 将金条数目置1000 # 初始化Luadriver self.luadriver = self.common.setupdriver() self.yuepai_page = Yuepai_Page() self.hall_page = Hall_Page() self.personinfo_page = Personinfo_Page() self.common.closeactivity_switchserver(self.luadriver, '预发布') self.hall_page.wait_element("头像").click() time.sleep(5) self.common.loginuser(user_info['user'], user_info['password']) self.common.closeActivityBtn()
def pre_test(self): UserID = self.casedata.get('mid2') print 'UserID:%s' % UserID 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 crystal = json.loads(user_info).get('result', { 'crystal': None }).get('crystal') # 获取当前金条值 AddCrystal = 1000 - crystal PHPInterface.add_crystal(UserID, AddCrystal) # 将金条数目置1000 self.common = Common() # 初始化Luadriver self.luadriver = self.common.setupdriver() self.yuepai_page = Yuepai_Page() self.hall_page = Hall_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 run_test(self): self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") self.start_step('进入保险箱页面') self.hall_page.wait_element('保险箱').click() self.safebox_page.wait_element('金条-老').click() Flag = True while Flag: # 将保险箱中的金条存款值置0 self.safebox_page.wait_element('减少金条/银条数目').click() savings = self.safebox_page.wait_element('存款').get_attribute( 'text') if int(savings) == 0: self.safebox_page.wait_element('确定---保险箱').click() Flag = False time.sleep(5) 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.start_step('进入保险箱页面') self.hall_page.wait_element('保险箱').click() self.safebox_page.wait_element('金条-老').click() self.start_step('获取当前金条值,存款值') coin = self.safebox_page.wait_element('现金').get_attribute('text') savings = self.safebox_page.wait_element('存款').get_attribute('text') print type(coin) print '当前金条值,存款值:%s,%s' % (coin, savings) self.start_step('点击-按钮') self.safebox_page.wait_element('减少金条/银条数目').click() self.start_step('获取点击-按钮后的金条值') coin1 = self.safebox_page.wait_element('现金').get_attribute('text') savings1 = self.safebox_page.wait_element('存款').get_attribute('text') print '点击-按钮后的金条值,存款值:%s,%s' % (coin1, savings1) if coin1 == coin and savings1 == savings: print '金条值未变,存款值未变' else: print '金条值改变,存款值改变' self.start_step('点击+按钮') self.safebox_page.wait_element('增加金条/银条数目').click() self.start_step('获取点击+按钮后的金条值') coin2 = self.safebox_page.wait_element('现金').get_attribute('text') savings2 = self.safebox_page.wait_element('存款').get_attribute('text') print '点击+按钮后的金条值,存款值:%s,%s' % (coin2, savings2) if coin2 == coin1 and savings2 == savings1: print '金条值未变,存款值未变' else: print '金条值改变,存款值改变' self.safebox_page.wait_element('确定---保险箱').click() time.sleep(1) self.personinfo_page.screenshot('.png')
def post_test(self): try: dict = PHPInterface.get_user_info(mid) # 获取玩家信息 crystal = eval(dict).get('result', { 'crystal': None }).get('crystal') # 获取当前金条值 coin = eval(dict).get('result', { 'coin': None }).get('coin') # 获取当前银币值 AddCrystal = 100 - crystal AddMoney = 20000 - int(coin) PHPInterface.add_money(mid, AddMoney) # 将设置银币值 PHPInterface.add_crystal(mid, AddCrystal) # 将金条数目置1000 except: self.log_info("初始化银币金条报错") try: self.common.closedriver() except: self.log_info("close driver fail") finally: self.common.release_user(mid)
def pre_test(self): self.common = Common() # global user_info,UserID # user_info = self.common.get_user() # print user_info # 初始化Luadriver self.luadriver = self.common.setupdriver() self.hall_page = Hall_Page() self.sign_page = Sign_Page() self.personinfo_page = Personinfo_Page() self.safebox_page = Safebox_Page() self.start_step("关闭活动,并切换到预发布") self.common.closeactivity_switchserver(self.luadriver) # UserID = user_info.get('mid') # print 'UserID:%s' % UserID cid = self.common.get_cid() global mid mid = PHPInterface.get_mid(cid, region=1) print "用户mid为:%s" % mid PHPInterface.add_crystal(mid,300) self.start_step("重新加载,让添加的银币生效") self.common.closeactivity_switchserver(self.luadriver)
def pre_test(self): UserID = self.casedata.get('mid') print 'UserID:%s' % UserID PHPInterface.add_crystal(UserID, 1000) 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.safebox_page = Safebox_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): UserID = self.casedata.get('mid2') print 'UserID:%s' % UserID PHPInterface.add_crystal(UserID, 400) 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.safebox_page = Safebox_Page() self.start_step("关闭活动,并切换到预发布") 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): self.common = Common() # global user_info # user_info = self.common.get_user() # print user_info 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() self.common.closeactivity_switchserver(self.luadriver) # time.sleep(1) self.start_step("获取账号mid") cid = self.common.get_cid() global mid mid = PHPInterface.get_mid(cid, region=1) print "用户mid为:%s" % mid # UserID = user_info.get('mid') # print 'UserID:%s' % UserID dict = PHPInterface.get_user_info(mid) # 获取玩家信息 crystal = eval(dict).get('result', { 'crystal': None }).get('crystal') # 获取当前金条值 #初始化银币 coin = eval(dict).get('result', {'coin': None}).get('coin') # 获取当前银币值 AddMoney = 20000 - int(coin) print AddMoney PHPInterface.add_money(mid, AddMoney) # 将设置银币值 AddCrystal = 450 - crystal PHPInterface.add_crystal(mid, AddCrystal) # 将金条数目置1400 # self.hall_page.wait_element("预发布").click() # time.sleep(15) # self.common.closeActivityBtn() self.common.closeactivity_switchserver(self.luadriver)
def pre_test(self): self.common = Common() global user_info,UserID user_info = self.common.get_user() print user_info UserID = user_info.get('mid') print 'UserID:%s' % UserID # 初始化Luadriver self.luadriver = self.common.setupdriver() self.hall_page = Hall_Page() self.sign_page = Sign_Page() self.personinfo_page = Personinfo_Page() self.safebox_page = Safebox_Page() 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 PHPInterface.add_crystal(UserID, 400) self.hall_page.wait_element("头像").click() time.sleep(5) self.common.loginuser(user_info['user'], user_info['password']) self.common.closeActivityBtn()