Ejemplo n.º 1
0
class ScreeningJude(JudgmentVerification):
    '''
    select二次封装并进行判断
    导出和搜索按钮为formSub时,使用该函数
    '''
    attrEle = 'css'

    def __init__(self, config, basename, centerName):
        '''
        定义模块数据信息
        :param module:   元素模块
        :param sheet:   用例标签名
        :param basename:  执行程序的文件名
        '''
        JudgmentVerification.__init__(self, config, basename)
        self.bi = centerName()
        pass

    def designated_box(self, keys, box: str):
        """
        进入指定的tab或者城市
        :return:
        """
        # 根据类型读取相应的数据信息
        self.ct = CustomTabs(self.driver, self.financial[keys])
        self.ct.into_the_city(self.vac, box)
        pass

    def create_select(self, direction: str) -> ScreeningDrop:
        '''
        创建操作select的对象
        :param direction:
        :return:
        '''
        op_se = ScreeningDrop(self.driver, direction, attr=self.attrEle)
        return op_se

    def button_formSub(self, formSub, att: str):
        '''
        根据按钮位置来进行点击
        :param formSub:  按钮的key值
        :param att: 按钮的位置
        :return:
        '''
        attribute = self._visible_returns_selectop(self.financial[formSub])
        attribute = attribute[int(self.financial[att]) - 1]
        return attribute

    def searchExport(self, formSub):
        """
        指定某个元素组,并获取指定位置的元素
        :param formSub:  指定元素组的元素路径.在yaml中配置
        :return:
        """
        # 读取excel配置中指定位置的元素路径
        att = self.overall[self.bi.whole_keys()]
        # 将元素组的路径传入,结合需要读取的数据位置来读取
        op_str = self.button_formSub(formSub, att).text
        # 读取excel中配置的默认值
        ov_str = self.overall[self.bi.whole_default()]
        # 默认值与指定位置读取的数据进行比较
        self.debugging_log(op_str, ov_str, 'Obtain all options values incorrectly %s' % att)

    def value_options_jude(self, selectPath: str):
        '''
        根据指定的路径获取select下面的全部option值
        :param selectPath: 下拉框对象。
        :param information: 比较错误之后,抛出的信息。
        :return:
        '''
        selectPath = self.financial[selectPath]
        op_se = self.create_select(selectPath)
        # 获取全部的options并将list格式转换成str
        op_str = op_se.options_to_str()
        ov_str = self.overall[self.bi.whole_including()]
        msg = 'Obtain all options values incorrectly %s' % selectPath
        self.debugging_log(op_str, ov_str, msg)
        pass

    def value_options_default(self, selectPath: str):
        '''
        根据指定的路径获取select下默认的option值
        :param selectPath:
        :param information:
        :return:
        '''
        op_se = self.create_select(self.financial[selectPath])
        op_str = op_se.getSelectedOptions()
        ov_str = self.overall[self.bi.whole_default()]
        msg = 'Option defaults are incorrect: %s' % selectPath
        self.debugging_log(op_str, ov_str, msg)
        pass

    def value_option_traverse(self, formSub, selectPath):
        """
        遍历选择下拉对象中的option属性值,然后在点击搜索按钮。
        :param formSub: 搜索按钮
        :param selectPath: 元素的路径
        :return:
        """
        selectPath = self.financial[selectPath]  # 找到指定标签的元素地址
        op_se = self.create_select(selectPath)
        op_list = op_se.getAllOptions()
        for value_str in op_list:
            # 设置option
            op_se.setSelectorText(value_str)

            # 点击搜索按钮
            self.button_formSub(formSub, self.bi.yaml_search()).click()

            # 重新設置text之後,界面會進行刷新此時driver對象也發生改變需要重新進行獲取
            op_se = op_se.setSelectData(selectPath, self.attrEle)
            # 判断当前显示的option是否为设置的option
            op_str = op_se.getSelectedOptions()
            msg = 'Error appearing when iterating click option : %s ' % selectPath
            self.debugging_log(value_str, op_str, msg)

    def select_option_value(self, selectPath):
        op_se = self.create_select(selectPath)
        prompt_value = op_se.setSelectorValue(self.overall[self.overall.whole_parameter()])
        return prompt_value

    def attribute_value(self, attribute='placeholder'):
        '''
        找到元素中的placeholder属性值
        :return:
        '''
        # 1. 找到界面数据
        timePath = self.overall[self.bi.whole_keys()]
        timePath = self.financial[timePath]  # 元素路径
        op_str = self.vai._visible_selectop_attribute(self.driver, timePath, attribute)  # 将属性转成对象
        # 2. 找到产品规定的数据
        ov_str = self.overall[self.bi.whole_default()]
        # 3. 数据比较
        msg = 'Error in time entry box : %s ' % timePath
        self.debugging_log(op_str, ov_str, msg)
        pass

    def time_value_jump(self, time_jump, attribute='value'):
        """

        读取时间选择框中默认显示的年月日(或者年月日)并于程序计算的年月日(或者年月)进行比较
        :return:
        """
        # 1. 找到界面数据
        timePath = self.overall[self.bi.whole_keys()]
        timePath = self.financial[timePath]  # 元素路径
        op_str = self.vai._visible_selectop_attribute(self.driver, timePath, attr=attribute)  # 将属性转成对象

        # 2. 找到产品规定的数据
        if 'ymd' in time_jump:
            ov_str = self.ti.at_the_present_day()
        elif 'ym' in time_jump:
            ov_str = self.ti.get_time_ym()
        else:
            ov_str = "没有这个内容哟!!..."

        # 3. 数据比较
        msg = 'Error in time entry box : %s ' % timePath
        self.debugging_log(op_str, ov_str, msg)
        pass

    def test_value(self):
        """
        判断指定元素的test是否正确
        :return:
        """
        locator = self.overall[self.bi.whole_keys()]
        locator = self.financial[locator]
        ct_default = self._visible_css_selectop_text(locator)
        ov_default = self.overall[self.bi.whole_default()]
        msg = 'Error in text entry key : %s ' % locator
        self.debugging_log(ct_default, ov_default, msg)
        pass

    def debugging_log(self, ct_default, ov_default, mesg):
        assert operator.eq(ct_default, ov_default), mesg
        pass
Ejemplo n.º 2
0
class OperateJude(JudgmentVerification):
    def __init__(self, config, basename, center_name):
        """
        定义模块数据信息
        :param module:   元素模块
        :param sheet:   用例标签名
        :param basename:  执行程序的文件名
        """
        JudgmentVerification.__init__(self, config, basename)
        self.bi = center_name()
        pass

    def click_and_mode(self, mode, key: str = None):
        if key:
            mode = mode[key]
            pass
        self.ti.dormancy_time(0.5)
        ordinal = mode[self.bi.yaml_parameter()]
        ordinal = self.financial[ordinal]
        self.vac.ele_click_and_mode(self.driver, mode, ordinal)
        del mode

    def conditions_screening(self, _para=None):
        functionName = inspect.stack()[0][3]
        # 1.读取用例设置的参数位置
        ov_para = self.overall[self.bi.whole_parameter()]
        # 1.1 根据文件名和key来解析相应的数据
        if _para:
            ov_para = os.path.join(_para, ov_para)
        else:
            ov_para = os.path.join(
                os.path.split(os.path.dirname(__file__))[0], ov_para)
        case_value = self.read_yaml_case(file_name=ov_para,
                                         case_key=self.FUNCTION_NAME)

        # 2.0 切换焦点
        self.ct = CustomTabs(self.driver, self.financial[self.bi.yaml_tabs()])
        self.ct.into_the_city(self.vac, case_value[self.bi.yaml_tabs()])
        # 2.1 切换城市
        self.ct.parth = self.financial[self.bi.yaml_city()]
        self.ct.into_the_city2(self.vac, case_value[self.bi.yaml_city()])

        # 3.判断弹窗用例是否存在
        info_operate = self.bi.yaml_operate()

        if info_operate in case_value:  # 判断信息输入框是否出现
            # 执行点击弹出的操作
            case_operate = case_value[info_operate]
            self.click_and_mode(case_operate, self.bi.yaml_modify())

            # 判断弹窗中是否需要执行用例
            info_pupop = self.bi.yaml_pupop()
            if info_pupop in case_operate:
                case_pupop = case_operate[info_pupop]
                # 各类输入内容的判断
                # 暂时不弄
                print("这里跳过: %s" % functionName)

                # 打开弹窗之后才执行点击弹窗的按钮命令
                self.ti.dormancy_time(1)  # 查看延迟进行调试。
                self.click_and_mode(case_pupop)
            else:
                self.log.info("%s->弹窗中的用例数据不存在" % (functionName))
                pass
            pass
        else:
            self.log.info("%s->不需要弹窗用例" % (functionName))
            pass
Ejemplo n.º 3
0
class InviteOperateJude(JudgmentVerification):
    def __init__(self, config, basename, center_name):
        """
        定义模块数据信息
        :param module:   元素模块
        :param sheet:   用例标签名
        :param basename:  执行程序的文件名
        """
        JudgmentVerification.__init__(self, config, basename)
        self.bi = center_name()
        pass

    def switchover_tabs_city(self, case_value, t_c):
        """
        进入指定的tabs或者city
        :param t_c:
        :return:
        """
        functionName = inspect.stack()[0][3]
        tabs = t_c
        if tabs in case_value:  # tabs元素是否存在存在,存在就进行切换
            self.ct = CustomTabs(self.driver, self.financial[tabs])
            self.ct.into_the_city(self.vac, case_value[tabs])
            pass
        else:
            self.log.info("%s-tabs或者city不需要进行切换的对象为:%s" % (functionName, t_c))
            pass
        del tabs
        pass

    def click_and_mode(self, mode, key: str = None):
        """
        获取dict中,parameter的value值并进行点击操。
        :param mode:
        :param key:
        :return:
        """
        if key:
            mode = mode[key]
            pass
        self.ti.dormancy_time(0.5)
        ordinal = mode[self.bi.yaml_parameter()]
        ordinal = self.financial[ordinal]
        self.vac.ele_click_and_mode(self.driver, mode, ordinal)
        del mode

    def conditions_screening(self, _para):
        """
        1. 根据tab/city进行相应的tabs/citys页面
        2. 点击指定的元素跳转到相应的数据页面
        3. 判断数据页面的标题是否正确
        :param _para: cases用例中参数所在目录
        :return:
        """
        functionName = inspect.stack()[0][3]
        # 1.读取用例设置的参数位置
        ov_para = self.overall[self.bi.whole_parameter()]
        # 1.1 根据文件名和key来解析相应的数据
        if _para:
            ov_para = os.path.join(_para, ov_para)
        else:
            ov_para = os.path.join(
                os.path.split(os.path.dirname(__file__))[0], ov_para)
        case_value = self.read_yaml_case(file_name=ov_para,
                                         case_key=self.FUNCTION_NAME)

        # 2.0: toggle focus - if the tabs element exists, toggle where it exists
        self.switchover_tabs_city(case_value, self.bi.yaml_tabs())
        # 2.1: switch the existence of city-city elements
        self.switchover_tabs_city(case_value, self.bi.yaml_city())

        # 3.判断弹窗用例是否存在
        info_operate = self.bi.yaml_operate()

        if info_operate in case_value:  # 判断信息输入框是否出现
            # 执行点击弹出的操作
            case_operate = case_value[info_operate]
            # 直接进入tr
            self.click_and_mode(case_operate)

            # 判断进入页面的title是否正确
            # 3.1 yaml中文字的dict
            valueText = case_operate[self.bi.yaml_value_text()]
            # 3.2 读取parameter中保存的title内容
            box_title = valueText[self.bi.yaml_parameter()]
            box_title = self.vac.differentiate_element_text(
                self.driver, valueText['ele'], self.financial[box_title])
            # 3.3 获取产品的title
            valueText = valueText["text"]
            # 3.4 执行断言比较
            assert operator.eq(
                valueText,
                box_title), "%s--进入页面title错误(原因为:有些为商品有些为水票):(%s-%s)" % (
                    functionName, box_title, valueText)
            self.log.info(
                "%s--The title of the box title compares the machinist" %
                valueText)
            pass
        else:
            self.log.info("%s->不需要弹窗用例" % (functionName))
            pass
        pass

    pass
Ejemplo n.º 4
0
class OperationViewJude(JudgmentVerification):
    def __init__(self, config, basename, center_name):
        """
        定义模块数据信息
        :param module:   元素模块
        :param sheet:   用例标签名
        :param basename:  执行程序的文件名
        """
        JudgmentVerification.__init__(self, config, basename)
        self.bi = center_name()
        pass

    def time_day_select(self, hour, value, part):
        """
        傻子操作方式:对时间下拉框进行操作
        :param hour:
        :param part:
        :return:
        """
        # 找到元素
        hourselect = self.vac.is_visibles_css_selectop(self.driver, hour)
        # 点击元素
        self.vac.element_click(hourselect[value])
        # 页面刷新之后需要重新找元素
        hourselect = self.vac.is_visibles_css_selectop(self.driver, hour)
        # 下拉对象并设置内容
        ScreeningDrop(self.driver).ele_select(
            hourselect[value]).setSelectorText(part)

    def release_success(self):
        """
        订单页面条件筛选动作的执行。
        第二步有个坑:如果设置的city不存在那么就默认页面执行操作
        :return:
        """
        # 1.读取用例设置的参数位置
        ov_para = self.overall[self.bi.whole_parameter()]
        # 1.1 根据文件名和key来解析相应的数据
        ov_para = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                               ov_para)
        case_value = self.read_yaml_case(file_name=ov_para,
                                         case_key=self.FUNCTION_NAME)

        # 2. 点击城市
        self.ct = CustomTabs(self.driver, self.financial[self.bi.yaml_tabs()])
        self.ct.into_the_city(self.vac, case_value[self.bi.yaml_city()])

        # 3.根据相应的key值对数据进行操作,遍历执行元素的动作(判断此参数的key是否出现)
        if self.bi.yaml_condition() in case_value:
            case_con = case_value[self.bi.yaml_condition()]
            para_key = case_con.keys()

            for ov in para_key:
                # 4.根据key值旗下的value值
                ov_pa = case_con[ov]
                pa_key = ov_pa.keys()
                # 5. 找到元素的keys值,该值为可在路径yaml表中找到元素的路径
                for pa in pa_key:
                    # ov_key = 依次元素的路径,ov_value = 设置的参数,ov_ty = 以及该元素的类型
                    ov_key = self.financial[pa]
                    case_pa = ov_pa[pa]
                    ov_value = case_pa[_parameter]
                    ov_ty = case_pa[_type].lower()

                    if ov_ty == _click:
                        # 根据元素进行点击
                        self.vac.css_click(self.driver, ov_key)
                        continue

                    elif ov_ty == _input:  # 根据元素进行输出操作

                        if pa == _timeinput:  # 如果为时间输入框就要的单独处理
                            start_time, end_time = self.ti.day_time_date(
                                ov_value)
                            # 点击输入框
                            self.vac.id_click(self.driver, ov_key)

                            # 输入日期:开始和结束
                            mimi = self.vac.is_visibles_css_selectop(
                                self.driver, ".input-mini")
                            self.vai.ele_clear_keys(mimi[0],
                                                    start_time["year"])
                            self.vai.ele_clear_keys(mimi[1], end_time["year"])

                            # 小时下拉框:开始和结束
                            self.time_day_select(".hourselect", 0,
                                                 start_time["time"])
                            self.time_day_select(".hourselect", 1,
                                                 end_time["time"])

                            # 下拉分:开始和结束
                            self.time_day_select(".minuteselect", 0,
                                                 start_time["seconds"])
                            self.time_day_select(".minuteselect", 1,
                                                 end_time["seconds"])

                            # 弹窗的确定按钮
                            self.vac.css_click(
                                self.driver,
                                self.financial[self.bi.yaml_timesuccess()])
                            pass
                        else:
                            self.vai.css_input(self.driver, ov_key, ov_value)
                            pass
                        continue

                    elif ov_ty == _select:  # 根据元素来设置相应的options值
                        ScreeningDrop(self.driver, ov_key,
                                      case_pa['ele']).setSelectorText(ov_value)
                        continue

                    elif ov_ty == 'checkbox':
                        # 根据元素来选择相应的单选框
                        checkbox = self.vac.is_visible_css_selectop(
                            self.driver, ov_key)
                        self.visibleRadioSelected(checkbox, ov_value)
                        continue

                    else:
                        self.log.info(_print % ov_ty)
                        continue
        else:
            self.log.info(
                "This use case has no condition parameter key value...")

        # 最后一步,点击查询还是点击导出
        ele_formSub = self.vai.is_visibles_css_selectop(
            self.driver, self.financial['formSub'])
        formSub = case_value['formSub']

        # 确定为搜索和导出就执行动作
        if formSub[_parameter]:
            action = formSub['action']
            if action == 'search':
                # 点击搜索按钮
                self.vac.element_click(ele_formSub[self.financial[action] - 1])
            else:
                # 点击搜索按钮之后在点击导出按钮
                x = [e.text for e in ele_formSub]
                self.vac.element_click(ele_formSub[self.financial['search'] -
                                                   1])
                # 点击搜索之后记得重新获取页面元素,不然会出现StaleElementReferenceException
                ele_formSub = self.vai.is_visibles_css_selectop(
                    self.driver, self.financial['formSub'])
                self.vac.element_click(ele_formSub[self.financial[action] - 1])
                # 弹窗中的全选按钮
                checkbox = self.vac.is_visible_css_selectop(
                    self.driver, self.financial[self.bi.yaml_headersort()])
                self.visibleRadioSelected(checkbox, True)
                # 没延迟会报错
                self.vai.sleep_Rest(1)
                # 弹窗中的确定按钮
                self.vac.css_click(self.driver,
                                   self.financial[self.bi.yaml_exportsort()])
            pass
        else:  # 确定不为搜索和导出就刷新页面
            self.driver.refresh()
        pass

    def close_order_types(self):
        """
        点击关闭按钮之后关闭弹窗,暂时不做任何交互
        :return:
        """
        # 找到关闭按钮
        _close = self.financial[self.bi.yaml_btnclose()]
        _close = self.vac.css_click(self.driver, _close)
        if _close:
            # 关闭弹窗
            _close = self.financial[self.bi.yaml_closecancel()]
            self.vac.css_click(self.driver, _close)
        else:
            self.log.info("没有关闭按钮")

    def transfer_order_types(self):
        """
        点击转预约按钮之后关闭弹窗,暂时不做任何交互
        :return:
        """
        # 找到转预约按钮
        _transfer = self.financial[self.bi.yaml_btndanger()] % 1
        _transfer = self.vac.is_visibles_css_selectop(self.driver, _transfer)
        if _transfer:
            # 关闭弹窗
            for tr in _transfer:
                if tr.text == "转预约":
                    self.log.info("click order %s " % tr.text)
                    self.vac.element_click(tr)
                    cancel = self.financial[self.bi.yaml_dangercancel()]
                    self.vac.css_click(self.driver, cancel)
                    break
                else:
                    self.log.info("no appear To make an appointment to %s:" %
                                  tr.text)
            else:
                assert True is False, "没有转预约按钮"

    def replace_order_types(self):
        """
        点击更换配送员按钮之后关闭弹窗,暂时不做任何交互
        :return:
        """
        # 找到更换配送员按钮
        _transfer = self.financial[self.bi.yaml_btndanger()] % 1
        _transfer = self.vac.is_visibles_css_selectop(self.driver, _transfer)
        if _transfer:
            # 更换配送员弹窗
            for tr in _transfer:
                if tr.text == "更换配送员":
                    self.log.info("click order %s " % tr.text)
                    self.vac.element_click(tr)
                    cancel = self.financial[self.bi.yaml_dangercancel()]
                    self.vac.css_click(self.driver, cancel)
                    break
                else:
                    self.log.info("no appear Change of delivery man %s:" %
                                  tr.text)
                    continue
        else:
            assert True is False, "订单页面没有数据信息,没有更换配送员按钮"

    def details_order_types(self):
        """
        进入详情页,暂时不做任何交互
        :return:
        """
        # 找到详情按钮
        _details = self.financial[self.bi.yaml_btnreplace()] % 1
        _details = self.vac.css_click(self.driver, _details)
        if _details:
            if self.vac.is_visible_css_selectop(self.driver,
                                                ".page-header").text == "订单明细":
                assert True is True, "订单明细 yes"
            else:
                assert True is False, "订单明细 no"
        else:
            assert True is False, "订单页面没有数据信息,找不到详情按钮进入详情页面"

    def record_order_types(self):
        """
        点击记录,暂时不做任何交互
        :return:
        """
        # 找到查看按钮
        _record = self.financial[self.bi.yaml_btnrecord()] % 1
        _record = self.vac.css_click(self.driver, _record)
        if _record:
            # 返回上一页
            self.vac.sleep_Rest(2)
            _record = self.financial[self.bi.yaml_closerecord()]
            self.vac.css_click(self.driver, _record)
        else:
            assert True is False, "订单页面没有数据信息,找不到记录按钮,"
        pass

    def close_cancel(self):
        _close = self.financial[self.bi.yaml_btnclose()]
        _close = self.vac.css_click(self.driver, _close)
        if _close:
            # 关闭弹窗
            _close = self.financial[self.bi.yaml_closecancel()]
            self.vac.sleep_Rest(3)
            self.vac.css_click(self.driver, _close)
        else:
            assert True is False, "详情页面没有关闭按钮"
        pass

    def appointmen_cancel(self):
        _transfer = self.financial[self.bi.yaml_handle()]
        _transfer = self.vac.is_visibles_css_selectop(self.driver, _transfer)
        if _transfer:
            # 转预约
            for tr in _transfer:
                if tr.text == "转预约":
                    self.log.info("click order %s " % tr.text)
                    self.vac.element_click(tr)
                    self.vac.sleep_Rest(3)
                    cancel = self.financial[self.bi.yaml_dangercancel()]
                    self.vac.css_click(self.driver, cancel)
                    break
                else:
                    self.log.info(
                        "no appointmen_cancel To make an appointment to %s:" %
                        tr.text)
            else:
                assert True is False, "详情页面没有转预约按钮"
        pass

    def replace_cancel(self):
        _transfer = self.financial[self.bi.yaml_handle()]
        _transfer = self.vac.is_visibles_css_selectop(self.driver, _transfer)
        if _transfer:
            # 更换
            for tr in _transfer:
                if tr.text == "更换配送员":
                    self.log.info("click order %s " % tr.text)
                    self.vac.element_click(tr)
                    self.vac.sleep_Rest(3)
                    cancel = self.financial[self.bi.yaml_dangercancel()]
                    self.vac.css_click(self.driver, cancel)
                    break
                else:
                    self.log.info("no appear To make an appointment to %s:" %
                                  tr.text)
            else:
                assert True is False, "详情页面没有更换按钮"
        pass
Ejemplo n.º 5
0
class SurfaceJude(JudgmentVerification):
    '''
    页面数据以及页面标题获取并判断
    '''
    def __init__(self, config, basename, centerName):
        '''
        定义模块数据信息
        :param module:   元素模块
        :param sheet:   用例标签名
        :param basename:  执行程序的文件名
        :param centerName:  元素所在的类
        '''
        JudgmentVerification.__init__(self, config, basename)
        self.bi = centerName()
        pass

    def designated_box(self, keys, box: str):
        """
        进入指定的tab或者城市
        :return:
        """
        # 根据类型读取相应的数据信息
        self.ct = CustomTabs(self.driver, self.financial[keys])
        self.ct.into_the_city(self.vac, box)
        pass

    def bs4_soup(self):
        label_text = self.driver.page_source
        soup = BeautifulSoup(label_text, "lxml")
        return soup

    def info_number(self):
        # 读取info的数据并把int数据切割
        info_text = self.bi.yaml_info()
        if info_text in self.financial:
            info_text = self._visible_css_selectop_text(
                self.financial[info_text])
            if info_text:
                pages = str.split(info_text, ',')[-1]

                pages = int(StringCutting.re_zip_code(pages, "\d+"))
                if (pages % 10) > 0:
                    number = 1
                else:
                    number = 0
                pages = int((pages / 10)) + number
                return pages
            else:
                return info_text
        else:
            self.log.debug("页面没有翻页按钮.")
            return False

    def traverseYield(self, thead_tr, tbody_class):
        '''
        :param thead_tr:  页面内容标题
        :param tbody_class:  页面内容展示项
        :return:
        '''
        _button = "button"
        thead_length = len(thead_tr)  # 判断一共会出现td的长度
        for tr in tbody_class:  # 遍历获取不同的tr
            tbody_tr = {}
            tr_td = tr.find_all('td')
            for tr_len in range(thead_length):  # 遍历读取tr中不同的td
                # 最好一个td时,应查询td下面的button数据并读取相应的数据信息
                if tr_len == thead_length - 1:
                    td_text = [
                        td.text.replace(" ", "").replace("\n", "")
                        for td in tr_td[tr_len].find_all(_button)
                    ]
                else:
                    td_text = tr_td[tr_len].text.replace(" ",
                                                         "").replace("\n", "")
                tbody_tr[thead_tr[tr_len]] = td_text
            yield tbody_tr
        pass

    def success_execute(self):
        """
        获取thead标签中的元素text
        :return:
        """
        try:
            soup = self.bs4_soup()
            thead_th = soup.find('thead').find('tr').find_all('th')
            text_center = [
                str.strip(th.text).replace("\n", "") for th in thead_th
            ]
            return text_center
        except AttributeError:
            self.log.error(
                "success_execute--页面没有数据信息出现错误:AttributeError: 'find'")
            assert False
        except Exception as e:
            self.log.error("出现未知的错误 %s" % e)

    def success_tbody(self, url, thead_tr):
        try:
            self.driver.get(url)
            soup = self.bs4_soup()
            tbody_class = soup.find('tbody').find_all('tr')
            tr_yield = self.traverseYield(thead_tr, tbody_class)
            for text in tr_yield:
                self.tbody_list.append(text)
            pass
        except AttributeError:
            self.log.error(
                "tbody布局中只有一个tr所以在find_all('tr'),的时候出现错误."
                "AttributeError: 'NoneType' object has no attribute 'find_all'"
            )

    def title_execute(self):
        '''
        获取页面标题
        :return:
        '''
        text_center = self.success_execute()
        excel_center = str.split(self.overall[self.bi.whole_including()], ',')
        self.debugging_log(text_center, excel_center,
                           'Thead title display is incorrectly displayed.')
        del text_center
        del excel_center
        pass

    def surface_execute(self):
        """
        1.根据分页信息判断需要获取数据的页面数量
        2.通过线程来执行获取任务
        :return:
        """
        # 1.根据info获取当前分页的总数
        pages = self.info_number()  # 获取into的总数据信息
        self.tbody_list = []
        self.threads = []

        queue = [i for i in range(1, pages + 1)]  # 构造 url 链接 页码。

        # 2.获取页面内容的key
        thead_tr = self.success_execute()

        # 3.通过线程来获取内容
        current = self.driver.current_url

        if pages:
            self.log.info("页面有翻页按钮")
            # 如果界面只有一行数据的话,执行下面遍历操作就会出现IndexError: list index out of range
            for qe in range(1, 3):
                url = current + '&page={}'.format(qe)
                thread = threading.Thread(target=self.success_tbody,
                                          args=(
                                              url,
                                              thead_tr,
                                          ))
                thread.setDaemon(True)
                thread.start()
                self.threads.append(thread)
                time.sleep(1)

            for th in self.threads:
                th.join()

            pass
        else:
            self.log.error("页面没有翻页按钮")

            url = current + '&page={}'.format(1)
            thread = threading.Thread(target=self.success_tbody,
                                      args=(
                                          url,
                                          thead_tr,
                                      ))
            thread.setDaemon(True)
            thread.start()
            self.threads.append(thread)
            time.sleep(1)

        # 判断页面是否出现报错的文字提示
        soup = self.bs4_soup()
        fatal_error = soup.br
        if fatal_error:
            fatal_error_pare = fatal_error.parent
            for i, child in enumerate(fatal_error_pare.children, start=1):
                if not child.name in ('div', 'table'):
                    self.log.error(child)
            assert False, "页面报错"
        pass

    def debugging_log(self, ct_default, ov_default, mesg):
        assert operator.eq(ct_default, ov_default), mesg
        pass