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)
Пример #2
0
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'测试用例执行失败,请检查')
Пример #3
0
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:
    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()
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