class C30958_DFQP_Start(TestCase): ''' 有网络时启动游戏 ''' owner = "Lucyliu" status = EnumStatus.Design priority = EnumPriority.Normal timeout = 5 def pre_test(self): #删除自动登陆文件,置为游客状态 self.common = Common() # 初始化Luadriver self.luadriver = self.common.setupdriver() # 声明方法 self.login_page = Login_Page() self.setting_page = Setting_Page() self.hall_page = Hall_Page() self.common.switchnetwork(self.luadriver, u"WIFI模式") #关闭活动页面 self.common.closeactivity_switchserver(self.luadriver, "预发布") def run_test(self): # 测试用例 self.hall_page.wait_element("同步标志") self.start_step("启动游戏") self.login_page.screenshot('Login.png') def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' self.common.closedriver()
class C30957_DFQP_Start_Nonetwork(TestCase): ''' 无网络,点击启动游戏,首次无网络时启动游戏 ''' owner = "Lucyliu" status = EnumStatus.Design priority = EnumPriority.Normal timeout = 5 def pre_test(self): #删除自动登陆文件,置为游客状态 self.common = Common() # 初始化Luadriver capabilities = {} capabilities['noReset'] = False #清除应用缓存 self.luadriver = self.common.setupdriver(capabilities) self.common.deletefile(self.luadriver) self.common.switchnetwork(self.luadriver, u"无网络") # 声明方法 self.login_page = Login_Page() #关闭活动页面 self.common.closeactivity_switchserver(self.luadriver, "预发布") def run_test(self): #测试用例 self.start_step("启动游戏") self.login_page.screenshot('GuestLogin1.png') def post_test(self): #测试用例执行完成后,清理测试环境 #设置网络 self.common.switchnetwork(self.luadriver, u"WIFI模式") self.common.closedriver()
class C001_DFQP_Login_GuestLogin(TestCase): ''' 无网络,点击启动游戏 ''' owner = "Lucyliu" status = EnumStatus.Design priority = EnumPriority.Normal timeout = 5 def pre_test(self): #删除自动登陆文件,置为游客状态 self.common = Common() # 初始化Luadriver self.luadriver = self.common.setupdriver() self.common.deletefile(self.luadriver) # 设置为无网络的方式 # 获取状态名 # self.get_connection_name1(self.luadriver.network_connection) # print self.luadriver.network_connection # self.luadriver.set_network_connection(0) self.common.switchnetwork(self.luadriver, u"无网络") # 声明方法 self.login_page = Login_Page() def run_test(self): #测试用例 self.start_step("启动游戏") time.sleep(15) self.start_step("设置网络弹出框") self.login_page.wait_element("设置网络").is_displayed() self.login_page.wait_element("关闭弹出页面").click() self.common.closeactivity(self.luadriver) self.start_step("点击物品箱,查看弹出框") self.login_page.wait_element("物品箱").click() time.sleep(2) self.login_page.wait_element("设置网络").click() time.sleep(2) self.start_step("进入手机网络设置页面") self.luadriver.find_elements_by_class_name( "android.widget.TextView")[0].is_displayed() self.login_page.screenshot('GuestLogin1.png') def post_test(self): #测试用例执行完成后,清理测试环境 #设置网络 self.luadriver.set_network_connection(ConnectionType.WIFI_ONLY) self.common.closedriver()
class C003_DFQP_Login_Login(TestCase): ''' 注册账号登陆,设置网络为无网络后,启动游戏 ''' owner = "Lucyliu" status = EnumStatus.Design priority = EnumPriority.Normal timeout = 5 def pre_test(self): self.common = Common() self.luadriver = self.common.setupdriver() if not self.common.isloginuser(self.luadriver): self.common.loginuser(self.casedata['user'], self.casedata['password']) self.common.switchnetwork(self.luadriver, u"无网络") # 声明方法 self.login_page = Login_Page() self.setting_page = Setting_Page() self.hall_page = Hall_Page() def run_test(self): #测试用例 self.hall_page.wait_element("同步标志") time.sleep(12) self.start_step("无网络,进入游戏页面") self.login_page.wait_element("设置网络").is_displayed() self.login_page.wait_element("关闭弹出页面").click() self.common.closeactivity(self.luadriver) self.login_page.wait_element("物品箱").click() time.sleep(2) self.login_page.wait_element("设置网络").click() time.sleep(2) self.start_step("进入手机网络设置页面") self.luadriver.find_elements_by_class_name( "android.widget.TextView")[0].is_displayed() self.login_page.screenshot('Login_UseLogin1.png') def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' self.common.switchnetwork(self.luadriver, "WIFI模式") self.common.closedriver()
class C002_DFQP_Switchtoback1(TestCase): ''' 游客登陆,切后台登录后切换到后台5分钟再启动游戏 ''' owner = "Lucyliu" status = EnumStatus.Design priority = EnumPriority.Normal timeout = 5 def pre_test(self): #删除自动登陆文件,置为游客状态 self.common = Common() # 初始化Luadriver self.luadriver = self.common.setupdriver() self.common.deletefile(self.luadriver) # 声明方法 self.login_page = Login_Page() self.setting_page = Setting_Page() self.hall_page = Hall_Page() def run_test(self): # 测试用例 self.hall_page.wait_element("同步标志") self.start_step("启动游戏") time.sleep(10) self.luadriver.keyevent(3) # home time.sleep(20) #拉起游戏 self.luadriver.start_activity("com.boyaa.enginedlqp.maindevelop", "com.boyaa.enginedlqp.maindevelop.Game") time.sleep(10) try: self.hall_page.wait_element("重新登录").click() except: print "未找到按钮" self.login_page.screenshot('Switchtoback1.png') def post_test(self): ''' 测试用例执行完成后,清理测试环境 ''' self.common.closedriver()
class C74637_DFQP_Start_Nonetwork(TestCase): ''' 无网络,点击启动游戏,首次无网络时启动游戏 ''' owner = "Lucyliu" status = EnumStatus.Design priority = EnumPriority.Normal timeout = 5 def pre_test(self): #删除自动登陆文件,置为游客状态 self.common = Common() # 初始化Luadriver capabilities = {} capabilities['noReset'] = False #清除应用缓存 self.luadriver = self.common.setupdriver(capabilities) config = ConfigHelper(constant.cfg_path) global deviceName deviceName = config.getValue('appium', 'deviceName') self.common.switchnetwork(self.luadriver, u"无网络") print self.luadriver.network_connection # if self.luadriver.network_connection == 2: # cmd = "adb -s " + deviceName + " shell am broadcast -a io.appium.settings.wifi --es setstatus disable" # print cmd # subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # try: # self.luadriver.find_element_by_android_uiautomator('new UiSelector().text("允许")').click() # except: # print "未出现按钮1" # 声明方法 self.login_page = Login_Page() self.hall_page = Hall_Page() #关闭活动页面 self.common.closeactivity_switchserver(self.luadriver) # time.sleep(10) def run_test(self): #测试用例 self.start_step("启动游戏") self.hall_page.wait_element("头像") self.login_page.screenshot('GuestLogin1.png') # self.hall_page.wait_element("头像").click() # self.hall_page.element_is_exist("头像") def post_test(self): #测试用例执行完成后,清理测试环境 self.common.switchnetwork(self.luadriver, u"WIFI模式") print self.luadriver.network_connection if self.luadriver.network_connection != 2: t1 = threading.Thread(target=self.switchnetwork) t2 = threading.Thread(target=self.closebtn) t1.start() t2.start() t1.join() t2.join() self.start_step("close driver") self.common.closedriver() def switchnetwork(self): ''' 测试用例运行过程中切换网络 ''' cmd = "shell am start -n com.example.unlock/.Unlock" print "adb start:" + str(time.time()) self.luadriver.adb(cmd) print "adb end:" + str(time.time()) def closebtn(self): time.sleep(1) print "closebtn" + str(time.time()) try: self.luadriver.find_element_by_android_uiautomator( 'new UiSelector().textMatches("确定|允许")').click() print "close1" + str(time.time()) except: print "1" + str(time.time()) try: self.luadriver.find_element_by_android_uiautomator( 'new UiSelector().textMatches("确定|允许")').click() print "close2" + str(time.time()) except: print "2" + str(time.time()) try: self.luadriver.find_element_by_android_uiautomator( 'new UiSelector().textMatches("确定|允许")').click() print "close3" + str(time.time()) except: print "3" + str(time.time())