#!usr/bin/env python
# -*- coding:utf-8 -*-


import unittest
from com.ea.common import tools
from com.ea.resource import globalparameter as gl
from com.ea.pages import menu_page, interview_list_page
import os
import sys
import time


class MyTestCase(unittest.TestCase):
    u"""面签提报页面所有选项检查"""
    screenshot_path = os.path.join(gl.screenshot_path, os.path.splitext(os.path.basename(__file__))[0])

    def setUp(self):
        tools.del_pics(self.screenshot_path)
        self.driver = tools.getAppiumDriver()
        self.driver.start_activity(gl.packagename, gl.login_activity)
        self.menupage = menu_page.MenuPage(self.driver)

    def tearDown(self):
        self.driver.quit()

    def test_interview_list_check(self):
        u"""面签提报页面所有选项检查"""
        casename = sys._getframe().f_code.co_name
        try:
            listpage = interview_list_page.InterViewListPage(self.driver)
            tools.login(self.driver)
            self.menupage.click_interview()
            listpage.click_first_row()
            listpage.click_shenheliucheng()
            self.assertTrue(tools.have_element(self.driver, "审核记录", 10))
            self.driver.back()
            listpage.click_daikuan_jiben_ziliao()
            self.assertTrue(tools.have_element(self.driver, "贷款类型", 10))
            self.driver.back()
            marry_status=listpage.click_jiekuanren_jiben_xinxi()
            self.assertTrue(tools.have_element(self.driver, "借款人姓", 10))
            self.driver.back()
            if marry_status == "已婚":
                listpage.click_jiekuanren_peiou_xinxi()
                self.assertTrue(tools.have_element(self.driver, "配偶姓", 10))
                self.driver.back()
            listpage.click_jinji_lianxiren()
            self.assertTrue(tools.have_element(self.driver, "与借款人关系", 10))
            self.driver.back()
            listpage.click_fuqi_fuzhai_qingkuang()
            self.assertTrue(tools.have_element(self.driver, "资产总计", 10))
            self.driver.back()
            listpage.click_fuqi_fangchan_xinxi()
            self.assertFalse(tools.have_element(self.driver, "详情", 3))
            self.driver.back()
            listpage.click_fuqi_chechan_xinxi()
            self.assertFalse(tools.have_element(self.driver, "详情", 3))
            self.driver.back()
            listpage.click_fuqi_qita_zichan_xinxi()
            self.assertFalse(tools.have_element(self.driver, "详情", 3))
            self.driver.back()
            listpage.click_jingying_zhuti_xinxi()
            self.assertTrue(tools.have_element(self.driver, "营业执照名称", 10))
            self.driver.back()
            time.sleep(1)
            listpage.swipe("up")
            time.sleep(1)
            listpage.click_qiye_guanlian_daikuan_jilu()
            self.assertFalse(tools.have_element(self.driver, "详情", 3))
            self.driver.back()
            listpage.click_jingying_lishi()
            self.assertTrue(tools.have_element(self.driver, "年销售额", 10))
            self.driver.back()
            listpage.click_jinliugeyue_yingyee_qingkuang()
            self.assertTrue(tools.have_element(self.driver, "第一个月", 10))
            self.driver.back()
            listpage.click_jingying_zhuangkuang()
            self.assertTrue(tools.have_element(self.driver, "员工人数", 10))
            self.driver.back()
            time.sleep(1)
            listpage.swipe("up")
            time.sleep(1)
            listpage.click_mendian_xinxi()
            self.assertTrue(tools.have_element(self.driver, "产权性质", 10))
            self.driver.back()
            listpage.click_cangku_xinxi()
            self.assertFalse(tools.have_element(self.driver, "详情", 3))
            self.driver.back()
            listpage.click_qudao_shuju()
            self.assertFalse(tools.have_element(self.driver, "详情", 3))
            self.driver.back()
            listpage.click_shangyou_xinxi()
            self.assertFalse(tools.have_element(self.driver, "详情", 3))
            self.driver.back()
            listpage.click_xiayou_xinxi()
            self.assertFalse(tools.have_element(self.driver, "详情", 3))
            self.driver.back()
            listpage.click_zhuyao_xiaoshou_chanpin()
            self.assertTrue(tools.have_element(self.driver, "产品名称", 10))
            self.driver.back()
            listpage.click_anfang_neirong()
            self.assertTrue(tools.have_element(self.driver, "未查到相应信息", 10))
            self.driver.back()
            listpage.click_diaocha_jielun()
            self.assertTrue(tools.have_element(self.driver, "调查结论,通过", 10))
            self.driver.back()
            time.sleep(1)
            listpage.swipe("up")
            time.sleep(1)
            listpage.click_shenpi_baogao()
            self.assertTrue(tools.have_element(self.driver, "公开信息查询是否有信贷纠纷记录", 10))
            self.driver.back()
            listpage.click_fuqi_daikuan_jilu()
            self.assertTrue(tools.have_element(self.driver, "贷款编号", 10))
            self.driver.back()
            listpage.click_daichang_he_yuqi_xinxi()
            self.assertFalse(tools.have_element(self.driver, "详情", 3))
            self.driver.back()
            listpage.click_fuqi_danbao_daikuan_xinxi()
            self.assertFalse(tools.have_element(self.driver, "补企业", 3))
            self.driver.back()
            listpage.click_fuqi_zhengxin_fuzhai_qingkuang()
            self.assertTrue(tools.have_element(self.driver, "征信总负债", 10))
            self.driver.back()
            listpage.click_jiekuanren_zhengxin_fujian()
            self.assertTrue(tools.have_element(self.driver, "征信报告变更记录", 10))
            self.driver.back()
            listpage.click_jiekuanren_qiye_zhengxin_baogao()
            self.assertTrue(tools.have_element(self.driver, "未查到相应信息", 10))
            self.driver.back()
            listpage.click_qiye_zhengxin_fujian()
            self.assertTrue(tools.have_element(self.driver, "未查到相应信息", 10))
            self.driver.back()
            time.sleep(1)
            listpage.swipe("up")
            time.sleep(1)
            listpage.click_peiou_zhengxin_fujian()
            self.assertTrue(tools.have_element(self.driver, "征信报告变更记录", 10))
            self.driver.back()
            listpage.click_buchong_zhengxin_fujian_xinxi()
            self.assertTrue(tools.have_element(self.driver, "未查到相应信息", 10))
            self.driver.back()
            listpage.click_qita_fujian_xinxi()
            self.assertTrue(tools.have_element(self.driver, "附件列表", 10))
            self.driver.back()
            listpage.click_caiwu_shenhe_sd_xinxi()
            self.assertTrue(tools.have_element(self.driver, "未查到相应信息", 10))
            self.driver.back()
            listpage.click_sd_xitong_jiaoyi_jilu_huizongbiao()
            self.assertTrue(tools.have_element(self.driver, "未查到相应信息", 10))
            self.driver.back()
            listpage.click_caiwu_shenhe_jilu()
            self.assertTrue(tools.have_element(self.driver, "客户年销售额", 10))
            self.driver.back()
            listpage.click_dianhe_fankui()
            self.assertTrue(tools.have_element(self.driver,"请审核确认是否已经通过电核",10))
            self.driver.back()
            listpage.click_yinhangka_xinxi()
            self.assertTrue(tools.have_element(self.driver, "银行卡账户名", 10))
            self.driver.back()
            listpage.click_shenpi_edu_yu_shoufei_feilv()
            self.assertTrue(tools.have_element(self.driver, "EA批复额度", 10))
            self.driver.back()
            listpage.click_danbaoren()
            self.assertFalse(tools.have_element(self.driver, "补企业", 3))
        except Exception as e:
            tools.screenshot(self.driver, self.screenshot_path, casename)
            raise e


if __name__ == '__main__':
    unittest.main()
