from BeautifulReport import BeautifulReport
from PublicScript import *
from BasePage import basepage


class as_Chargequery2(basepage):
    def save_img(self, img_name):
        self.driver.get_screenshot_as_file("./img/" + img_name + ".png")

    @classmethod
    def setUpClass(cls):
        cls.set_driver()

    @BeautifulReport.add_test_img("test_Asfzhquery")
    def test_Asfzhquery(self):
        """填写所有内容后进行收费（综合）查询"""
        global driver
        driver = self.get_driver()
        id_click(driver, '售气收费')
        id_click(driver, '收费(综合)')
        self.public_ctrl(driver)

    # @BeautifulReport.add_test_img("test_Bxbsfquery")
    # def test_Bxbsfquery(self):
    #     """填写所有内容后进行新版收费查询"""
    #     id_click(driver, '新版收费')
    #     self.public_ctrl(driver)
    #
    # @BeautifulReport.add_test_img("test_CAtjbxsfquery")
    # def test_CAtjbxsfquery(self):
    #     """填写所有内容后进行添加保险查询"""
    #     id_click(driver, '保险收费')
    #     bottom_push_click(driver)
    #     self.public_ctrl(driver)
    #
    # @BeautifulReport.add_test_img("test_CBbxjlwhquery")
    # def test_CBbxjlwhquery(self):
    #     """填写所有内容后进行保险记录维护查询"""
    #     id_click(driver, '保险收费')
    #     present_wait(driver, By.XPATH, '//button[text()="保险记录维护"]').click()
    #     bottom_push_click(driver)
    #     self.public_ctrl(driver)
    #
    # @BeautifulReport.add_test_img("test_CCbxsfmxquery")
    # def test_CCbxsfmxquery(self):
    #     """填写所有内容后进行保险收费明细查询"""
    #     id_click(driver, '保险收费')
    #     present_wait(driver, By.XPATH, '//button[text()="保险收费明细"]').click()
    #     bottom_push_click(driver)
    #     self.public_ctrl(driver)
    #
    # @BeautifulReport.add_test_img("test_Dqssfquery")
    # def test_Dqssfquery(self):
    #     """填写所有内容后进行气损收费查询"""
    #     id_click(driver, '气损收费')
    #     bottom_push_click(driver)
    #     self.public_ctrl(driver)
    #
    # @BeautifulReport.add_test_img("test_Eplycquery")
    # def test_Eplycquery(self):
    #     """填写所有内容后进行批量预存查询"""
    #     id_click(driver, '批量预存')
    #     bottom_push_click(driver)
    #     self.public_ctrl(driver)

    def test_zZZZ_END(self):
        """当前测试模块结束，关闭浏览器"""
        driver.quit()

    def public_ctrl(self, driver):
        #  输入框
        input_border(driver, '//div[@class="form-group col-sm-3"]//input')
        input_border(driver, '//div[@class="col-sm-3 form-group"]//input')
        input_border(driver, '//input[@class="input_search"]')
        #  选择小区
        area_choose(driver)
        #  选择框
        choose_border(driver, '//div[@class="form-group col-sm-3"]//div[@class="btn-group"]')
        choose_border(driver, '//div[@class="col-sm-2 form-group"]//div[@class="btn-group"]')
        #  日期框
        data_border(driver, '//div[@class="datepicker"]')
        #  查询按钮
        search_button_click(driver)

        sleep(1)
        result = is_element_load(driver, '//p[contains(text(),"错误码")]')
        wrong = '错误信息：服务器内部错误，组件：undefined'
        if not result:
            print('查询功能未报错，测试通过')
            wrong = '查询功能未报错，测试通过'
        else:
            print('查询功能报错，测试失败')
        self.assertEqual(wrong, '查询功能未报错，测试通过')

    def tearDown(self):
        pass
