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.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.mall_page = Mall_Page()
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 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() 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)
class C31060_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) PHPInterface.add_money(self.casedata['mid'], 53000) # 每个用例都需要关闭活动,把这个放在初始化里面实现 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()
def pre_test(self): self.common = Common() global mid mid = self.common.get_config_value("casecfg", "mid") self.common.set_coin(mid=mid, value='20000') self.common.set_crystal(mid=mid,value='450') # 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(self.luadriver)
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)
class C31060_DFCP_Mall_Interface_GetPro(TestCase): ''' 商城购买道具 ''' owner = "LucyLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 5 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=mid, value='53000') # global user_info # user_info = self.common.get_user() # print user_info self.luadriver = self.common.setupdriver() # 每个用例都需要关闭活动,把这个放在初始化里面实现 self.common.closeactivity(self.luadriver) def run_test(self): self.start_step("等待页面加载完成") self.start_step("进入商城页面") self.hall_page.wait_element("商城").click() self.mall_page.wait_element("道具页签").click() 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() self.common.recover_user(mid)
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 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)
class C31056_DFQP_Mall(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.common.closeactivity_switchserver(self.luadriver,"预发布") self.hall_page = Hall_Page() self.mall_page = Mall_Page() def run_test(self): ''' 测试用例 ''' self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") self.start_step("进入商城页面") self.hall_page.wait_element("商城").click() time.sleep(5) self.mall_page.get_element("金条商品").click() time.sleep(2) self.mall_page.screenshot('zhifu.png') time.sleep(2) try: self.mall_page.get_element("支付宝").click() self.mall_page.screenshot('zhifubao.png') except: print "需升级为手机号码" def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' self.common.closedriver()
class C31034_DFCP_Backpack_GetPro(TestCase): ''' 购买道具,商城购买道具,查看物品箱 ''' owner = "LucyLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 5 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 run_test(self): self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") self.start_step("进入物品箱页面") self.hall_page.wait_element("物品箱").click() self.hall_page.screenshot('Backpack_Enterpack1.png') self.luadriver.keyevent(4) self.start_step("进入商城页面") self.hall_page.wait_element("商城").click() self.mall_page.wait_element("道具页签").click() self.start_step("购买道具") self.mall_page.wait_element("提示卡").click() self.sign_page.wait_element("购买").click() self.mall_page.wait_element("返回").click() self.start_step("进入物品箱页面") self.hall_page.wait_element("物品箱").click() self.hall_page.screenshot('buy.png') def post_test(self): # self.common.release_user(user_info['mid']) # self.common.deletefile(self.luadriver) self.common.recover_user(mid=mid) self.common.closedriver()
class C31034_DFCP_Backpack_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.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 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('buy.png') def post_test(self): # self.common.release_user(user_info['mid']) # self.common.deletefile(self.luadriver) self.common.closedriver()
class C31049_DFQP_Mall(TestCase): ''' 商城界面显示 ''' owner = "MindyZhang" 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.mall_page = Mall_Page() def run_test(self): ''' 测试用例 ''' self.start_step("等待页面加载完成") self.hall_page.wait_element("同步标志") self.start_step("进入商城页面") self.hall_page.wait_element("商城").click() time.sleep(2) self.mall_page.get_element("银币页签").click() time.sleep(2) self.mall_page.screenshot('Mall1.png') self.mall_page.wait_element("金条页签").click() time.sleep(2) self.mall_page.screenshot('Mall2.png') self.mall_page.wait_element("道具页签").click() time.sleep(2) self.mall_page.screenshot('Mall3.png') self.mall_page.wait_element("VIP页签").click() time.sleep(2) self.mall_page.screenshot('Mall4.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()
class PerTest_QIPAIHALL_Mall(TestCase): ''' 商城操作 ''' owner = "JessicZeng" status = EnumStatus.Design priority = EnumPriority.High timeout = 5 def pre_test(self): self.common = Common() self.hall_page = Hall_Page() self.mall_Page = Mall_Page() def run_test(self): ''' 测试步骤 1、大厅点击商城入口 2、点击第一金条购买item,关闭购买框 3、滑动金条购买列表 4、切换到银币购买列表 5、滑动银币购买列表 6、切换到道具列表 7、执行购买第一个道具操作,打开购买弹框后取消购买操作 8、滑动道具列表 9、切换到VIP页 10、返回大厅 不同类型的商品列表,共用listView和Item ''' self.hall_page.wait_element("同步标志") self.start_step("点击大厅商城入口") self.common.sendTagBroadcast(EnumSceneName.Mall, EnumSceneType.Start) try: #点击商城 self.hall_page.get_element("商城", 0).click() time.sleep(2) self.mall_Page.wait_element("同步标志") self.common.taskScreenShot("openMallPop.jpg") #购买金条(选择第一个item)并滑动金条列表 self.start_step("购买金条") self.mall_Page.get_element("item0", 0).click() self.mall_Page.wait_element("金条购买框Flag") self.common.taskScreenShot("buyGoldPop.jpg") self.mall_Page.get_element("金条购买框关闭", 0).click() time.sleep(1) self.start_step("滑动金条列表") self.common.swipeList(self.mall_Page.get_element("物品列表")) #切换到银币页并滑动列表 self.start_step("切换到银币Tab") self.mall_Page.get_element("银币Tab", 0).click() time.sleep(2) self.common.taskScreenShot("silverView.jpg") self.start_step("滑动银币列表") self.common.swipeList(self.mall_Page.get_element("物品列表")) #切换到道具页面,并查看购买道具框,最后滑动列表 self.start_step("切换到道具Tab") self.mall_Page.get_element("道具Tab", 0).click() time.sleep(2) self.common.taskScreenShot("propView.jpg") self.start_step("购买道具") self.mall_Page.get_element("item0", 0).click() self.mall_Page.wait_element("道具购买框Flag") self.common.taskScreenShot("buyPropPop.jpg") self.mall_Page.get_element("道具购买框关闭", 0).click() time.sleep(1) self.start_step("滑动道具列表") self.common.swipeList(self.mall_Page.get_element("物品列表")) #切换到VIP self.start_step("切换到VIPTab") self.mall_Page.get_element("VIPTab", 0).click() time.sleep(2) self.common.taskScreenShot("vipView.jpg") #关闭商城弹框 self.mall_Page.get_element("商城关闭", 0).click() except: self.common.platformLog("操作商城失败") finally: self.common.checkPopVisible(self.mall_Page) self.hall_page.wait_element("同步标志") time.sleep(5) self.common.sendTagBroadcast(EnumSceneName.Mall, EnumSceneType.Stop)
class C31053_DFCP_Mall_Interface_GetPro(TestCase): ''' 金条购买银币 ''' owner = "LucyLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 15 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) # 每个用例都需要关闭活动,把这个放在初始化里面实现 # self.common.closeactivitytest(self.luadriver) # 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(4) self.mall_page.wait_element("银币页签").click() time.sleep(2) self.start_step("购买道具") time.sleep(4) try: self.hall_page.wait_element("立即升级绑定账号").click() time.sleep(3) self.sign_page.wait_element("关闭1").click() time.sleep(4) except: print "未出现立即升级绑定账号按钮" self.mall_page.wait_element("银币购买1").click() time.sleep(5) while (self.hall_page.element_is_exist("立即升级绑定账号")): self.sign_page.wait_element("关闭1").click() while (self.mall_page.element_is_exist("银币页面购买") == False): self.mall_page.wait_element("银币购买1").click() self.mall_page.wait_element("银币页面购买").click() time.sleep(5) self.hall_page.screenshot('buy.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)
class C31053_DFCP_Mall_Interface_GetPro(TestCase): ''' 金条购买银币 ''' owner = "LucyLiu" status = EnumStatus.Design priority = EnumPriority.High timeout = 15 def pre_test(self): self.common = Common() global mid mid = self.common.get_config_value("casecfg", "mid") self.common.set_coin(mid=mid, value='20000') self.common.set_crystal(mid=mid,value='450') # 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(self.luadriver) def run_test(self): self.start_step("等待页面加载完成") self.start_step("进入商城页面") self.hall_page.wait_element("商城").click() time.sleep(4) self.mall_page.wait_element("银币页签").click() time.sleep(2) self.start_step("购买道具") time.sleep(4) try: self.hall_page.wait_element("立即升级绑定账号").click() time.sleep(3) self.sign_page.wait_element("关闭1").click() time.sleep(4) except: print "未出现立即升级绑定账号按钮" self.mall_page.wait_element("银币购买1").click() time.sleep(5) while(self.hall_page.element_is_exist("立即升级绑定账号")): self.sign_page.wait_element("关闭1").click() while(self.mall_page.element_is_exist("银币页面购买")==False): self.mall_page.wait_element("银币购买1").click() self.mall_page.wait_element("银币页面购买").click() time.sleep(5) self.hall_page.screenshot('buy.png') def post_test(self): try: self.common.recover_user(mid) except: self.log_info("初始化银币金条报错") try: self.common.closedriver() except: self.log_info("close driver fail")
class C308_DFCP_Backpack_Interface_GivePro(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) self.start_step("添加金币,用于购买道具") PHPInterface.add_money(self.casedata['mid'], 53000) # 每个用例都需要关闭活动,把这个放在初始化里面实现 self.common.closeactivitytest(self.luadriver) self.start_step("用户登录") 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("购买道具") i = 0 while (i < 3): i += 1 try: self.sign_page.wait_element("提示卡").click() time.sleep(5) self.sign_page.wait_element("购买").click() except: time.sleep(1) 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.closedriver()