Esempio n. 1
0
    def query_inspection_page_language_assert(self):
        logger.info("断言:设置项-查看页面自检页语言,与数据库比对,返回True or False")
        value = self.get_element_text(loc.inspection_page_language,
                                      module="设置项-自检页语言")
        logger.info(f"---value-----:{value}")

        try:
            db_value = \
                HandleMysql().read_mysql(do_yaml.read_yaml("mysql", "query_inspection_page_language_sql"), DMIPD.SN)[
                    DMIPD.inspection_page_language]
        except:
            db_value = "简体中文"
        else:
            if db_value == 0:
                db_value = "简体中文"
            elif db_value == 1:
                db_value = "英文"
        finally:
            HandleMysql().close()
            logger.info(f"----db_value----:{db_value}")

        if value == db_value:
            return True
        else:
            return False
Esempio n. 2
0
    def query_dialect_assert(self):
        logger.info("断言:设置项-查看页面语音方言,与数据库比对,返回True or False")
        value = self.get_element_text(loc.dialect, module="设置项-语音方言")
        logger.info(f"---value-----:{value}")

        try:
            db_value = HandleMysql().read_mysql(
                do_yaml.read_yaml("mysql", "query_dialect_sql"),
                DMIPD.SN)[DMIPD.dialect]
        except:
            db_value = "普通话女声"
        else:
            if db_value == 0:
                db_value = "普通话男声"
            elif db_value == 1:
                db_value = "普通话女声"
            elif db_value == 2:
                db_value = "四川话"
            elif db_value == 3:
                db_value = "粤语"
        finally:
            HandleMysql().close()
            logger.info(f"----db_value----:{db_value}")

        if value == db_value:
            return True
        else:
            return False
Esempio n. 3
0
    def query_density_assert(self):
        logger.info("断言:设置项-查看页面打印浓度,与数据库比对,返回True or False")
        value = self.get_element_text(loc.density, module="设置项-打印浓度")
        logger.info(f"---value-----:{value}")

        try:
            db_value = HandleMysql().read_mysql(
                do_yaml.read_yaml("mysql", "query_density_sql"),
                DMIPD.SN)[DMIPD.density]
        except:
            db_value = "100%"
        else:
            if db_value == 75:
                db_value = "75%"
            elif db_value == 85:
                db_value = "85%"
            elif db_value == 100:
                db_value = "100%"
            elif db_value == 125:
                db_value = "125%"
            elif db_value == 150:
                db_value = "150%"
        finally:
            HandleMysql().close()
            logger.info(f"----db_value----:{db_value}")

        if value == db_value:
            return True
        else:
            return False
    def online_devices_number(self, ):
        logger.info("断言:查询页面在线打印机总数,并与数据库数据比对,返回True or False")

        # 从页面获取在线打印机总数
        online_devices_number = self.get_element_text(
            loc.device_count_and_online_number, "设备子界面-在线打印机总数")
        online_devices_number = online_devices_number.split("/")[1]

        logger.info(
            f"--------online_devices_number------{online_devices_number}")

        # 从数据库获取在线打印机数据
        db_value = HandleMysql().read_mysql(
            do_yaml.read_yaml(
                "mysql",
                "query_online_devices_number_sql"))[DMSPD.count_is_online]
        db_value = "在线" + str(db_value) + "台"

        logger.info(f"--------db_value------{db_value}")

        HandleMysql().close()

        if online_devices_number == db_value:
            return True
        else:
            return False
Esempio n. 5
0
    def query_voice_speed_assert(self):
        logger.info("断言:设置项-查看页面语音播报语速,与数据库比对,返回True or False")
        value = self.get_element_text(loc.voice_speed, module="设置项-语音播报语速")
        logger.info(f"---value-----:{value}")

        try:
            db_value = HandleMysql().read_mysql(
                do_yaml.read_yaml("mysql", "query_voice_speed_sql"),
                DMIPD.SN)[DMIPD.voice_speed]
        except:
            db_value = "50%"
        else:
            if db_value == 20:
                db_value = "20%"
            elif db_value == 50:
                db_value = "50%"
            elif db_value == 80:
                db_value = "80%"
        finally:
            HandleMysql().close()
            logger.info(f"----db_value----:{db_value}")

        if value == db_value:
            return True
        else:
            return False
    def device_log_state(self, td_index):
        logger.info("断言:查询页面的设备log开关状态,并与数据库数据比对,返回True or False")

        # 从页面获取log开关状态
        tr_list = self.get_element(loc.table_tbody,
                                   "获取tr为一个列表").find_elements_by_tag_name("tr")
        td_list = tr_list[0].find_elements_by_tag_name("td")
        log_state = td_list[td_index].text

        # 从数据库获取log开关状态
        value_db = HandleMysql().read_mysql(
            do_yaml.read_yaml("mysql", "query_log_switch_sql"),
            DMSPD.SN)[DMSPD.log_switch]
        HandleMysql().close()

        if log_state == "关":
            value = 0
        else:
            value = 1

        logger.info(f"---value:---{value}")
        logger.info(f"---value_db:---{value_db}")

        if value == value_db:
            return True
        else:
            return False
    def device_current_disconnect_time(self, td_index):
        logger.info("断言:查询页面SN的断开连接时间,并与数据库数据比对,返回True or False")

        # 从页面获取时间
        tr_list = self.get_element(
            loc.table_tbody,
            module="获取tr为一个列表").find_elements_by_tag_name("tr")
        td_list = tr_list[0].find_elements_by_tag_name("td")
        value = td_list[td_index].text
        logger.info(f"---value:---{value}")

        # 从数据库获取断连时间
        value_db = HandleMysql().read_mysql(
            do_yaml.read_yaml("mysql", "query_disconnect_time_sql"), DMSPD.SN)
        HandleMysql().close()

        value_db = value_db[DMSPD.disconnect_time]
        # 转换时间戳为需要格式
        value_db = switch_timestamp(value_db)
        logger.info(f"---value_db:---{value_db}")

        if value == value_db:
            return True
        else:
            return False
    def device_current_connect_time(self, td_index):
        logger.info("断言:查询页面SN的上次连入时间,并与数据库数据比对,返回True or False")

        # 从页面获取时间
        # 获取所有的tr 对象 为一个列表
        tr_list = self.get_element(
            loc.table_tbody,
            module="获取tr为一个列表").find_elements_by_tag_name("tr")
        td_list = tr_list[0].find_elements_by_tag_name("td")
        connect_time = td_list[td_index].text
        logger.info(f"--connect_time:--{connect_time}")

        # 从数据库中获取连接时间
        value = (HandleMysql().read_mysql(
            do_yaml.read_yaml("mysql", "query_connect_time_sql"),
            DMSPD.SN))[DMSPD.connect_time]
        # 关闭数据库
        HandleMysql().close()

        # 转换时间戳为需要格式
        connect_time_db = switch_timestamp(value)
        logger.info(f"--connect_time_db:--{connect_time_db}")

        if connect_time == connect_time_db:
            return True
        else:
            return False
Esempio n. 9
0
    def query_longitude_latitude_assert(self):
        logger.info("断言:点击设备信息-移动网络-查询经纬度,与数据库数据比较,返回Ture or False")

        value = self.get_element_text(loc.mni_current_longitude_latitude,
                                      module="获取页面经纬度")
        logger.info(f"---value-----:{value}")

        db_value_longitude = HandleMysql().read_mysql(
            do_yaml.read_yaml("mysql", "query_lng_sql"),
            DMIPD.SN)[DMIPD.longitude]

        db_value_latitude = HandleMysql().read_mysql(
            do_yaml.read_yaml("mysql", "query_lat_sql"),
            DMIPD.SN)[DMIPD.latitude]

        HandleMysql().close()

        if str(db_value_longitude) == "0E-7":
            db_value_longitude = "0.00"
        else:
            db_value_longitude = "{:.2f}".format(db_value_longitude)

        if str(db_value_latitude) == "0E-7":
            db_value_latitude = "0.00"
        else:
            db_value_latitude = "{:.2f}".format(db_value_latitude)

        db_value = "Lat: " + db_value_latitude + " " + "Lon: " + db_value_longitude  # Lat: 0.00 Lon: 0.00
        logger.info(f"----db_value----:{db_value}")

        if db_value == value:
            return True
        else:
            return False
Esempio n. 10
0
    def query_wifi_length_assert(self):
        logger.info("断言:点击wifi信息-查看页面wifi强度,与数据库数据比对,返回True or False")

        value = self.get_element_text(loc.wifi_length, module="查询页面wifi信号强度")

        if "." not in value:
            value = value.replace("dB", ".0dB")
        logger.info(f"---value-----:{value}")

        try:
            db_value = HandleMysql().read_mysql(
                do_yaml.read_yaml("mysql", "query_wifi_length_sql"),
                DMIPD.SN)[DMIPD.wifi_length]
        except:
            db_value = "--"
        else:
            db_value = str(db_value) + "dB"

        logger.info(f"----db_value----:{db_value}")

        HandleMysql().close()

        if db_value == value:
            return True
        else:
            return False
Esempio n. 11
0
    def test_68_click_log_button_to_on(self, device_more_info_device_log):
        logger.info("正常用例:点击设备log-点击log开关按钮打开log开关")
        sleep(3)
        device_more_info_device_log[7].click_log_button_to_on_obj()
        sleep(3)
        assert device_more_info_device_log[6].click_log_button_to_on_assert(
        ) == True

        HandleMysql().read_mysql(
            do_yaml.read_yaml("mysql", "update_log_swith_off"), [0, DMIPD.SN])
        HandleMysql().close()
Esempio n. 12
0
    def query_new_order_contents_assert(self):
        logger.info("断言:设置项-查看页面新订单播报内容,与数据库比对,返回True or False")

        value = self.get_element_text(loc.new_order_contents,
                                      module="设置项-新订单播报内容")
        logger.info(f"---value-----:{value}")

        try:
            db_value = HandleMysql().read_mysql(
                do_yaml.read_yaml("mysql", "query_new_order_contents_sql"),
                DMIPD.SN)[DMIPD.new_order_contents]
        except:
            db_value = "来源播报、备注播报"
        else:
            if db_value == "0,1,2,3":
                db_value = "来源播报、内容播报、金额播报、备注播报"
            elif db_value == "0,1,2":
                db_value = "来源播报、内容播报、金额播报"
            elif db_value == "0,1":
                db_value = "来源播报、内容播报"
            elif db_value == "0":
                db_value = "来源播报"
            elif db_value == "0,2":
                db_value = "来源播报、金额播报"
            elif db_value == "0,2,3":
                db_value = "来源播报、金额播报、备注播报"
            elif db_value == "0,3":
                db_value = "来源播报、备注播报"
            elif db_value == "1":
                db_value = "内容播报"
            elif db_value == "1,2":
                db_value = "内容播报、金额播报"
            elif db_value == "1,2,3":
                db_value = "内容播报、金额播报、备注播报"
            elif db_value == "1,3":
                db_value = "内容播报、备注播报"
            elif db_value == "2":
                db_value = "金额播报"
            elif db_value == "2,3":
                db_value = "金额播报、备注播报"
            elif db_value == "3":
                db_value = "备注播报"
            else:
                db_value = ""
        finally:
            HandleMysql().close()
            logger.info(f"----db_value----:{db_value}")

        if value == db_value:
            return True
        else:
            return False
Esempio n. 13
0
    def query_ldi_model_assert(self):
        logger.info("断言:本机信息-查询页面机型与数据库数据比较-返回True or Flase")

        value = self.get_element_text(loc.ldi_model, module="查询本机信息-机型型号")
        logger.info(f"---value-----{value}")

        db_value = HandleMysql().read_mysql(
            do_yaml.read_yaml("mysql", "query_hardware_model_sql"),
            DMIPD.SN)[DMIPD.hardware_model]
        HandleMysql().close()
        logger.info(f"----db_value----{db_value}")

        if value == db_value:
            return True
        else:
            return False
Esempio n. 14
0
    def query_signal_strength_assert(self):
        logger.info("断言:点击设备信息-移动网络-查询信号强度,与数据库数据比较,返回Ture or False")

        value = self.get_element_text(loc.mni_signal_strength,
                                      module="获取当前移动网络信号强度")

        if "." not in value:
            value = value.replace("dB", ".0dB")
        logger.info(f"---value-----:{value}")

        try:
            db_value = HandleMysql().read_mysql(
                do_yaml.read_yaml("mysql", "query_gprs_signal_sql"),
                DMIPD.SN)[DMIPD.gprs_signal]
        except:
            db_value = "--"
        else:
            db_value = str(db_value) + "dB"

        logger.info(f"----db_value----:{db_value}")

        if db_value == value:
            return True
        else:
            return False
Esempio n. 15
0
    def query_ldi_app_version_assert(self):
        logger.info("断言:本机信息-查询页面app版本与数据库数据比较-返回True or False")
        value = self.get_element_text(loc.ldi_app_version,
                                      module="查询本机信息-app版本")
        logger.info(f"---value-----{value}")

        db_value = HandleMysql().read_mysql(
            do_yaml.read_yaml("mysql", "query_app_version_sql"),
            DMIPD.SN)[DMIPD.app_version]
        HandleMysql().close()

        db_value = "V" + db_value
        logger.info(f"----db_value----{db_value}")

        if db_value == value:
            return True
        else:
            return False
Esempio n. 16
0
class DeviceManageSubPageDatas:
    """设备子界面测试数据"""

    # 存在的完整的渠道名称
    complete_channel = '阿爸'
    complete_channel_2 = 'zzzz'
    # 存在的不完整的渠道名称
    notcomplete_channel = '阿'
    # 存在的完整的SN
    # SN = "N301P98Q40093"
    SN = "N301P9WZC0193"
    # SN = "testWap4"
    #存在的不完整的sn
    no_complete_SN = "40093"
    # 不存在的SN 、渠道
    no_exist_SN = "N111111111111111111111"
    no_exist_channel = "mmmaassqqqwqwqwqw"

    # td所在的索引位置 0 开始
    hareware_model_td_index = 1  # 机型
    SN_td_index = 2  # SN
    channel_td_index = 3  # 渠道
    last_connect_td_index = 5  # 上次连入
    last_disconnect_td_index = 6  # 上次断开
    log_switch_td_index = 7  # log开关

    # 可选择的机型
    device_model_NT211 = "NT211"
    device_model_NT212 = "NT212"
    device_model_NT211_S = "NT211_S"
    device_model_NT212_S = "NT212_S"
    device_model_NT213 = "NT213"

    # 页面跳转输入框 输入的页面数字
    jump_to_page_number = 10
    # 页面跳转输入框中输入的错误数字列表 (参数化用)
    jump_to_error_page = [0, -1]
    # 键盘操作,enter键
    enter_keyboard = (Keys.ENTER)
    # 当前共多少页设备(设备总数/10 向上取整)
    current_page_number = math.ceil(
        int(HandleMysql().read_mysql(
            do_yaml.read_yaml("mysql",
                              "query_device_count_sql"))["count(msn)"]) / 10)

    # 大于当前最大页
    out_of_largest_page_number = current_page_number + 10

    #查询数据库数据key值
    is_online = "is_online"
    hardware_model = "hardware_model"
    connect_time = "connect_time"
    disconnect_time = "disconnect_time"
    log_switch = "log_switch"
    count_is_online = "count(is_online)"
    count_msn = "count(msn)"
Esempio n. 17
0
    def query_voice_connect_assert(self):
        logger.info("断言:设置项-查看页面网络连接播报次数,与数据库比对,返回True or False")
        value = self.get_element_text(loc.voice_connect, module="设置项-网络连接播报次数")
        logger.info(f"---value-----:{value}")

        try:
            db_value = str(HandleMysql().read_mysql(
                do_yaml.read_yaml("mysql", "query_voice_connect_sql"),
                DMIPD.SN)[DMIPD.voice_connect]) + "次"
        except:
            db_value = "1次"
        finally:
            HandleMysql().close()
            logger.info(f"----db_value----:{db_value}")

        if value == db_value:
            return True
        else:
            return False
Esempio n. 18
0
    def query_cancel_order_copy_assert(self):
        logger.info("断言:设置项-查看页面取消单打印联数,与数据库比对,返回True or False")
        value = self.get_element_text(loc.cancel_order_copy,
                                      module="设置项-取消单打印联数")
        logger.info(f"---value-----:{value}")

        try:
            db_value = str(HandleMysql().read_mysql(
                do_yaml.read_yaml("mysql", "query_cancel_order_copy_sql"),
                DMIPD.SN)[DMIPD.cancel_order_copy]) + "张"
        except:
            db_value = "1张"
        finally:
            HandleMysql().close()
            logger.info(f"----db_value----:{db_value}")

        if value == db_value:
            return True
        else:
            return False
Esempio n. 19
0
    def query_MAC_address_assert(self):
        logger.info("断言:点击wifi信息-查看页面mac地址,与数据库数据比对,返回True or False")

        value = self.get_element_text(loc.mac_address, module="查询页面MAC地址")
        logger.info(f"---value-----:{value}")

        db_value = HandleMysql().read_mysql(
            do_yaml.read_yaml("mysql", "query_boot_mac_sql"),
            DMIPD.SN)[DMIPD.MAC_address]

        if db_value == None:
            db_value = "--"
        logger.info(f"----db_value----:{db_value}")

        HandleMysql().close()

        if db_value == value:
            return True
        else:
            return False
Esempio n. 20
0
    def query_rush_order_play_time_assert(self):
        logger.info("断言:设置项-查看页面催单播报次数,与数据库比对,返回True or False")
        value = self.get_element_text(loc.rush_order_play_time,
                                      module="设置项-催单播报次数")
        logger.info(f"---value-----:{value}")

        try:
            db_value = str(HandleMysql().read_mysql(
                do_yaml.read_yaml("mysql", "query_rush_order_play_time_sql"),
                DMIPD.SN)[DMIPD.rush_order_play_time]) + "次"
        except:
            db_value = "1次"
        finally:
            HandleMysql().close()
            logger.info(f"----db_value----:{db_value}")

        if value == db_value:
            return True
        else:
            return False
    def device_current_state(self):
        logger.info("断言:查询页面SN的当前状态,与数据库数据比对,返回True or False")
        # 查看离线状态的元素存不存在,如果存在则返回0 ,不存在则返回1
        try:
            WebDriverWait(self.driver, 20, 0.5).until(
                EC.presence_of_element_located(loc.device_offline))
        except:
            value = 1
        else:
            value = 0

        value_db = (HandleMysql().read_mysql(
            do_yaml.read_yaml("mysql", "query_state_sql"),
            DMSPD.SN))[DMSPD.is_online]
        # 关闭数据库
        HandleMysql().close()

        if value == value_db:
            return True
        else:
            return False
    def device_count(self):
        logger.info("断言:查询页面打印机总数,并与数据库数据比对,返回True or False")

        # 从页面获取打印机总数
        value = self.get_element_text(loc.device_count_and_online_number,
                                      "设备子界面-打印机总数")
        value = value.split("/")[0]
        logger.info(f"--------value------{value}")

        # 从数据库获取打印机总数数据
        db_value = HandleMysql().read_mysql(
            do_yaml.read_yaml("mysql",
                              "query_device_count_sql"))[DMSPD.count_msn]
        db_value = "共" + str(db_value) + "台"

        logger.info(f"--------db_value------{db_value}")
        HandleMysql().close()

        if value == db_value:
            return True
        else:
            return False
    def device_current_hardware_model(self, td_index):
        logger.info("断言:查询页面SN的小机型,并与数据库数据比对,返回True or False")
        # 获取所有的tr 对象 为一个列表
        tr_list = self.get_element(
            loc.table_tbody,
            module="获取tr为一个列表").find_elements_by_tag_name("tr")

        td_list = tr_list[0].find_elements_by_tag_name("td")

        hardware_model = td_list[td_index].text
        logger.info(f"--hardware_model:--{hardware_model}")

        # 从数据库中获取数据
        value = (HandleMysql().read_mysql(
            do_yaml.read_yaml("mysql", "query_hardware_model_sql"),
            DMSPD.SN))[DMSPD.hardware_model]
        # 关闭数据库
        HandleMysql().close()
        logger.info(f"---value:---{value}")

        if hardware_model == value:
            return True
        else:
            return False
Esempio n. 24
0
    def query_ldi_tts_version_assert(self):
        logger.info("断言:本机信息-查询页面tts版本与数据库数据比较-返回True or False")
        value = self.get_element_text(loc.ldi_tts_language,
                                      module="查询本机信息-tts版本")
        value = value.split("(")[0]
        logger.info(f"---value-----{value}")

        db_value = "V" + HandleMysql().read_mysql(
            do_yaml.read_yaml("mysql", "query_tts_version_sql"),
            DMIPD.SN)[DMIPD.tts_version]
        logger.info(f"----db_value----{db_value}")

        if db_value == value:
            return True
        else:
            return False
Esempio n. 25
0
    def query_IMEI_assert(self):
        logger.info("断言:点击设备信息-移动网络-查询页面IMEI号,与数据库数据比较,返回True or Flase")

        value = self.get_element_text(loc.mni_IMEI, module="获取页面IMEI号")
        logger.info(f"---value-----:{value}")

        db_value = HandleMysql().read_mysql(
            do_yaml.read_yaml("mysql", "query_imei_sql"), DMIPD.SN)[DMIPD.IMEI]

        if db_value == "":
            db_value = "--"
        logger.info(f"----db_value----:{db_value}")

        if db_value == value:
            return True
        else:
            return False
Esempio n. 26
0
    def query_open_money_box_assert(self):
        logger.info("断言:点击打印信息-查看页面开钱箱次数,与数据库数据比对,返回True or False")

        value = self.get_element_text(loc.money_box, module="查询页面开钱箱次数")
        logger.info(f"---value-----:{value}")

        db_value = HandleMysql().read_mysql(
            do_yaml.read_yaml("mysql", "query_money_box_sql"),
            DMIPD.SN)[DMIPD.open_money_box]
        if db_value == None:
            db_value = "--"
        else:
            db_value = str(db_value) + "次"
        logger.info(f"----db_value----:{db_value}")

        if db_value == value:
            return True
        else:
            return False
Esempio n. 27
0
    def query_ldi_network_type_assert(self):
        logger.info("断言:本机信息-查询页面网络类型与数据库数据比较-返回True or False")
        value = self.get_element_text(loc.ldi_network_type,
                                      module="查询本机信息-网络类型版本")
        logger.info(f"---value-----{value}")

        db_value = HandleMysql().read_mysql(
            do_yaml.read_yaml("mysql", "query_network_type_sql"),
            DMIPD.SN)[DMIPD.network_type]
        if db_value == 0:
            db_value = "GPRS"
        elif db_value == 1:
            db_value = "WIFI"
        logger.info(f"----db_value----{db_value}")

        if db_value == value:
            return True
        else:
            return False
Esempio n. 28
0
    def click_log_button_to_off_assert(self):
        logger.info("断言:关闭log元素存在,数据库数据比对,返回True or False")

        try:
            self.wait_element_visible(loc.device_log_button_off,
                                      module="点击log开关_关闭log元素存在")
        except:
            value = 0
        else:
            value = 1

        db_value = HandleMysql().read_mysql(
            do_yaml.read_yaml("mysql", "query_log_switch_sql"),
            DMIPD.SN)[DMSPD.log_switch]
        logger.info(f"----db_value----:{db_value}")

        if value == 1 and db_value == 0:
            return True
        else:
            return False
Esempio n. 29
0
    def query_printer_head_broken_assert(self):
        logger.info("断言:点击打印信息-查看页面打印头坏点,与数据库数据比对,返回True or False")

        value = self.get_element_text(loc.printer_head_broken,
                                      module="查询页面打印头坏点")
        logger.info(f"---value-----:{value}")

        try:
            db_value = HandleMysql().read_mysql(
                do_yaml.read_yaml("mysql", "query_printer_head_broken_sql"),
                DMIPD.SN)[DMIPD.print_head_broken]
        except:
            db_value = "--"

        logger.info(f"----db_value----:{db_value}")

        if db_value == value:
            return True
        else:
            return False
Esempio n. 30
0
    def query_printer_kilometer_assert(self):
        logger.info("断言:点击打印信息-查看页面打印公里数,与数据库数据比对,返回True or False")

        value = self.get_element_text(loc.printer_kilometer,
                                      module="查询页面打印机公里数")
        logger.info(f"---value-----:{value}")

        try:
            db_value = HandleMysql().read_mysql(
                do_yaml.read_yaml("mysql", "query_printer_info_sql"),
                DMIPD.SN)[DMIPD.print_kilometer]
        except:
            db_value = "--"
        else:
            db_value = str(db_value / 1000) + "m"

        logger.info(f"----db_value----:{db_value}")

        if db_value == value:
            return True
        else:
            return False