class TestClass: def setup(self): print("Test Start") self.log = MyLog() self.env2 = "Wristband_Alpha" self.moudle = Moudle(self.env2) self.log.debug(u'初始化测试数据') def teardown(self): print("Test End") @allure.story("wyzeband通过性验证") @allure.severity('blocker') @pytest.mark.smoke def test_wyzeband_smoke(self): self.moudle.bind() #绑定手环 self.moudle.get_token() #获取设备Token(不传参) self.moudle.get_token_data() #获取设备Token(传参) self.moudle.user_info() #获取用户信息 self.moudle.set_defaultconn() #设置默认连接的key self.moudle.get_defaultconn() #获取设备对应的默认自动连接设置 self.moudle.get_functions() #获取版本对应的功能列表(不包括基础功能) self.moudle.data_upload() #上传数据 self.moudle.get_sleep() #获取睡眠数据 self.moudle.get_step() #获取步数统计数据 self.moudle.get_heart_rate() #获取心率统计数据 self.moudle.get_sport_history() #获取运动历史 self.moudle.get_heart_rate_history() #获取某天的心率 self.moudle.get_band_bg_list() #获取手环背景图 self.moudle.upload_band_bg() #上传手环背景图 self.moudle.upload_taglog() #用户打点数据上报 self.moudle.unbind() #解绑手环
def setup(self): print("Test Start") self.log = MyLog() desired_caps = Yamlc(yaml_path).get_yaml_data(3, "Model", "desired_caps") self.desired_caps = desired_caps self.app = App(desired_caps) self.log.debug(u'初始化测试数据')
class TestClass: def setup(self): print("Test Start") self.log = MyLog() desired_caps = Yamlc(yaml_path).get_yaml_data(3, "Model", "desired_caps") self.desired_caps = desired_caps self.app = App(desired_caps) self.log.debug(u'初始化测试数据') def teardown(self): print("Test End") @allure.story("设备升级") @allure.severity('blocker') @pytest.mark.smoke def test_upgradewyze_smoke(self): self.driver = self.app.open_app() # self.app.click_prompt_box() if self.app.object_exist("*****@*****.**") == False: self.app.login_wyze("*****@*****.**", "Yxz@2020") self.app.upgrade_wyze("1.0.7.81") self.app.upgrading() time.sleep(5) self.app.upgrade_wyze_again("1.0.7.78") self.app.upgrading() self.app.close_app()
def setup(self): print("Test Start***********************") self.config = ReadConfig(config_path) self.login_host = self.config.get_value("Wristband_Alpha", "host").encode('utf-8') #config文件获取host firmware_ver = self.config.get_value("Wristband_Alpha", "firmware_ver").encode('utf-8') self.yaml = Yamlc(yaml_path).get_yaml_data(1, "bind_device") self.method = Yamlc(yaml_path).get_yaml_data(1, "bind_device", "method") self.url = Yamlc(yaml_path).get_yaml_data(1, "bind_device", "url") self.parm = Yamlc(yaml_path).get_yaml_data(1, "bind_device", "parm") self.expect = Yamlc(yaml_path).get_yaml_data(1, "bind_device", "expect") #yaml文件获取传入参数 self.parm2 = Yamlc(yaml_path).get_yaml_data(2, "bind_device", "parm") self.expect2 = Yamlc(yaml_path).get_yaml_data(2, "bind_device", "expect") self.parm3 = Yamlc(yaml_path).get_yaml_data(3, "bind_device", "parm") self.expect3 = Yamlc(yaml_path).get_yaml_data(3, "bind_device", "expect") self.parm4 = Yamlc(yaml_path).get_yaml_data(4, "bind_device", "parm") self.expect4 = Yamlc(yaml_path).get_yaml_data(4, "bind_device", "expect") self.parm5 = Yamlc(yaml_path).get_yaml_data(5, "bind_device", "parm") self.expect5 = Yamlc(yaml_path).get_yaml_data(5, "bind_device", "expect") self.parm6 = Yamlc(yaml_path).get_yaml_data(6, "bind_device", "parm") self.expect6 = Yamlc(yaml_path).get_yaml_data(6, "bind_device", "expect") self.parm7 = Yamlc(yaml_path).get_yaml_data(7, "bind_device", "parm") self.expect7 = Yamlc(yaml_path).get_yaml_data(7, "bind_device", "expect") env2 = "Wristband_Alpha" Returndata = Session().get_wristband_session(env2) self.wirst_cookies = Returndata[0] #获取wrist端的cookies self.headers = Returndata[1] #获取wrist端的headers self.headers['firmware_ver'] = firmware_ver self.url = self.login_host + self.url self.parm['device_token'] = self.wirst_cookies self.log = MyLog() self.log.debug(u'初始化测试数据')
class TestClass: def setup(self): print("Test Start") self.log = MyLog() desired_caps = Yamlc(yaml_path).get_yaml_data(1, "Model", "desired_caps") desired_caps2 = Yamlc(yaml_path).get_yaml_data(2, "Model", "desired_caps") self.wyzeband_mac = "2C:AA:8E:8F:03:52" self.desired_caps = desired_caps self.app = App(desired_caps) self.app_setting = App(desired_caps2) self.log.debug(u'初始化测试数据') def teardown(self): # self.app.find_elementby(By.XPATH, "//*[@text='解绑']").click() self.app.close_app() #关闭App print("Test End") @allure.story("模拟Brandy设备端操作验证") @allure.severity('blocker') @pytest.mark.smoke def test_wyzewatch_smoke(self): self.driver = self.app.open_app() time.sleep(1) for i in range(1, 100): self.app.devices_click('BRANDY_设备') time.sleep(1) while self.app.object_exist(self.wyzeband_mac + " 正在连接...") : time.sleep(1) if self.app.object_exist(self.wyzeband_mac + " 已连接") == False: self.app.devices_click('解绑') self.app.click_prompt_box() if (self.app.object_exist("realme Watch Saturn") or self.app.object_exist("WYZE") or self.app.object_exist("hey+")) == False: self.app.close_app() self.app_setting.restart_bluetooth() #重启蓝牙 self.driver = self.app.open_app() self.app.devices_click('BRANDY_设备') self.app.devices_click('解绑') while self.app.object_exist(self.wyzeband_mac) == False: time.sleep(1) self.app.devices_click(self.wyzeband_mac) while self.app.object_exist("请在设备上点击确认") == False: time.sleep(1) self.app.devices_click('完成') self.app.devices_click('BRANDY_设备') self.app.brandy_inputclick("160", "240") self.driver.keyevent(4) self.app.devices_click('BRANDY_设备') try: self.log.debug(u'运行次数:' + str(i)) assert(self.app.object_exist(self.wyzeband_mac + " 已连接")) self.device_clickDID() self.app.assert_getdevicepagename('home_page') self.log.debug(u'进入表盘主页面成功') self.app.find_elementby(By.XPATH, "//*[@text='解绑']").click() self.log.debug(u'解绑成功') except: self.log.error(u'绑定解绑第N次运行失败:' + str(i)) time.sleep(6) self.driver.keyevent(4) self.driver.keyevent(4)
class TestClass: def setup(self): print("Test Start") self.config = ReadConfig(config_path) self.login_host = self.config.get_value("Wristband_Alpha", "host") self.login_host = self.login_host.encode('utf-8') #config文件获取host self.yaml = Yamlc(yaml_path).get_yaml_data(1, "get_historysport") self.method = Yamlc(yaml_path).get_yaml_data(1, "get_historysport", "method") self.url = Yamlc(yaml_path).get_yaml_data(1, "get_historysport", "url") self.parm = Yamlc(yaml_path).get_yaml_data(1, "get_historysport", "parm") self.expect = Yamlc(yaml_path).get_yaml_data(1, "get_historysport", "expect") #yaml文件获取传入参数 self.url = self.login_host + self.url self.log = MyLog() self.log.debug(u'初始化测试数据') def teardown(self): print("Test End") case_name = Yamlc(yaml_path).get_yaml_data(1, "get_historysport", "case_name") @allure.story(case_name) @allure.severity('blocker') def test_get_historysport001(self): Returndata = Moudle("Wristband_Alpha").bind() self.headers = Returndata[1] r = Request().post_wirst_request(method=self.method, url=self.url, data=self.parm, header=self.headers) print(r) Assertions().assert_code(r['code'], self.expect['code']) Assertions().assert_code(r['status_code'], self.expect['status_code'])
def setup(self): print("Test Start") self.log = MyLog() desired_caps = Yamlc(yaml_path).get_yaml_data(1, "Model", "desired_caps") desired_caps2 = Yamlc(yaml_path).get_yaml_data(2, "Model", "desired_caps") self.wyzeband_mac = "2C:AA:8E:8F:03:52" self.desired_caps = desired_caps self.app = App(desired_caps) self.app_setting = App(desired_caps2) self.log.debug(u'初始化测试数据')
def setup(self): print("Test Start") self.log = MyLog() desired_caps = Yamlc(yaml_path).get_yaml_data(1, "Model", "desired_caps") desired_caps2 = Yamlc(yaml_path).get_yaml_data(2, "Model", "desired_caps") self.wyzeband_mac = "9C:F6:DD:38:1A:F5" # self.wyzeband_mac = "9C:F6:DD:38:19:59" # self.wyzeband_mac = "9C:F6:DD:38:18:75" self.desired_caps = desired_caps self.app = App(desired_caps) self.app_setting = App(desired_caps2) self.log.debug(u'初始化测试数据')
def setup(self): print("Test Start") self.config = ReadConfig(config_path) self.login_host = self.config.get_value("Wristband_Alpha", "host") self.login_host = self.login_host.encode('utf-8') #config文件获取host self.yaml = Yamlc(yaml_path).get_yaml_data(1, "get_historysport") self.method = Yamlc(yaml_path).get_yaml_data(1, "get_historysport", "method") self.url = Yamlc(yaml_path).get_yaml_data(1, "get_historysport", "url") self.parm = Yamlc(yaml_path).get_yaml_data(1, "get_historysport", "parm") self.expect = Yamlc(yaml_path).get_yaml_data(1, "get_historysport", "expect") #yaml文件获取传入参数 self.url = self.login_host + self.url self.log = MyLog() self.log.debug(u'初始化测试数据')
class AllTest(object): def __init__(self): global on_off self.log = MyLog() check_exsit("java.exe") # current_path = os.path.abspath(__file__) # father_path = os.path.abspath(os.path.dirname(current_path) + os.path.sep + "..") # report_path = father_path + "\\" + "Config\Config.ini" # self.report_path = report_path.replace("\\", "/") def run(self): try: self.log.info("********TEST START** ******") pytest.main() # pytest.main(['--alluredir', 'C:/Users/EDZ/PycharmProjects/untitled/ApiTest/Report/xml']) # os.system('allure generate C:/Users/EDZ/PycharmProjects/untitled/ApiTest/Report/xml -o C:/Users/EDZ/PycharmProjects/untitled/ApiTest/Report/html --clean') #将报告转换成HTML except: self.log.error(u'测试用例执行失败,请检查')
def __init__(self, env2): current_path = os.path.abspath(__file__) # 获取当前文件路径 father_path = os.path.abspath( os.path.dirname(current_path) + os.path.sep + "..") # 获取当前文件的祖父目录 config_path = father_path + "\\" + "Config\Config.ini" config_path = config_path.replace("\\", "/") self.file_path = father_path + "\\" + "Testdata\\space_flight.png" self.config = ReadConfig(config_path) self.log = MyLog() self.host = self.config.get_value(env2, "host").encode('utf-8') firmware_ver = self.config.get_value(env2, "firmware_ver").encode( 'utf-8') #生成token值之后'firmware_ver'字段获取设备的'version'值 self.Returndata = Session().get_wristband_session(env2) self.headers = self.Returndata[1] self.headers['firmware_ver'] = firmware_ver
class TestClass: def setup(self): print("Test Start") self.log = MyLog() desired_caps = Yamlc(yaml_path).get_yaml_data(1, "Model", "desired_caps") desired_caps2 = Yamlc(yaml_path).get_yaml_data(2, "Model", "desired_caps") self.wyzeband_mac = "9C:F6:DD:38:19:59" self.desired_caps = desired_caps self.app = App(desired_caps) self.app_setting = App(desired_caps2) self.log.debug(u'初始化测试数据') def teardown(self): self.app.close_app() #关闭App print("Test End") @allure.story("设备端通过性验证") @allure.severity('blocker') @pytest.mark.smoke def test_appwyze_smoke(self): self.driver = self.app.open_app() size = self.driver.get_window_size() self.app.find_elementby( By.XPATH, "//android.widget.Button[@text='BRANDY_APP']").click() time.sleep(5) if self.app.object_exist(self.wyzeband_mac + " 已连接") == False: self.app.find_elementby( By.XPATH, "//android.widget.Button[@text='解绑']").click() self.app.click_prompt_box() if self.app.object_exist_xpath( "//android.view.ViewGroup[@index='0']") == False: self.app.close_app() self.app_setting.restart_bluetooth() #重启蓝牙 self.driver = self.app.open_app() self.app.find_elementby( By.XPATH, "//android.widget.Button[@text='BRANDY_APP']").click() self.app.find_elementby( By.XPATH, "//android.widget.Button[@text='扫描']").click() time.sleep(5) self.app.find_elementby(By.XPATH, "//*[@text='" + self.wyzeband_mac + "']").click() time.sleep(5) if self.app.object_exist("请在设备上点击确认"): self.driver.keyevent(4) self.driver.keyevent(4) self.app.brandy_inputclick("160", "300") self.driver.keyevent(4) self.app.find_elementby( By.XPATH, "//android.widget.Button[@text='BRANDY_APP']").click() self.app.tv_device_info() #设备信息 self.app.tv_device_property() #设备电量 self.app.tv_device_activity() #活动数据 self.app.tv_device_data() #数据同步 self.app.tv_find_device() #查找手环 self.app.tv_reboot_device("BRANDY_APP") #重启手环 self.app.tv_send_notification({ "telephony": { "contact": "reeyx", "number": "1234567", "status": "RINGING_UNANSWERABLE" }, "type": "TELEPHONY" }) #发送通知 self.app.tv_send_notification({ "appMessage": { "appId": "app.facebook", "text": "ryeex text", "title": "ryeex title" }, "type": "APP_MESSAGE" }) self.app.tv_send_notification({ "sms": { "contact": "ryeex contact", "content": "ryeex content", "sender": "1234567" }, "type": "SMS" }) self.app.tv_set_app_list("2,3,5,6,7,8,11,12,13,14,15") #设置应用排序 self.app.tv_app_list("2, 3, 5") #获取应用排序 self.app.swpe(size['width'] * 0.25, size['height'] * 0.85, size['width'] * 0.25, size['height'] * 0.5) self.app.tv_setDoNotDisturb({ "homeVibrate": 0, "lunchModeEnable": 0, "mode": "ALWAYS", "raiseToWake": 0 }) #设置勿扰模式 self.app.tv_getDoNotDisturb("ALWAYS") #获取勿扰模式 self.app.tv_setDoNotDisturb({ "homeVibrate": 0, "lunchModeEnable": 0, "mode": "DISABLE", "raiseToWake": 0 }) self.app.tv_getDoNotDisturb("DISABLE") self.app.tv_setDoNotDisturb({ "homeVibrate": 0, "lunchModeEnable": 0, "mode": "SMART", "raiseToWake": 0 }) self.app.tv_getDoNotDisturb("SMART") self.app.tv_setDoNotDisturb({ "durations": [{ "endTimeHour": 12, "endTimeMinute": 30, "startTimeHour": 10, "startTimeMinute": 30 }], "homeVibrate": 0, "lunchModeEnable": 0, "mode": "TIMING", "raiseToWake": 0 }) self.app.tv_getDoNotDisturb("TIMING") self.app.tv_setDeviceRaiseToWake({ "enable": True, "endTimeHour": 10, "endTimeMinute": 00, "startTimeHour": 8, "startTimeMinute": 00 }) #设置抬腕亮屏 self.app.tv_getDeviceRaiseToWake(True) #获取抬腕亮屏 self.app.tv_setDeviceRaiseToWake({"enable": False}) self.app.tv_getDeviceRaiseToWake(False) self.app.swpe(size['width'] * 0.25, size['height'] * 0.95, size['width'] * 0.25, size['height'] * 0.5) self.app.tv_setHeartRateDetect({ "enable": True, "interval": 5 }) #设置心率检测 self.app.tv_getHeartRateDetect(5) #获取心率检测 self.app.tv_setHeartRateDetect({"enable": False}) self.app.tv_getHeartRateDetect(False) self.app.tv_setDeviceBrightness("MID") #设置屏幕亮度 self.app.tv_getDeviceBrightness("MID") #获取屏幕亮度 self.app.tv_setDeviceBrightness("LOW") self.app.tv_getDeviceBrightness("LOW") self.app.tv_setDeviceBrightness("HIGH") self.app.tv_setDeviceBrightness("HIGH") self.app.tv_setHomeVibrateSetting(True) #设置震动开关 self.app.tv_getHomeVibrateSetting(True) #获取震动开关 self.app.tv_setHomeVibrateSetting(False) self.app.tv_getHomeVibrateSetting(False) self.app.tv_setUnlock(1) #设置解锁方式 self.app.tv_getUnlock(1) #获取解锁方式 self.app.tv_setUnlock(0) self.app.tv_getUnlock(0) self.app.swpe(size['width'] * 0.25, size['height'] * 0.25, size['width'] * 0.25, size['height'] * 0.95)
class TestClass: def setup(self): print("Test Start") self.log = MyLog() desired_caps = Yamlc(yaml_path).get_yaml_data(1, "Model", "desired_caps") desired_caps2 = Yamlc(yaml_path).get_yaml_data(2, "Model", "desired_caps") self.wyzeband_mac = "9C:F6:DD:38:1A:F5" # self.wyzeband_mac = "9C:F6:DD:38:19:59" # self.wyzeband_mac = "9C:F6:DD:38:18:75" self.desired_caps = desired_caps self.app = App(desired_caps) self.app_setting = App(desired_caps2) self.log.debug(u'初始化测试数据') def teardown(self): # self.app.find_elementby(By.XPATH, "//*[@text='解绑']").click() # self.app.close_app() #关闭App print("Test End") @allure.story("模拟Saturn设备端操作验证") @allure.severity('blocker') @pytest.mark.smoke def test_wyzewatch_smoke(self): self.driver = self.app.open_app() time.sleep(1) self.app.devices_click('SATURN_APP') time.sleep(1) while self.app.object_exist(self.wyzeband_mac + " 正在连接..."): time.sleep(1) if self.app.object_exist(self.wyzeband_mac + " 已连接") == False: self.app.devices_click('解绑') self.app.click_prompt_box() if (self.app.object_exist("realme Watch Saturn") or self.app.object_exist("WYZE") or self.app.object_exist("hey+")) == False: self.app.close_app() self.app_setting.restart_bluetooth() #重启蓝牙 self.driver = self.app.open_app() self.app.devices_click('SATURN_设备') self.app.devices_click('解绑') while self.app.object_exist(self.wyzeband_mac) == False: time.sleep(1) self.app.devices_click(self.wyzeband_mac) while self.app.object_exist("请在设备上点击确认") == False: time.sleep(1) self.app.devices_click('完成') self.app.devices_click('SATURN_设备') self.app.saturn_inputclick("160", "240", "160", "240") self.driver.keyevent(4) self.app.devices_click('SATURN_设备') time.sleep(1) count = 1 for i in range(1, 1000): try: self.log.debug(str(i)) self.app.tv_send_notification( '{"telephony": {"contact": "reeyx' + str(i) + '", "number": ' + str(i) + ', "status": "RINGING_UNANSWERABLE"}, "type": "TELEPHONY"}' ) self.driver.keyevent(4) self.app.devices_click('SATURN_设备') self.app.assert_getdevicepagename('remind') self.app.saturn_inputclick("240", "240", "240", "240") self.driver.keyevent(4) self.app.devices_click('SATURN_APP') except: count = 1 + count self.log.error(str(count)) self.app.device_home() self.app.device_home() self.driver.keyevent(4) self.app.devices_click('SATURN_APP') time.sleep(3)
class TestClass(object): def setup(self): print("Test Start***********************") self.config = ReadConfig(config_path) self.login_host = self.config.get_value("Wristband_Alpha", "host").encode('utf-8') #config文件获取host firmware_ver = self.config.get_value("Wristband_Alpha", "firmware_ver").encode('utf-8') self.yaml = Yamlc(yaml_path).get_yaml_data(1, "bind_device") self.method = Yamlc(yaml_path).get_yaml_data(1, "bind_device", "method") self.url = Yamlc(yaml_path).get_yaml_data(1, "bind_device", "url") self.parm = Yamlc(yaml_path).get_yaml_data(1, "bind_device", "parm") self.expect = Yamlc(yaml_path).get_yaml_data(1, "bind_device", "expect") #yaml文件获取传入参数 self.parm2 = Yamlc(yaml_path).get_yaml_data(2, "bind_device", "parm") self.expect2 = Yamlc(yaml_path).get_yaml_data(2, "bind_device", "expect") self.parm3 = Yamlc(yaml_path).get_yaml_data(3, "bind_device", "parm") self.expect3 = Yamlc(yaml_path).get_yaml_data(3, "bind_device", "expect") self.parm4 = Yamlc(yaml_path).get_yaml_data(4, "bind_device", "parm") self.expect4 = Yamlc(yaml_path).get_yaml_data(4, "bind_device", "expect") self.parm5 = Yamlc(yaml_path).get_yaml_data(5, "bind_device", "parm") self.expect5 = Yamlc(yaml_path).get_yaml_data(5, "bind_device", "expect") self.parm6 = Yamlc(yaml_path).get_yaml_data(6, "bind_device", "parm") self.expect6 = Yamlc(yaml_path).get_yaml_data(6, "bind_device", "expect") self.parm7 = Yamlc(yaml_path).get_yaml_data(7, "bind_device", "parm") self.expect7 = Yamlc(yaml_path).get_yaml_data(7, "bind_device", "expect") env2 = "Wristband_Alpha" Returndata = Session().get_wristband_session(env2) self.wirst_cookies = Returndata[0] #获取wrist端的cookies self.headers = Returndata[1] #获取wrist端的headers self.headers['firmware_ver'] = firmware_ver self.url = self.login_host + self.url self.parm['device_token'] = self.wirst_cookies self.log = MyLog() self.log.debug(u'初始化测试数据') def teardown(self): print("Test End***********************") case_name = Yamlc(yaml_path).get_yaml_data(1, "bind_device", "case_name").encode('utf-8') @allure.story(case_name) @allure.severity('blocker') def test_bind_device001(self): r = Request().post_wirst_request(self.method, self.url, self.parm, header=self.headers) print(r) Assertions().assert_code(r['code'], self.expect['code']) Assertions().assert_code(r['status_code'], self.expect['status_code']) Assertions().assert_time(r['time_total'], self.expect['respones_time']) Assertions().assert_code(r['message'], self.expect['message']) Assertions().assert_code(r['data']['rst'], self.expect['data']['rst']) case_name = Yamlc(yaml_path).get_yaml_data(2, "bind_device", "case_name").encode('utf-8') @allure.story(case_name) @allure.severity('blocker') def test_bind_device002(self): self.parm2['device_token'] = self.wirst_cookies headers = self.headers.copy() headers['firmware_ver'] = '' r = Request().post_wirst_request(self.method, self.url, self.parm2, header=headers) print(r) Assertions().assert_code(r['code'], self.expect2['code']) Assertions().assert_code(r['status_code'], self.expect2['status_code']) case_name = Yamlc(yaml_path).get_yaml_data(3, "bind_device", "case_name").encode('utf-8') @allure.story(case_name) @allure.severity('blocker') def test_bind_device003(self): self.parm3['device_token'] = self.wirst_cookies headers = self.headers.copy() headers['access_token'] = 'AAAAAAAAAAAAAAAA' r = Request().post_wirst_request(self.method, self.url, self.parm3, header=headers) print(r) Assertions().assert_code(r['code'], self.expect3['code']) Assertions().assert_code(r['status_code'], self.expect3['status_code']) case_name = Yamlc(yaml_path).get_yaml_data(4, "bind_device", "case_name").encode('utf-8') @allure.story(case_name) @allure.severity('blocker') def test_bind_device004(self): self.parm4['device_token'] = self.wirst_cookies r = Request().post_wirst_request(self.method, self.url, self.parm4, header=self.headers) print(r) Assertions().assert_code(r['code'], self.expect4['code']) Assertions().assert_code(r['status_code'], self.expect4['status_code']) case_name = Yamlc(yaml_path).get_yaml_data(5, "bind_device", "case_name").encode('utf-8') @allure.story(case_name) @allure.severity('blocker') def test_bind_device005(self): self.parm5['device_token'] = self.wirst_cookies r = Request().post_wirst_request(self.method, self.url, self.parm5, header=self.headers) print(r) Assertions().assert_code(r['code'], self.expect5['code']) Assertions().assert_code(r['status_code'], self.expect5['status_code']) case_name = Yamlc(yaml_path).get_yaml_data(6, "bind_device", "case_name").encode('utf-8') @allure.story(case_name) @allure.severity('blocker') def test_bind_device006(self): self.parm6['device_token'] = self.wirst_cookies + 'Greey' r = Request().post_wirst_request(self.method, self.url, self.parm6, header=self.headers) print(r) Assertions().assert_code(r['code'], self.expect6['code']) Assertions().assert_code(r['status_code'], self.expect6['status_code'])
class TestClass: def setup(self): print("Test Start") self.config = ReadConfig(config_path) self.login_host = self.config.get_value("Wristband_Alpha", "host") self.login_host = self.login_host.encode('utf-8') #config文件获取host self.yaml = Yamlc(yaml_path).get_yaml_data(1, "unbind_device") self.method = Yamlc(yaml_path).get_yaml_data(1, "unbind_device", "method") self.url = Yamlc(yaml_path).get_yaml_data(1, "unbind_device", "url") self.parm = Yamlc(yaml_path).get_yaml_data(1, "unbind_device", "parm") self.expect = Yamlc(yaml_path).get_yaml_data(1, "unbind_device", "expect") #yaml文件获取传入参数 self.parm2 = Yamlc(yaml_path).get_yaml_data(2, "unbind_device", "parm") self.expect2 = Yamlc(yaml_path).get_yaml_data(2, "unbind_device", "expect") self.parm3 = Yamlc(yaml_path).get_yaml_data(3, "unbind_device", "parm") self.expect3 = Yamlc(yaml_path).get_yaml_data(3, "unbind_device", "expect") self.url = self.login_host + self.url self.log = MyLog() self.log.debug(u'初始化测试数据') def teardown(self): print("Test End") case_name = Yamlc(yaml_path).get_yaml_data(1, "unbind_device", "case_name") @allure.story(case_name) @allure.severity('blocker') def test_unbind_device001(self): Returndata = Moudle("Wristband_Alpha").bind() self.parm['device_token'] = Returndata[0] self.headers = Returndata[1] r = Request().post_wirst_request(method=self.method, url=self.url, data=self.parm, header=self.headers) print(r) Assertions().assert_code(r['code'], self.expect['code']) Assertions().assert_code(r['status_code'], self.expect['status_code']) Assertions().assert_time(r['time_total'], self.expect['respones_time']) Assertions().assert_code(r['message'], self.expect['message']) Assertions().assert_code(r['data']['rst'], self.expect['data']['rst']) case_name = Yamlc(yaml_path).get_yaml_data(2, "unbind_device", "case_name") @allure.story(case_name) @allure.severity('blocker') def test_unbind_device002(self): Returndata = Moudle("Wristband_Alpha").bind() self.parm2['device_token'] = Returndata[0] self.headers = Returndata[1] r = Request().post_wirst_request(method=self.method, url=self.url, data=self.parm2, header=self.headers) print(r) Assertions().assert_code(r['code'], self.expect2['code']) Assertions().assert_code(r['status_code'], self.expect2['status_code']) case_name = Yamlc(yaml_path).get_yaml_data(3, "unbind_device", "case_name") @allure.story(case_name) @allure.severity('blocker') def test_unbind_device002(self): Returndata = Moudle("Wristband_Alpha").bind() # self.parm3['device_token'] = Returndata[0] + 'Greey' self.headers = Returndata[1] r = Request().post_wirst_request(method=self.method, url=self.url, data=self.parm3, header=self.headers) print(r) Assertions().assert_code(r['code'], self.expect3['code']) Assertions().assert_code(r['status_code'], self.expect3['status_code'])
import pytest import os import time import allure from ApiTest.Common.Appcommon import App from ApiTest.Common.Readyaml import Yamlc from ApiTest.Common.Log import MyLog from selenium.webdriver.common.by import By import multiprocessing current_path = os.path.abspath(__file__) father_path = os.path.abspath( os.path.dirname(current_path) + os.path.sep + "../..") #获取上上级目录 yaml_path = father_path + "\\" + "Testdata\\app.yaml" log = MyLog() def initdata(): log.info(u'初始化测试数据') log.info(t1.name) log.info(t2.name) def smoke1(): info1 = "Process-1" desired_caps = Yamlc(yaml_path).get_yaml_data(1, "Model", "desired_caps") app = App(desired_caps) wyzeband_mac1 = "9C:F6:DD:38:1B:81" # App.start_appium(4723, 4724, "468207dd") driver = app.open_application('4723')
def __init__(self): global on_off self.log = MyLog() check_exsit("java.exe")
class TestClass: def setup(self): print("Test Start") self.log = MyLog() desired_caps = Yamlc(yaml_path).get_yaml_data(1, "Model", "desired_caps") desired_caps2 = Yamlc(yaml_path).get_yaml_data(2, "Model", "desired_caps") # self.wyzeband_mac = "2C:AA:8E:8F:00:9E" self.wyzeband_mac = "2c:aa:8e:8f:02:28" self.desired_caps = desired_caps self.app = App(desired_caps) self.app_setting = App(desired_caps2) self.log.debug(u'初始化测试数据') def teardown(self): self.app.close_app() #关闭App print("Test End") @allure.story("模拟Brandy设备端操作验证") @allure.severity('blocker') @pytest.mark.smoke def test_wyzewatch_smoke(self): self.driver = self.app.open_app() self.app.find_elementby( By.XPATH, "//android.widget.Button[@text='BRANDY_设备']").click() time.sleep(5) if self.app.object_exist(self.wyzeband_mac + " 已连接") == False: self.app.find_elementby( By.XPATH, "//android.widget.Button[@text='解绑']").click() self.app.click_prompt_box() if self.app.object_exist_xpath( "//android.view.ViewGroup[@index='0']") == False: self.app.close_app() self.app_setting.restart_bluetooth() #重启蓝牙 self.driver = self.app.open_app() self.app.find_elementby( By.XPATH, "//android.widget.Button[@text='BRANDY_设备']").click() self.app.find_elementby( By.XPATH, "//android.widget.Button[@text='扫描']").click() time.sleep(5) self.app.find_elementby(By.XPATH, "//*[@text='" + self.wyzeband_mac + "']").click() time.sleep(5) if self.app.object_exist("请在设备上点击确认"): self.driver.keyevent(4) self.driver.keyevent(4) self.app.brandy_inputclick("160", "300") self.driver.keyevent(4) self.app.find_elementby( By.XPATH, "//android.widget.Button[@text='BRANDY_设备']").click() # self.app.find_elementby(By.XPATH, "//@text='" + self.wyzeband_mac + " 已连接']") self.app.device_upslide() self.app.brandy_inputclick("80", "80") self.app.brandy_inputclick("240", "80") self.app.brandy_inputclick("240", "80") self.app.brandy_inputclick("240", "80") self.app.brandy_inputclick("80", "240") self.app.brandy_inputclick("240", "240") self.app.device_downslide() self.app.device_leftslide() self.app.device_rightslide()
class TestClass: def setup(self): print("Test Start") self.log = MyLog() desired_caps = Yamlc(yaml_path).get_yaml_data(1, "Model", "desired_caps") desired_caps2 = Yamlc(yaml_path).get_yaml_data(2, "Model", "desired_caps") self.wyzeband_mac = "9C:F6:DD:38:1A:F5" # self.wyzeband_mac = "9C:F6:DD:38:19:59" # self.wyzeband_mac = "9C:F6:DD:38:18:75" self.desired_caps = desired_caps self.app = App(desired_caps) self.app_setting = App(desired_caps2) self.log.debug(u'初始化测试数据') def teardown(self): # self.app.find_elementby(By.XPATH, "//*[@text='解绑']").click() # self.app.close_app() #关闭App print("Test End") @allure.story("模拟Saturn设备端操作验证") @allure.severity('blocker') @pytest.mark.smoke def test_wyzewatch_smoke(self): self.driver = self.app.open_app() time.sleep(1) self.app.devices_click('SATURN_设备') time.sleep(1) while self.app.object_exist(self.wyzeband_mac + " 正在连接...") : time.sleep(1) if self.app.object_exist(self.wyzeband_mac + " 已连接") == False: self.app.devices_click('解绑') self.app.click_prompt_box() if (self.app.object_exist("realme Watch Saturn") or self.app.object_exist("WYZE") or self.app.object_exist("hey+")) == False: self.app.close_app() self.app_setting.restart_bluetooth() #重启蓝牙 self.driver = self.app.open_app() self.app.devices_click('SATURN_设备') self.app.devices_click('解绑') while self.app.object_exist(self.wyzeband_mac) == False: time.sleep(1) self.app.devices_click(self.wyzeband_mac) while self.app.object_exist("请在设备上点击确认") == False: time.sleep(1) self.app.devices_click('完成') self.app.devices_click('SATURN_设备') self.app.saturn_inputclick("160", "240", "160", "240") self.driver.keyevent(4) self.app.devices_click('SATURN_设备') time.sleep(1) self.app.device_upslide() self.log.debug(u"向上滑动") for i in range(83, 250): try: # self.log.debug(str(i)) # self.app.device_upslide() # self.app.saturn_inputslide("160", "40", "160", "10") # self.app.saturn_inputclick("80", "315", "80", "315") # self.app.assert_getdevicepagename("sports") # self.app.device_upslide() # self.app.saturn_inputclick("160", "160", "160", "160") # time.sleep(200) # self.app.device_home() # self.app.device_home() # self.app.saturn_inputclick("80", "160", "80", "160") # self.app.saturn_inputclick("160", "300", "160", "300") # self.app.device_home() # self.app.device_home() # # self.app.device_upslide() # self.app.saturn_inputslide("160", "40", "160", "10") # self.app.saturn_inputclick("80", "315", "80", "315") # self.app.assert_getdevicepagename("sports") # self.app.device_upslide() # self.app.saturn_inputclick("160", "300", "160", "300") # time.sleep(200) # self.app.device_home() # self.app.device_home() # self.app.saturn_inputclick("80", "160", "80", "160") # self.app.saturn_inputclick("160", "300", "160", "300") # self.app.device_home() # self.app.device_home() self.log.debug(str(i)) self.app.saturn_inputclick("240", "80", "240", "80") self.app.assert_getdevicepagename("hrm") self.log.debug(u"进入心率功能") time.sleep(5) self.app.device_home() self.log.debug(u'点击home回到上级页面') self.app.saturn_inputclick("80", "240", "80", "240") self.app.assert_getdevicepagename("spo2") self.log.debug(u"进入血氧功能") time.sleep(5) self.app.device_home() self.log.debug(u'点击home回到上级页面') except: self.log.error(str(i)) self.app.device_home() self.app.device_home() self.app.device_upslide()
def setup(self): print("Test Start") self.log = MyLog() self.env2 = "Wristband_Alpha" self.moudle = Moudle(self.env2) self.log.debug(u'初始化测试数据')
class TestClass: def setup(self): print("Test Start") self.log = MyLog() desired_caps = Yamlc(yaml_path).get_yaml_data(1, "Model", "desired_caps") desired_caps2 = Yamlc(yaml_path).get_yaml_data(2, "Model", "desired_caps") self.wyzeband_mac = "9C:F6:DD:38:1A:F5" # self.wyzeband_mac = "9C:F6:DD:38:19:59" # self.wyzeband_mac = "9C:F6:DD:38:18:75" self.desired_caps = desired_caps self.app = App(desired_caps) self.app_setting = App(desired_caps2) self.log.debug(u'初始化测试数据') def teardown(self): # self.app.find_elementby(By.XPATH, "//*[@text='解绑']").click() # self.app.close_app() #关闭App print("Test End") @allure.story("模拟Saturn设备端操作验证") @allure.severity('blocker') @pytest.mark.smoke def test_wyzewatch_smoke(self): self.driver = self.app.open_app() time.sleep(1) self.app.devices_click('SATURN_设备') time.sleep(1) while self.app.object_exist(self.wyzeband_mac + " 正在连接..."): time.sleep(1) if self.app.object_exist(self.wyzeband_mac + " 已连接") == False: self.app.devices_click('解绑') self.app.click_prompt_box() if (self.app.object_exist("realme Watch Saturn") or self.app.object_exist("WYZE") or self.app.object_exist("hey+")) == False: self.app.close_app() self.app_setting.restart_bluetooth() #重启蓝牙 self.driver = self.app.open_app() self.app.devices_click('SATURN_设备') self.app.devices_click('解绑') while self.app.object_exist(self.wyzeband_mac) == False: time.sleep(1) self.app.devices_click(self.wyzeband_mac) while self.app.object_exist("请在设备上点击确认") == False: time.sleep(1) self.app.devices_click('完成') self.app.devices_click('SATURN_设备') self.app.saturn_inputclick("160", "240", "160", "240") self.driver.keyevent(4) self.app.devices_click('SATURN_设备') time.sleep(1) for i in range(30, 100): try: self.log.debug(u'运行次数:' + str(i)) self.driver.keyevent(4) self.app.devices_click('SATURN_APP') self.app.tv_send_notification( '{"appMessage": {"appId": "app.qq", "text": "reeyx' + str(i) + '", "title": ' + str(i) + '}, "type": "APP_MESSAGE"}') self.log.debug(u'发送通知成功') self.driver.keyevent(4) self.app.devices_click('SATURN_设备') # self.app.device_home() # self.log.debug(u'返回上级页面成功') # self.app.device_downslide() # self.log.debug(u'向下滑动成功') self.app.saturn_inputslide("160", "80", "160", "160") self.log.debug(u'向下滑动') self.app.saturn_inputslide("160", "160", "160", "80") self.log.debug(u'向上滑动') self.app.saturn_inputslide("160", "160", "160", "160") self.log.debug(u'点击消息') # self.app.assert_getdevicepagename('notification_box_detail') # self.log.debug(u'进入消息详情页面成功') # self.app.device_home() # self.log.debug(u'返回上级页面成功') # self.app.device_home() # self.log.debug(u'返回主页面成功') except: self.log.error(u'第N次运行失败:' + str(i)) raise