def setUpClass(cls):
     super().setUpClass()
     cls.operation = Operation(cls.driver)
     cls.company = CompanyFunc(cls.driver, cls.ELEMENT)
     cls.account = Account()
     cls.user = cls.account.get_account()
     cls.company_name = '四川同辉实业有限公司'
 def setUpClass(cls):
     super().setUpClass()
     cls.operation = Operation(cls.driver)
     cls.company = CompanyFunc(cls.driver, cls.ELEMENT)
     cls.account = Account()
     cls.company_name = '四川同辉实业有限公司'
     cls.rand_str = RandomStr()
Exemple #3
0
 def setUpClass(cls):
     # 忽略waring提示
     warnings.simplefilter("ignore", ResourceWarning)
     cls.driver, cls.device, cls.port = stater()
     cls.extend = Extend(cls.driver)
     # 点击同意用户协议
     agree_license(cls.driver)
     # 跳过引导页
     skip_guide(cls.driver)
     # 跳过更新提示
     cancel_update(cls.driver)
     cls.account = Account()
Exemple #4
0
    def test_005_jgq_gjss_p0(self):
        """
        金刚区-进入高级搜索页面
        VIP用户登查看无结果---我也是醉了基金
        """
        log.info(self.test_001_jgq_gjss_p0.__doc__)
        try:
            # 获取普通账号登录
            account = Account()
            acc_vip_name = account.get_account('vip')
            acc_pwd = account.get_pwd()
            log.info("登录普通账号:{},账号密码:{}".format(acc_vip_name, acc_pwd))
            # 登录vip账号
            self.login(phone_num=acc_vip_name, password=acc_pwd)
            self.in_allserver('gjss')
            # 关键字搜索---有限公司
            self.new_find_element(
                By.ID,
                self.ELEMENT['advance_search_keyword_input_et']).send_keys(
                    '我也是醉了基金')
            # 点击「查看结果」
            self.new_find_element(
                By.ID, self.ELEMENT['advance_search_check_result_tv']).click()
            # 进入搜索结果页
            page_title = self.new_find_element(By.ID,
                                               self.ELEMENT['page_title']).text
            log.info("搜素结果页页面title:{}".format(page_title))
            self.assertEqual(page_title, "搜索结果")
            result = self.isElementExist(
                By.ID, self.ELEMENT['advance_search_result_count'])
            self.assertFalse(result)
            no_result = self.new_find_element(
                By.ID, self.ELEMENT['tv_empty_title']).text
            log.info(no_result)
            # 搜索结果页-无结果重新搜索
            ele = self.new_find_element(By.ID,
                                        self.ELEMENT['tv_empty_sub_title'])
            print("-------", print(ele.size))

            # self.driver.tap()
            # time.sleep(5)

            log.info("搜索无结果,点击重新搜索")

            self.logout()
            account.release_account(acc_vip_name, "vip")
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            print(e)
            raise Exception
Exemple #5
0
class Search_relation_sift_vip(MyTest, Operation):
    """查关系_高级筛选_02"""

    a = Read_Ex()
    ELEMENT = a.read_excel("Search_relation")
    account = Account()
    phone_vip = account.get_account("vip")

    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        cls.sift_opera = SiftOperation(cls.driver, cls.ELEMENT)
        cls.sift_opera.login_vip(cls.phone_vip, cls.account.get_pwd())

    @classmethod
    def tearDownClass(cls):
        cls.account.release_account(cls.phone_vip, 'vip')
        super().tearDownClass()

    @getimage
    def test_001_cgx_gjsx_wzxx_p0(self):
        """查关系-搜索中间页,高级筛选:网址信息"""
        log.info(self.test_001_cgx_gjsx_wzxx_p0.__doc__)
        try:
            inputTarget = self.sift_opera.search_key(2)
            num_wzxx = random.randint(1, 2)
            selectTarget, selectText = self.sift_opera.get_key(
                "more_wzxx_title", "more_wzxx", num_wzxx)
            result, company = self.sift_opera.basic4relation(
                selectTarget, inputTarget)

            if num_wzxx == 1:
                self.assertEqual("true", result,
                                 "===查关系「有网址」断言失败,公司名:{}===".format(company))
            else:
                self.assertEqual("false", result,
                                 "===查关系「无网址」断言失败,公司名:{}===".format(company))
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception
class Search_relation_sift_vip(MyTest, Operation):
    """查关系_高级筛选_03"""

    a = Read_Ex()
    ELEMENT = a.read_excel("Search_relation")
    account = Account()
    phone_vip = account.get_account("vip")

    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        cls.sift_opera = SiftOperation(cls.driver, cls.ELEMENT)
        cls.sift_opera.login_vip(cls.phone_vip, cls.account.get_pwd())

    @classmethod
    def tearDownClass(cls):
        cls.account.release_account(cls.phone_vip, 'vip')
        super().tearDownClass()

    @getimage
    def test_001_cgx_gjsx_sxxx_p0(self):
        """查关系-搜索中间页,高级筛选:失信信息"""
        log.info(self.test_001_cgx_gjsx_sxxx_p0.__doc__)
        try:
            inputTarget = self.sift_opera.search_key(2)
            num_sxxx = random.randint(1, 2)
            selectTarget, selectText = self.sift_opera.get_key(
                "more_sxxx_title", "more_sxxx", num_sxxx)
            result = self.sift_opera.detail4relation("失信信息", selectTarget,
                                                     inputTarget, num_sxxx)
            if num_sxxx == 1:
                self.assertTrue(result, "===失败-高级筛选:「有失信信息」错误===")
            else:
                self.assertFalse(result, "===失败-高级筛选:「无失信信息」错误===")
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception
class Search_company_sift_vip(MyTest, Operation):
    """查公司_高级筛选_08"""

    a = Read_Ex()
    ELEMENT = a.read_excel("test_search_company_sift")
    account = Account()
    phone_vip = account.get_account("vip")

    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        cls.sift_opera = SiftOperation(cls.driver, cls.ELEMENT)
        cls.sift_opera.login_vip(cls.phone_vip, cls.account.get_pwd())

    @classmethod
    def tearDownClass(cls):
        cls.account.release_account(cls.phone_vip, 'vip')
        super().tearDownClass()

    @getimage
    def test_001_cgs_gjsx_dcdy_p0(self):
        """查公司-搜索中间页,高级筛选:动产抵押"""
        log.info(self.test_001_cgs_gjsx_dcdy_p0.__doc__)
        try:
            self.sift_opera.search_key(1)
            num_dcdy = random.randint(1, 2)
            selectTarget, selectText = self.sift_opera.get_key("more_dcdy_title", "more_dcdy", num_dcdy)
            result = self.sift_opera.detail4company(selectText, "动产抵押", selectTarget, num_dcdy)
            if num_dcdy == 1:
                # 断言-有动产抵押
                self.assertTrue(result, "===失败-高级筛选:「{}」错误===".format(selectText))
            else:
                # 断言-无动产抵押
                self.assertFalse(result, "===失败-高级筛选:「{}」错误===".format(selectText))
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception
Exemple #8
0
 def test_002_jgq_gjss_p0(self):
     """
     金刚区-进入高级搜索页面
     用户未登查看结果---调起登录
     普通用户查看结果---开通VIP
     """
     log.info(self.test_001_jgq_gjss_p0.__doc__)
     try:
         self.in_allserver('gjss')
         # 关键字搜索---有限公司
         self.new_find_element(
             By.ID,
             self.ELEMENT['advance_search_keyword_input_et']).send_keys(
                 '有限公司')
         # 点击「查看结果」
         self.new_find_element(
             By.ID, self.ELEMENT['advance_search_check_result_tv']).click()
         log.info("未登录查看结果拉起登录")
         login = self.isElementExist(By.ID, self.ELEMENT['btv_title'])
         self.assertTrue(login)
         # 获取普通账号登录
         account = Account()
         acc_pt_name = account.get_account('account')
         acc_pwd = account.get_pwd()
         log.info("登录普通账号:{},账号密码:{}".format(acc_pt_name, acc_pwd))
         # 登录普通账号
         self.hit_login(account=acc_pt_name, password=acc_pwd)
         # 普通账号没有权限----调起VIP弹框
         VIP = self.new_find_element(By.ID,
                                     self.ELEMENT['tv_top_title']).text
         self.assertEqual(VIP, "开通VIP会员使用高级搜索")
         # 账号退出
         self.logout()
         # 退还账号
         account.release_account(acc_pt_name, "account")
     except AssertionError:
         raise self.failureException()
     except Exception as e:
         print(e)
         raise Exception
Exemple #9
0
 def test_003_jgq_gjss_p0(self):
     """
     金刚区-进入高级搜索页面
     VIP用户登查看结果---
     """
     log.info(self.test_001_jgq_gjss_p0.__doc__)
     try:
         self.in_allserver('gjss')
         # 关键字搜索---有限公司
         self.new_find_element(
             By.ID,
             self.ELEMENT['advance_search_keyword_input_et']).send_keys(
                 '有限公司')
         # 点击「查看结果」
         self.new_find_element(
             By.ID, self.ELEMENT['advance_search_check_result_tv']).click()
         log.info("未登录查看结果拉起登录")
         login = self.isElementExist(By.ID, self.ELEMENT['btv_title'])
         self.assertTrue(login)
         # 获取VIP账号登录
         account = Account()
         acc_vip_name = account.get_account('vip')
         acc_pwd = account.get_pwd()
         log.info("登录VIP账号:{},账号密码:{}".format(acc_vip_name, acc_pwd))
         # 登录vip账号
         self.new_find_element(By.ID, self.ELEMENT['et_phone']).clear()
         self.hit_login(account=acc_vip_name, password=acc_pwd)
         # 登录后进入搜索结果页
         page_title = self.new_find_element(By.ID,
                                            self.ELEMENT['page_title']).text
         log.info("搜素结果页页面title:{}".format(page_title))
         self.assertEqual(page_title, "搜索结果")
         self.logout()
         account.release_account(acc_vip_name, "vip")
     except AssertionError:
         raise self.failureException()
     except Exception as e:
         print(e)
         raise Exception
            break
        else:
            # 没有可用设备,则每隔10秒检测一次
            time.sleep(10)
            devices.change_device()


if __name__ == "__main__":
    start_time = time.time()
    s_time = datetime.datetime.now()
    log.info(time.strftime("开始时间:%Y-%m-%d %H:%M:%S", time.localtime(start_time)))
    kill_adb()

    lock = Lock()
    # 初始化账户列表
    Account().init_account()
    # 获取case 文件列表
    case_list = CaseFilses()
    cases = case_list.case_files
    # 获取 case 文件数
    cases_count = len(cases)

    # 设备操作 实例化
    devices = MachinePool()
    devices.init()

    threads = []
    # case文件数 是否大于0
    while cases_count > 0:
        with lock:
            # 判断 是否有可用设备
Exemple #11
0
class Search_company_sift(MyTest, Operation):
    """查公司_更多筛选_01"""

    a = Read_Ex()
    ELEMENT = a.read_excel("test_search_company_sift")
    account = Account()
    phone_vip = account.get_account("vip")

    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        cls.sift_opera = SiftOperation(cls.driver, cls.ELEMENT)
        cls.sift_opera.login_vip(cls.phone_vip, cls.account.get_pwd())

    @classmethod
    def tearDownClass(cls):
        cls.account.release_account(cls.phone_vip, 'vip')
        super().tearDownClass()

    def get_company_ssfw(self, selectTarget, inputTarget, index):
        """
        获取公司:搜索范围并断言
        :param selectTarget: 选中条件
        :param inputTarget: 输入内容
        :param index: 选中项索引
        """
        result = None
        assert_info = ""
        assert_tag_info = ""
        selectText = self.new_find_element(By.ID, self.ELEMENT["tv_title"]).text
        if self.isElementExist(By.ID, self.ELEMENT["more_empty_view"]):
            log.info("搜索范围:{},筛选无结果".format(selectText))
            self.sift_opera.reset(selectTarget)
        else:
            items = self.sift_opera.random_list()
            log.info("搜索范围:{},搜索结果页-公司列表长度:{}".format(selectText, str(items)))
            if items > 2:
                items = items - 2
            company_xpath = "{}[{}]{}".format(self.ELEMENT["company_list"], str(items),
                                              self.ELEMENT["company_name_path"])
            assert_company = self.new_find_element(By.XPATH, company_xpath).text
            if index == 4 or index == 6:
                tag_xpath = "{}[{}]{}".format(self.ELEMENT["company_list"], str(items),
                                              self.ELEMENT["company_tag_info_path"])
                assert_tag_info = self.new_find_element(By.XPATH, tag_xpath).text
            if index != 1:
                company_xpath = "{}[{}]{}".format(self.ELEMENT["company_list"], str(items),
                                                  self.ELEMENT["company_info_path"])
                assert_info = self.new_find_element(By.XPATH, company_xpath).text
            log.info("断言公司名称:{}".format(assert_company))
            if index == 1:  # 企业名称
                result = inputTarget in assert_company
            elif index == 4 or index == 6:  # 商标、经营范围
                tag1 = selectText in assert_tag_info
                tag2 = inputTarget in assert_info
                result = tag1 and tag2
            else:
                result = inputTarget, assert_info
            self.sift_opera.reset(selectTarget)
        return result

    def get_company_jglx(self, selectTarget, inputTarget, index):
        """
        获取公司:机构类型并断言
        :param selectTarget: 选中条件
        :param inputTarget: 输入内容
        :param index: 选中项索引
        """
        result = None
        selectText = self.new_find_element(By.ID, self.ELEMENT["tv_title"]).text
        tagTemp = 0
        if self.isElementExist(By.ID, self.ELEMENT["more_empty_view"]):
            pass
        else:  # 查公司-「机构类型」筛选
            items = self.sift_opera.random_list()
            log.info("机构类型:「{}」,搜索结果页-公司列表长度:{}".format(selectText, str(items)))
            if items > 2:  # 防止item超出页面,无法获取元素
                items = items - 2
            company_xpath = "{}[{}]{}".format(self.ELEMENT["company_list"], str(items),
                                              self.ELEMENT["company_name_path"])
            assert_company = self.new_find_element(By.XPATH, company_xpath).text
            log.info("断言公司名称:{}".format(assert_company))
            group = '//*[@resource-id="com.tianyancha.skyeye:id/rl_label"]/android.view.ViewGroup'
            label_xpath = "{}[{}]{}".format(self.ELEMENT["company_list"], str(items), group)
            tags = self.new_find_elements(By.XPATH, label_xpath)
            if index == 1:  # 企业
                result = inputTarget in assert_company
            else:
                if tags is None:
                    result = False
                else:
                    group_text = '//*[@resource-id="com.tianyancha.skyeye:id/rl_label"]/android.view.ViewGroup/android.widget.TextView'
                    for i in range(len(tags)):
                        text_xpath = "{}[{}]{}[{}]".format(self.ELEMENT["company_list"], str(items), group_text,
                                                           str(i + 1))
                        tag = self.new_find_element(By.XPATH, text_xpath, ).text
                        if index == 5:  # 律所
                            if tag != "律所":
                                tagTemp += 1
                        else:
                            if tag != selectText:
                                tagTemp += 1
                    result = len(tags) != tagTemp
        self.sift_opera.reset(selectTarget)
        return result

    def get_company_zczb(self, selectTarget, index=None):
        """
        获取公司:注册资本并断言
        :param selectTarget: 选中条件
        :param index: 选中项索引
        """
        data = {
            1: [{"upper": 100, "lower": 0}],
            2: [{"upper": 200, "lower": 100}],
            3: [{"upper": 500, "lower": 200}],
            4: [{"upper": 1000, "lower": 500}],
            5: [{"upper": 99999999999999999999, "lower": 1000}],
        }
        upper = data[index][0]["upper"]
        lower = data[index][0]["lower"]
        selectText = self.new_find_element(By.ID, self.ELEMENT["tv_title"]).text
        if self.isElementExist(By.ID, self.ELEMENT["more_empty_view"]):
            result = "注册资本:{},筛选无结果".format(selectText)
        else:  # 查公司-「机构类型」筛选
            items = self.sift_opera.random_list()
            log.info("注册资本:「{}」,搜索结果页-公司列表长度:{}".format(selectText, str(items)))
            if items > 2:  # 防止item超出页面,无法获取元素
                items = items - 2
            company_xpath = "{}[{}]{}".format(self.ELEMENT["company_list"], str(items),
                                              self.ELEMENT["company_name_path"])
            assert_company = self.new_find_element(By.XPATH, company_xpath).text
            log.info("断言公司名称:{}".format(assert_company))
            Layout_text = '//*[@resource-id="com.tianyancha.skyeye:id/base_info_ll"]/android.widget.LinearLayout[2]/android.widget.TextView[2]'
            text_xpath = "{}[{}]{}".format(self.ELEMENT["company_list"], str(items), Layout_text)
            if self.isElementExist(By.XPATH, text_xpath):
                zczbStr = self.new_find_element(By.XPATH, text_xpath).text
                zczbNum = re.findall(r"\d+\.?\d*", zczbStr)
                if zczbNum:
                    if "美元" in zczbStr:  # 美元折算
                        numFilter = float(zczbNum[0]) * 7
                    elif "新台币" in zczbStr:  # 新台币折算
                        numFilter = float(zczbNum[0]) * 0.23 / 10000
                    elif "港" in zczbStr:  # 港币折算
                        numFilter = float(zczbNum[0]) * 0.89
                    elif "日" in zczbStr:  # 日元折算
                        numFilter = float(zczbNum[0]) * 0.064
                    else:
                        numFilter = float(zczbNum[0])
                    log.info("{}-注册资本:{}".format(assert_company, str(numFilter)))
                    result = lower <= numFilter <= upper
                else:
                    log.info("{}-注册资本:{}".format(assert_company, zczbStr))
                    result = index == 1 and "-" is zczbStr
            else:
                result = "===失败-公司详情页,基本信息未展示「注册资本」字段==="
        self.sift_opera.reset(selectTarget)
        return result

    def get_company_zcnx(self, selectTarget, index=None):
        """
        获取公司:注册年限并断言
        :param selectTarget: 选中条件
        :param index: 选中项索引
        """
        result = None
        selectText = self.new_find_element(By.ID, self.ELEMENT["tv_title"]).text
        if self.isElementExist(By.ID, self.ELEMENT["more_empty_view"]):
            result = "注册年限:{},筛选无结果".format(selectText)
        else:  # 查公司-「机构类型」筛选
            items = self.sift_opera.random_list()
            log.info("注册年限:「{}」,搜索结果页-公司列表长度:{}".format(selectText, str(items)))
            if items > 2:  # 防止item超出页面,无法获取元素
                items = items - 2
            company_xpath = "{}[{}]{}".format(self.ELEMENT["company_list"], str(items),
                                              self.ELEMENT["company_name_path"])
            assert_company = self.new_find_element(By.XPATH, company_xpath).text
            log.info("断言公司名称:{}".format(assert_company))
            Layout_text = '//*[@resource-id="com.tianyancha.skyeye:id/base_info_ll"]/android.widget.LinearLayout[3]/android.widget.TextView[2]'
            text_xpath = "{}[{}]{}".format(self.ELEMENT["company_list"], str(items), Layout_text)
            if self.isElementExist(By.XPATH, text_xpath):
                zcnxStrList = self.new_find_element(By.XPATH, text_xpath).text.split("-")
                log.info("{}-成立日期: {} 年 {} 月 {} 日".format(assert_company, zcnxStrList[0], zcnxStrList[1], zcnxStrList[2]))
                tarTime = datetime.datetime(int(zcnxStrList[0]), int(zcnxStrList[1]), int(zcnxStrList[2]))
                nowTime = datetime.datetime.now()
                subtractDay = nowTime - tarTime
                tarDay = float(subtractDay.days / 365)
                log.info("{}-注册年限:{}年".format(assert_company, str(tarDay)))
                _dict = {
                    1: tarDay < 1,
                    2: 1 <= tarDay < 2,
                    3: 2 <= tarDay < 3,
                    4: 3 <= tarDay < 5,
                    5: 5 <= tarDay < 10,
                    6: 10 <= tarDay,
                }
                for i in _dict.keys():
                    if i == index:
                        result = _dict[index]
                if result is None:
                    result = "===失败-普通筛选-注册年限:{},断言失败===".format(selectText)
            else:
                result = "===失败-普通筛选-注册年限:{},断言失败===".format(selectText)
        self.sift_opera.reset(selectTarget)
        return result

    def get_company_qyzt(self, selectTarget):
        """
        获取公司:企业状态并断言
        :param selectTarget: 选中条件
        """
        result = None
        selectText = self.new_find_element(By.ID, self.ELEMENT["tv_title"]).text
        if self.isElementExist(By.ID, self.ELEMENT["more_empty_view"]):
            pass
        else:  # 查公司-「机构类型」筛选
            items = self.sift_opera.random_list()
            log.info("企业状态:「{}」,搜索结果页-公司列表长度:{}".format(selectText, str(items)))
            if items > 2:  # 防止item超出页面,无法获取元素
                items = items - 2
            company_xpath = "{}[{}]{}".format(self.ELEMENT["company_list"], str(items),
                                              self.ELEMENT["company_name_path"])
            assert_company = self.new_find_element(By.XPATH, company_xpath).text
            log.info("断言公司名称:{}".format(assert_company))
            reg_id = '//*[@resource-id="com.tianyancha.skyeye:id/search_reg_status_tv"]'
            reg_xpath = "{}[{}]{}".format(self.ELEMENT["company_list"], str(items), reg_id)
            reg_text = self.new_find_element(By.XPATH, reg_xpath).text
            result = reg_text
        self.sift_opera.reset(selectTarget)
        return result

    @getimage
    def test_001_cgs_ptsx_ssfw_p0(self):
        """查公司-搜索中间页,普通筛选:搜索范围"""
        log.info(self.test_001_cgs_ptsx_ssfw_p0.__doc__)
        try:
            inputTarget = self.sift_opera.search_key(1)
            num_ssfw = random.randint(1, 6)
            selectTarget, selectText = self.sift_opera.get_key("more_ssfw_title", "more_ssfw", num_ssfw)
            result = self.get_company_ssfw(selectTarget, inputTarget, num_ssfw)
            if result is None:
                log.info("搜索范围:{},筛选无结果".format(selectText))
            else:
                self.assertTrue(result, "===失败-搜索范围-{},筛选结果异常===".format(selectText))
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception

    @getimage
    def test_002_cgs_ptsx_jglx_p0(self):
        """查公司-搜索中间页,普通筛选:机构类型"""
        log.info(self.test_002_cgs_ptsx_jglx_p0.__doc__)
        try:
            inputTarget = self.sift_opera.search_key(1)
            num_jglx = random.randint(1, 7)
            selectTarget, selectText = self.sift_opera.get_key("more_jglx_title", "more_jglx", num_jglx)
            result = self.get_company_jglx(selectTarget, inputTarget, num_jglx)
            if result is None:
                log.info("机构类型:{},筛选无结果".format(selectText))
            else:
                self.assertTrue(result, "===失败-查公司:更多筛选「{}」标签===".format(selectText))
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception

    @getimage
    def test_003_cgs_ptsx_zczb_p0(self):
        """查公司-搜索中间页,普通筛选:注册资本"""
        log.info(self.test_003_cgs_ptsx_zczb_p0.__doc__)
        try:
            self.sift_opera.search_key(1)
            num_zczb = random.randint(1, 5)
            selectTarget, selectText = self.sift_opera.get_key("more_zczb_title", "more_zczb", num_zczb)
            result = self.get_company_zczb(selectTarget, num_zczb)
            if isinstance(result, type("返回值类型为str")):
                log.info(result)
            else:
                self.assertTrue(result, "===失败-注册资本不符合筛选结果===")
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception

    @getimage
    def test_004_cgs_ptsx_zcnx_p0(self):
        """查公司-搜索中间页,普通筛选:注册年限"""
        log.info(self.test_004_cgs_ptsx_zcnx_p0.__doc__)
        try:
            self.sift_opera.search_key(1)
            num_zcnx = random.randint(1, 5)
            selectTarget, selectText = self.sift_opera.get_key("more_zcnx_title", "more_zcnx", num_zcnx)
            result = self.get_company_zcnx(selectTarget, num_zcnx)
            if isinstance(result, type("返回值类型为str")):
                log.info(result)
            else:
                self.assertTrue(result, "===失败-普通筛选-注册年限:{},断言失败===".format(selectText))
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception

    @getimage
    def test_005_cgs_ptsx_qyzt_p0(self):
        """查公司-搜索中间页,普通筛选:企业状态"""
        log.info(self.test_005_cgs_ptsx_qyzt_p0.__doc__)
        try:
            self.sift_opera.search_key(1)
            num_qyzt = random.randint(1, 5)
            selectTarget, selectText = self.sift_opera.get_key("more_qyzt_title", "more_qyzt", num_qyzt)
            result = self.get_company_qyzt(selectTarget)
            if result is None:
                log.info("企业状态:{},筛选无结果".format(selectText))
            else:
                self.assertEqual(selectText, result, "===失败-企业状态-{},筛选结果异常===".format(selectText))
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception
class TestMainHuman(MyTest, Operation):
    account = Account()
    username = account.get_account('vip')
    password = account.get_pwd()

    def into_company_detail(self, company):
        """
        通过搜索进入公司详情页,搜索结果选择第一条
        :param company: 搜索公司名称
        :return: None
        """
        self.new_find_element(By.ID, elements["index_search_input"]).click()
        self.new_find_element(
            By.ID, elements["search_result_input"]).send_keys(company)
        self.new_find_elements(By.ID,
                               elements["search_result_item"])[0].click()

    @getimage
    def test_1_main_human_count(self):
        """企业背景-主要人员-count"""
        login_status = self.is_login()
        if not login_status:
            self.login(self.username, self.password)
        self.into_company_detail("瓴盛科技有限公司")
        log.info("企业背景-主要人员-count-校验")
        main_human = self.swipe_up_while_ele_located(By.XPATH,
                                                     elements["main_human"])
        main_human_count = self.new_find_element(
            By.XPATH, elements["main_human_count"]).text
        main_human.click()
        real_num = self.data_list_count(By.ID, elements["main_human_item"])
        self.assertEqual(
            int(main_human_count),
            real_num,
            "主要人员实际数量{}与外侧count数量{}不相等".format(main_human_count, real_num),
        )

    @getimage
    def test_2_main_human_jump(self):
        """企业背景-主要人员-跳转"""
        login_status = self.is_login()
        if not login_status:
            self.login(self.username, self.password)
        self.into_company_detail("中信建投证券股份有限公司")
        self.swipe_up_while_ele_located(By.XPATH,
                                        elements["main_human"],
                                        click=True)
        log.info("企业背景-主要人员-上市披露的高管信息跳转")
        self.new_find_element(By.ID, elements["main_human_ipo"]).click()
        page_title = self.new_find_element(By.ID,
                                           elements["app_page_title"]).text
        self.assertEqual(page_title, "高管信息", "企业背景-主要人员-上市披露的高管信息跳转失败")
        self.driver.keyevent(4)
        log.info("企业背景-主要人员-人员跳转")
        click_item = self.new_find_elements(By.ID,
                                            elements["main_human_item"])[0]
        click_human = click_item.text
        click_item.click()
        detail_human_name = self.new_find_element(
            By.ID, elements["detail_human_name"]).text
        self.assertEqual(
            click_human,
            detail_human_name,
            "人员入口名称{}和详情页名称{}不一致".format(click_human, detail_human_name),
        )
        self.driver.keyevent(4)
        log.info("企业背景-主要人员-他有xx家公司跳转")
        self.new_find_elements(By.ID,
                               elements["main_human_has_company"])[0].click()
        person_detail_title = self.new_find_element(
            By.ID, elements["person_detail_title"]).text
        self.assertEqual(person_detail_title, "人员详情", "主要人员他有xx家公司跳转失败")

    @getimage
    def test_3_shareholders_count(self):
        """企业背景-股东信息-count校验"""
        login_status = self.is_login()
        if not login_status:
            self.login(self.username, self.password)
        self.into_company_detail("国安社区(北京)科技有限公司")
        shareholders = self.swipe_up_while_ele_located(
            By.XPATH, elements["shareholders"])
        log.info("企业背景-股东信息-count校验")
        shareholders_count = self.new_find_element(
            By.XPATH, elements["shareholders_count"]).text
        shareholders.click()
        shareholders_item = self.data_list_count(By.ID,
                                                 elements["shareholders_item"])
        self.assertEqual(
            int(shareholders_count),
            shareholders_item,
            "股东信息实际数量{}和外侧count数{}不相等".format(shareholders_count,
                                              shareholders_item),
        )

    @getimage
    def test_4_shareholders_detail_history_jump(self):
        """企业背景-股东信息-历史股东跳转"""
        login_status = self.is_login()
        if not login_status:
            self.login(self.username, self.password)
        self.into_company_detail("思享时代(北京)科技有限公司")
        self.swipe_up_while_ele_located(By.XPATH,
                                        elements["shareholders"],
                                        click=True)
        self.new_find_element(By.ID,
                              elements["shareholders_detail_history"]).click()
        page_title = self.new_find_element(By.ID,
                                           elements["app_page_title"]).text
        self.assertEqual(page_title, "历史股东", "企业背景-股东信息-历史股东跳转失败")

    @getimage
    def test_5_shareholders_company_jump(self):
        """企业背景-股东信息-股东是公司跳转"""
        login_status = self.is_login()
        if not login_status:
            self.login(self.username, self.password)
        self.into_company_detail("智动时代(北京)科技有限公司")
        self.swipe_up_while_ele_located(By.XPATH,
                                        elements["shareholders"],
                                        click=True)
        log.info("企业背景-股东信息-股东是公司跳转")
        jump_human = self.new_find_elements(By.ID,
                                            elements["shareholders_item"])[0]
        jump_text = jump_human.text
        jump_human.click()
        detail_human_name = self.new_find_element(
            By.ID, elements["detail_company_name"]).text
        self.assertEqual(
            jump_text,
            detail_human_name,
            "股东信息股东是公司跳转入口名称{}和公司详情名称{}不一致".format(jump_text,
                                                   detail_human_name),
        )
        self.driver.keyevent(4)
        log.info("企业背景-股东信息-股东是公司股权结构跳转")

    @getimage
    def test_6_shareholders_human_jump(self):
        """企业背景-股东信息-股东是人跳转"""
        login_status = self.is_login()
        if not login_status:
            self.login(self.username, self.password)
        self.into_company_detail("九湾(北京)科技有限公司")
        self.swipe_up_while_ele_located(By.XPATH,
                                        elements["shareholders"],
                                        click=True)
        log.info("企业背景-股东信息-股东是人跳转")
        jump_human = self.new_find_elements(By.ID,
                                            elements["shareholders_item"])[0]
        jump_text = jump_human.text
        jump_human.click()
        detail_human_name = self.new_find_element(
            By.ID, elements["detail_human_name"]).text
        self.assertEqual(
            jump_text,
            detail_human_name,
            "股东信息股东是人跳转入口名称{}和人详情名称{}不一致".format(jump_text, detail_human_name),
        )
        self.driver.keyevent(4)
        log.info("企业背景-股东信息-股东是人-他有xx家公司跳转")
        self.new_find_elements(By.ID, elements["has_company"])[0].click()
        detail_human_name_has = self.new_find_element(
            By.ID, elements["detail_human_name"]).text
        self.assertEqual(
            jump_text,
            detail_human_name_has,
            "股东信息股东是人他有xx家公司名称{}和人详情名称{}不一致".format(jump_text,
                                                    detail_human_name_has),
        )

    @getimage
    def test_7_shareholders_field_check(self):
        """股东信息字段合法校验"""
        login_status = self.is_login()
        if not login_status:
            self.login(self.username, self.password)
        self.into_company_detail("九湾(北京)科技有限公司")
        self.swipe_up_while_ele_located(By.XPATH,
                                        elements["shareholders"],
                                        click=True)

        # 认缴出资额
        log.info("认缴出资额")
        money_num = self.new_find_elements(By.XPATH,
                                           elements["money_num"])[0].text
        print('认缴出资额--->', money_num)
        money_num_flag = is_bill_available(money_num)
        self.assertTrue(money_num_flag, "股东信息认缴出资额{}校验失败".format(money_num))

        # 认缴出资日期
        log.info("认缴出资日期")
        money_time = self.new_find_elements(By.XPATH,
                                            elements["money_time"])[0].text
        money_time_flag = check_time(money_time)
        self.assertTrue(money_time_flag,
                        "股东信息认缴出资日期{}校验失败".format(money_time_flag))

        # 持股比例
        log.info("持股比例")
        holder_percent = self.new_find_elements(
            By.ID, elements["holder_percent"])[0].text
        holder_percent_flag = is_percentage_available(holder_percent)
        self.assertTrue(holder_percent_flag,
                        "股东信息持股比例{}校验失败".format(holder_percent))

    def test_8_release_account(self):
        self.account.release_account(self.username, 'vip')
 def test_007_foundation_dwtz_p0(self):
     """
     基金会-企业背景-对外投资
     """
     log.info(self.test_007_foundation_dwtz_p0.__doc__)
     try:
         # vip 账号登录登录
         account = Account()
         acc_vip_name = account.get_account('vip')
         acc_pwd = account.get_pwd()
         log.info("登录VIP账号:".format(acc_vip_name))
         self.login(acc_vip_name, acc_pwd)
         self.enter_official_information("上海文化发展基金会")
         self.swipeUp(x1=0.5, y1=0.85, y2=0.65, t=500)
         # 获取对外投资count
         foreign_investment_count = self.new_find_element(
             By.XPATH, self.ELEMENT["foreign_investment_count"]
         ).text
         log.info("对外投资count:{}".format(foreign_investment_count))
         # 进入对外投资
         self.new_find_element(By.XPATH, self.ELEMENT["foreign_investment"]).click()
         page_title = self.new_find_element(By.ID, self.ELEMENT["title_name"]).text
         self.assertEqual(page_title, "对外投资", msg="页面title不一致")
         # 存长图
         save_long_figure = self.new_find_element(By.XPATH, self.ELEMENT["save_long_figure"])
         self.assertIsNotNone(save_long_figure)
         # 分享
         share = self.new_find_element(By.XPATH, self.ELEMENT["share"])
         self.assertIsNotNone(share)
         # 对外投资页-页面字段展示
         # 公司名称
         outinvest_company_name = self.new_find_elements(By.ID, self.ELEMENT["outinvest_company_name"])[1].text
         log.info("公司名称:{}".format(outinvest_company_name))
         # 法定代表人
         outinvest_legal = self.new_find_elements(By.ID, self.ELEMENT["outinvest_legal"])[1].text
         log.info("法定代表人:{}".format(outinvest_legal))
         # 经营状态
         outinvest_reg_capital = self.new_find_elements(By.ID, self.ELEMENT["outinvest_reg_capital"])[1].text
         log.info("经营状态:{}".format(outinvest_reg_capital))
         a = operating_check(1, outinvest_reg_capital)
         self.assertTrue(a)
         # 投资数额
         outinvest_amount = self.new_find_elements(By.ID, self.ELEMENT["outinvest_amount"])[1].text
         log.info("投资数额:{}".format(outinvest_amount))
         a = is_bill_available(outinvest_amount)
         self.assertTrue(a)
         # 投资比例
         outinvest_ratio = self.new_find_elements(By.ID, self.ELEMENT["outinvest_ratio"])[1].text
         log.info("投资比例:{}".format(outinvest_ratio))
         a = is_percentage_available(outinvest_ratio)
         self.assertTrue(a)
         # 成立日期
         outinverst_date = self.new_find_elements(By.ID, self.ELEMENT["outinverst_date"])[1].text
         log.info("成立日期:{}".format(outinverst_date))
         a = check_time(outinverst_date)
         self.assertTrue(a)
         # 公司的跳转
         self.new_find_elements(By.ID, self.ELEMENT["outinvest_company_name"])[1].click()
         comp_name = self.new_find_element(By.ID, self.ELEMENT["comp_name"]).text
         log.info("页面跳转后公司详情页name:{}".format(comp_name))
         self.assertEqual(comp_name, outinvest_company_name)
         self.driver.keyevent(4)
         # 人的跳转
         self.new_find_elements(By.ID, self.ELEMENT["outinvest_legal"])[1].click()
         close_guide(self)
         person_name = self.new_find_element(By.ID, self.ELEMENT["person_name"]).text
         # self.assertEqual(person_name, outinvest_legal)
         self.assertIn(outinvest_legal, person_name)
         self.driver.keyevent(4)
         # 股权机构的跳转
         self.new_find_elements(By.ID, self.ELEMENT["outinvest_title_right"])[1].click()
         title_name = self.new_find_element(By.ID, self.ELEMENT["title_name"]).text
         self.assertEqual(title_name, '股权结构')
         self.driver.keyevent(4)
         # 对外投资页count
         comp_count = self.all_count_compute_v1(By.ID, self.ELEMENT["outinvest_company_name"])
         log.info("对外投资页item展示数量:{}".format(comp_count))
         self.assertEqual(comp_count, int(foreign_investment_count))
         account.release_account(acc_vip_name, "vip")
     except AssertionError:
         raise self.failureException()
     except Exception as e:
         log.error(e)
         raise Exception
Exemple #14
0
class TestBusinessInfo(MyTest, Operation):
    account = Account()
    username = account.get_account('vip')
    password = account.get_pwd()

    def into_company_detail(self, company):
        """
        通过搜索进入公司详情页,搜索结果选择第一条
        :param company: 搜索公司名称
        :return: None
        """
        self.new_find_element(By.ID, elements["index_search_input"]).click()
        self.new_find_element(
            By.ID, elements["search_result_input"]).send_keys(company)
        self.new_find_elements(By.ID,
                               elements["search_result_item"])[0].click()

    # def swipe_up_while_ele_located(self, *loc, click=False, time=10, group=False):
    #     """
    #     定位不到元素向上滑动循环定位直到达到最大次数限制并且点击
    #     :param time: 查找次数
    #     :param loc: 定位元素
    #     :param click: 是否点击找到的元素
    #     :param group: 是否使用find_elements
    #     :return: None
    #     """
    #     count = 0
    #     timeout = 8
    #     screen_size = self.driver.get_window_size()
    #     ele = None
    #     while True:
    #         if count == time:
    #             break
    #         else:
    #             if group:
    #                 ele = self.new_find_elements(*loc, outtime=timeout)
    #             else:
    #                 ele = self.new_find_element(*loc, outtime=timeout)
    #         if ele:
    #             if click and not group:
    #                 ele.click()
    #             break
    #         else:
    #             self.driver.swipe(
    #                 0.5 * screen_size["width"],
    #                 0.8 * screen_size["height"],
    #                 0.5 * screen_size["width"],
    #                 0.4 * screen_size["height"],
    #                 1500,
    #             )
    #             count += 1
    #             timeout = 3
    #     return ele

    @getimage
    def test_1_registration_info_1(self):
        """企业背景-工商信息-登记信息-vip-part-1"""
        log.info(self.__doc__)
        if not self.is_login():
            self.login(self.username, self.password)
        check = UnifiedSocialCreditIdentifier()
        self.into_company_detail("京东数字科技控股有限公司")
        log.info("case --- 京东数字科技控股有限公司")
        self.swipe_up_while_ele_located(By.XPATH,
                                        elements["business_info"],
                                        click=True)

        # 查看历史工商信息
        log.info("查看历史工商信息")
        self.new_find_element(By.ID, elements["history_business"]).click()
        history_business_title = self.new_find_element(
            By.ID, elements["app_page_title"], outtime=15).text
        self.assertEqual(history_business_title, "历史工商信息", "跳转历史工商信息失败")
        self.driver.keyevent(4)

        # 法定代表人跳转
        log.info("法定代表人跳转")
        self.new_find_element(By.ID, elements["person"]).click()
        jump_flag = self.isElementExist(By.ID, elements["person_detail_title"])
        self.assertTrue(jump_flag, "工商信息法定代表人跳转失败")
        self.driver.keyevent(4)

        # 他有xxx家公司跳转
        log.info("他有xxx家公司跳转")
        self.new_find_element(By.ID, elements["have_company"]).click()
        company_flag = self.isElementExist(By.ID,
                                           elements["person_detail_title"])
        self.assertTrue(company_flag, "他有xx家公司跳转失败")
        self.driver.keyevent(4)

        # 成立日期
        log.info("成立日期")
        create_time = self.new_find_element(By.ID,
                                            elements["create_time"]).text
        time_format = check_time(create_time, is_compare=True)
        self.assertTrue(time_format, "成立时间{}格式展示不正确".format(create_time))

        # 经营状态
        log.info("经营状态")
        status = self.new_find_element(By.ID, elements["status"]).text
        self.assertIn(status, ("在业", "存续", "吊销", "注销", "迁出"),
                      "经营状态{}展示错误".format(status))

        # 注册资本
        log.info("注册资本")
        capital = self.new_find_element(By.ID, elements["capital"]).text
        capital_flag = is_bill_available(capital)
        self.assertTrue(capital_flag, "注册资本{}展示错误".format(capital))

        # 实缴资本
        log.info("实缴资本")
        real_capital = self.new_find_element(By.ID,
                                             elements["real_capital"]).text
        real_capital_flag = is_bill_available(real_capital)
        self.assertTrue(real_capital_flag, "实缴资本{}展示错误".format(real_capital))

        # 统一社会信用代码
        log.info("统一社会信用代码")
        credit_code = self.new_find_element(By.ID,
                                            elements["credit_code"]).text
        credit_flag = check.check_social_credit_code(credit_code)
        self.assertTrue(credit_flag, "统一社会信用代码{}校验未通过".format(credit_code))

        # 工商注册号
        log.info("工商注册号")
        business_code = self.new_find_element(By.ID,
                                              elements["business_code"]).text
        business_code_flag = re.match(r"^\d{15}$", business_code)
        self.assertIsNotNone(business_code_flag,
                             "工商注册号{}校验未通过".format(business_code))

        # 组织机构代码
        log.info("组织机构代码")
        organize_code = self.new_find_element(By.ID,
                                              elements["organize_code"]).text
        organize_flag = check.check_organization_code(organize_code)
        self.assertTrue(organize_flag, "组织机构代码{}校验未通过".format(organize_code))

        # 纳税人识别号
        log.info("纳税人识别号")
        tax_code = self.new_find_element(By.ID, elements["tax_code"]).text
        tax_flag = check.check_tax_code(tax_code)
        self.assertTrue(tax_flag, "纳税人识别号{}校验未通过".format(tax_code))

        # 纳税人资质
        log.info("纳税人资质")
        tax_person = self.new_find_element(By.ID, elements["tax_person"]).text
        self.assertEqual(tax_person, "-", "纳税人资质{}校验失败".format(tax_person))

    @getimage
    def test_2_registration_info_2(self):
        """企业背景-工商信息-登记信息-vip-part-2"""
        login_status = self.is_login()
        if not login_status:
            self.login(self.username, self.password)
        self.into_company_detail("河北苹乐面粉机械集团有限公司")
        self.swipe_up_while_ele_located(By.XPATH,
                                        elements["business_info"],
                                        click=True)

        # 企业类型
        log.info("企业类型")
        company_type = self.new_find_element(By.ID,
                                             elements["company_type"]).text
        self.assertEqual(company_type, "有限责任公司(自然人投资或控股)",
                         "企业类型{}展示错误".format(company_type))

        # 行业
        log.info("行业")
        industry = self.new_find_element(By.ID, elements["industry"]).text
        self.assertEqual(industry, "专用设备制造业", "行业{}校验失败".format(industry))

        # 营业期限
        log.info("营业期限")
        over_time = self.new_find_element(By.ID, elements["over_time"]).text
        if over_time == "-":
            self.assertEqual(over_time, "-", "营业期限{}格式校验错误".format(over_time))
        else:
            check_result = re.findall(
                "[1,2][0, 9][0-9][0-9]-[0-9][0-9]-[0-3][0-9]", over_time)
            self.assertEqual(len(check_result), 2,
                             "营业期限{}格式校验错误".format(over_time))

        # 人员规模
        log.info("人员规模")
        person_size = self.swipe_up_while_ele_located(
            By.ID, elements["person_size"]).text
        person_size_flag = re.match(r"^\d(.*?)人$", person_size)
        self.assertTrue(person_size == "-" or person_size_flag,
                        "人员规模{}规则校验失败".format(person_size))

        # 参保人数
        log.info("参保人数")
        protect_person = self.swipe_up_while_ele_located(
            By.ID, elements["protect_person"]).text
        protect_person_flag = re.match(r"^\d*", protect_person)
        self.assertTrue(
            protect_person == "-" or protect_person_flag,
            "参保人数{}规则校验失败".format(protect_person),
        )

        # 英文名称
        log.info("英文名称")
        english_name = self.swipe_up_while_ele_located(
            By.ID, elements["english_name"]).text
        english_name_flag = re.match(r"^[a-zA-Z](.*?)Ltd\.$", english_name)
        self.assertTrue(
            english_name == "-" or english_name_flag,
            "英文名称{}校验失败".format(english_name),
        )

        # 曾用名
        log.info("曾用名")
        past_name = self.swipe_up_while_ele_located(By.ID,
                                                    elements["past_name"]).text
        self.assertTrue(past_name == "-" or len(past_name) > 5,
                        "曾用名{}校验失败".format(past_name))

        # 登记机关
        log.info("登记机关")
        reg_institute = self.swipe_up_while_ele_located(
            By.ID, elements["reg_institute"]).text
        self.assertTrue(
            reg_institute == "-" or len(reg_institute) > 5,
            "登记机关{}校验失败".format(reg_institute),
        )

        # 核准日期
        log.info("核准日期")
        approved_time = self.swipe_up_while_ele_located(
            By.ID, elements["approved_time"]).text
        approved_time_flag = re.match(
            "[1,2][0, 9][0-9][0-9]-[0-9][0-9]-[0-3][0-9]",
            approved_time,
        )
        self.assertTrue(
            approved_time == "-" or approved_time_flag,
            "核准日期{}校验失败".format(approved_time),
        )

        # 注册地址
        log.info("注册地址")
        reg_address = self.swipe_up_while_ele_located(By.ID,
                                                      elements["reg_address"])
        if reg_address.text == "-":
            self.assertEqual(reg_address.text, "-", "注册地址无数据展示错误")
        else:
            reg_address.click()
            map_title = self.new_find_element(By.ID,
                                              elements["app_page_title"]).text
            self.assertEqual(map_title, "公司地图", "注册地址跳转失败")
            self.driver.keyevent(4)

        # 经营范围
        log.info("经营范围")
        business_scope = self.swipe_up_while_ele_located(
            By.ID, elements["business_scope"]).text
        self.assertTrue(
            business_scope == "-" or len(business_scope) > 50,
            "经营范围{}校验失败".format(business_scope),
        )

    @getimage
    def test_3_shareholders_info_company(self):
        """企业背景-工商信息-股东信息-公司"""
        login_status = self.is_login()
        if not login_status:
            self.login(self.username, self.password)
        self.into_company_detail("北京转转精神科技有限责任公司")
        self.swipe_up_while_ele_located(By.XPATH,
                                        elements["business_info"],
                                        click=True)

        # 股东是公司跳转
        log.info("股东是公司跳转")
        company_holder = self.swipe_up_while_ele_located(
            By.ID, elements["shareholders_info"], group=True)[0]
        company_name = company_holder.text
        company_holder.click()
        detail_company_name = self.new_find_element(
            By.ID, elements["detail_company_name"]).text
        self.assertEqual(
            company_name,
            detail_company_name,
            "公司股东{}名称和详情页{}不一致".format(company_name, detail_company_name),
        )
        self.driver.keyevent(4)

        # 股权结构跳转
        log.info("股权结构跳转")
        self.driver.swipe(400, 1500, 400, 1450, 1000)
        structure_map = self.new_find_elements(By.ID,
                                               elements["structure_map"])[0]
        structure_map.click()
        page_title = self.new_find_element(By.ID,
                                           elements["app_page_title"],
                                           outtime=15).text
        self.assertEqual(page_title, "股权结构", "股权结构图跳转失败")
        self.driver.keyevent(4)

        # 认缴出资额
        log.info("认缴出资额")
        money_num = self.swipe_up_while_ele_located(By.ID,
                                                    elements["money_num"],
                                                    group=True)[1].text
        money_num_flag = is_bill_available(money_num)
        self.assertTrue(money_num_flag, "公司股东认缴出资额{}校验失败".format(money_num))

        # 认缴出资日期
        log.info("认缴出资日期")
        money_time = self.new_find_elements(By.ID,
                                            elements["money_time"])[1].text
        money_time_flag = check_time(money_time)
        self.assertTrue(money_time_flag,
                        "公司股东认缴出资日期{}校验失败".format(money_time_flag))

        # 持股比例
        log.info("持股比例")
        holder_percent = self.swipe_up_while_ele_located(
            By.ID, elements["holder_percent"], group=True)[0].text
        holder_percent_flag = is_percentage_available(holder_percent)
        self.assertTrue(holder_percent_flag,
                        "公司股东持股比例{}校验失败".format(holder_percent))

    @getimage
    def test_4_shareholders_info_human(self):
        """企业背景-工商信息-股东信息-人"""
        login_status = self.is_login()
        if not login_status:
            self.login(self.username, self.password)
        self.into_company_detail("字节跳动有限公司")
        self.swipe_up_while_ele_located(By.XPATH,
                                        elements["business_info"],
                                        click=True)

        # 股东是人跳转
        log.info("股东是人跳转")
        human_holder = self.swipe_up_while_ele_located(
            By.ID, elements["shareholders_info"], group=True)[0]
        human_name = human_holder.text
        human_holder.click()
        detail_human_name = self.new_find_element(
            By.ID, elements["detail_human_name"]).text
        self.assertEqual(
            human_name,
            detail_human_name,
            "人股东{}名称和详情页{}不一致".format(human_name, detail_human_name),
        )
        self.driver.keyevent(4)

        # 他有xx家公司跳转
        log.info("他有xx家公司跳转")
        self.new_find_elements(By.ID, elements["has_company"])[0].click()
        human_title = self.new_find_element(
            By.ID, elements["person_detail_title"]).text
        self.assertEqual(human_title, "人员详情", "股东信息人他有xx家公司跳转失败")
        self.driver.keyevent(4)

        # 认缴出资额
        log.info("认缴出资额")
        money_num = self.swipe_up_while_ele_located(By.ID,
                                                    elements["money_num"],
                                                    group=True)[1].text
        money_num_flag = is_bill_available(money_num)
        self.assertTrue(money_num_flag, "人股东认缴出资额{}校验失败".format(money_num))

        # 认缴出资日期
        log.info("认缴出资日期")
        money_time = self.new_find_elements(By.ID,
                                            elements["money_time"])[1].text
        money_time_flag = check_time(money_time)
        self.assertTrue(money_time_flag,
                        "人股东认缴出资日期{}校验失败".format(money_time_flag))

        # 持股比例
        log.info("持股比例")
        holder_percent = self.swipe_up_while_ele_located(
            By.ID, elements["holder_percent"], group=True)[0].text
        holder_percent_flag = is_percentage_available(holder_percent)
        self.assertTrue(holder_percent_flag,
                        "人股东持股比例{}校验失败".format(holder_percent))

    @getimage
    def test_5_main_person_and_change_list(self):
        """企业背景-工商信息-主要人员"""
        log.info(self.__doc__)
        login_status = self.is_login()
        if not login_status:
            self.login(self.username, self.password)
        self.into_company_detail("北京天眼查科技有限公司")
        self.swipe_up_while_ele_located(By.XPATH,
                                        elements["business_info"],
                                        click=True)

        # 主要人员-人员名称跳转
        log.info("主要人员-人员名称跳转")
        main_person = self.swipe_up_while_ele_located(By.ID,
                                                      elements["main_person"],
                                                      group=True)[0]
        main_person.click()
        person_title = self.new_find_element(
            By.ID, elements["person_detail_title"]).text
        self.driver.keyevent(4)
        self.assertEqual(person_title, "人员详情",
                         "主要人员{}跳转失败".format(person_title))

        # 主要人员-他有xx家公司跳转
        log.info("主要人员-他有xx家公司跳转")
        self.new_find_elements(By.XPATH,
                               elements["main_has_company"])[0].click()
        person_title = self.new_find_element(
            By.ID, elements["person_detail_title"]).text
        self.driver.keyevent(4)
        self.assertEqual(person_title, "人员详情",
                         "主要人员-他有xx家公司{}跳转失败".format(person_title))

        # 变更记录
        log.info("变更记录")
        # 变更时间
        log.info("变更时间")
        change_time = self.swipe_up_while_ele_located(By.ID,
                                                      elements["change_time"],
                                                      group=True)[0].text
        self.assertTrue(check_time(change_time, is_compare=True))

        # 变更内容
        log.info("变更内容")
        change_before = self.swipe_up_while_ele_located(
            By.ID, elements["change_before"], group=True)[0].text
        self.assertIsNot(change_before, "", "变更记录前内容为空")
        change_after = self.new_find_elements(By.ID,
                                              elements["change_after"])[0].text
        self.assertIsNot(change_after, "", "变更记录后内容为空")

    @getimage
    def test_6_company_branch(self):
        """企业背景-工商信息-分支机构"""
        log.info(self.__doc__)
        login_status = self.is_login()
        if not login_status:
            self.login(self.username, self.password)
        self.into_company_detail("长江证券股份有限公司")
        self.swipe_up_while_ele_located(By.XPATH,
                                        elements["business_info"],
                                        click=True)
        # 分支机构
        log.info("分支机构")
        company_branch = self.swipe_up_while_ele_located(
            By.ID, elements["company_branch"], times=30, group=True)[0]
        company_branch_name = company_branch.text
        company_branch.click()
        jump_name = self.new_find_element(By.ID,
                                          elements["detail_company_name"]).text
        self.driver.keyevent(4)
        self.assertEqual(
            company_branch_name,
            jump_name,
            "分支机构跳转名称{}和详情页名称{}不一致".format(company_branch_name, jump_name),
        )

    def test_7_release_account(self):
        self.account.release_account(self.username, 'vip')
Exemple #15
0
class Search_relation_sift_vip(MyTest, Operation):
    """查关系_高级筛选_08"""

    a = Read_Ex()
    ELEMENT = a.read_excel("Search_relation")
    account = Account()
    phone_vip = account.get_account("vip")

    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        cls.sift_opera = SiftOperation(cls.driver, cls.ELEMENT)
        cls.sift_opera.login_vip(cls.phone_vip, cls.account.get_pwd())

    @classmethod
    def tearDownClass(cls):
        cls.account.release_account(cls.phone_vip, "vip")
        super().tearDownClass()

    def get_company_lxfs(self, selectTarget, inputTarget):
        """
        获取公司:联系方式并断言
        :param selectTarget: 选中条件
        :param inputTarget: 输入内容
        """
        selectText = self.sift_opera.point2company(selectTarget)
        firm_name = self.new_find_element(By.ID, self.ELEMENT["firm_detail_name_tv"]).text
        log.info("高级筛选:{},断言公司名称:{}".format(selectText, firm_name))
        result = self.driver.find_element_by_id(self.ELEMENT["tv_base_info_phone"]).get_attribute("enabled")
        self.sift_opera.back2relation_search(inputTarget)
        return result

    @getimage
    def test_001_cgx_gjsx_lxfs_p0(self):
        """查关系-搜索中间页,高级筛选:联系方式"""
        log.info(self.test_001_cgx_gjsx_lxfs_p0.__doc__)
        try:
            inputTarget = self.sift_opera.search_key(2)
            num_lxfs = random.randint(1, 2)
            selectTarget, selectText = self.sift_opera.get_key("more_lxfs_title", "more_lxfs", num_lxfs)
            result = self.get_company_lxfs(selectTarget, inputTarget)
            if num_lxfs == 1:
                self.assertEqual("true", result, "===失败-联系方式(VIP特权)筛选:有联系方式===")
            else:
                self.assertEqual("false", result, "===失败-联系方式(VIP特权)筛选:无联系方式===")
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception

    @getimage
    def test_002_cgx_gjsx_zpzzq_p0(self):
        """查关系-搜索中间页,高级筛选:作品著作权"""
        log.info(self.test_002_cgx_gjsx_zpzzq_p0.__doc__)
        try:
            inputTarget = self.sift_opera.search_key(2)
            num_zpzzq = random.randint(1, 2)
            num_zpzzq = 2
            selectTarget, selectText = self.sift_opera.get_key("more_zpzzq_title", "more_zpzzq", num_zpzzq)
            result = self.sift_opera.detail4relation("著作权", selectTarget, inputTarget, num_zpzzq)
            if num_zpzzq == 2 and not result:
                # 断言-详情页「著作权」维度无数据时
                self.assertFalse(result, "===失败-高级筛选:「无作品著作权」错误===")
            else:
                if num_zpzzq == 1:
                    # 断言-「有作品著作权」
                    # self.assertNotIn("0", result, "===失败-高级筛选:「有作品著作权」错误===")
                    log.info("作品著作权:{}个".format(result))
                    self.assertNotEqual(0, result, "===失败-高级筛选:「有作品著作权」错误===")
                else:
                    # 断言-「无作品著作权」
                    # self.assertIn("0", result, "===失败-高级筛选:「无作品著作权」错误===")
                    self.assertEqual(0, result, "===失败-高级筛选:「无作品著作权」错误===")
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception
Exemple #16
0
class Search_company_sift(MyTest, Operation):
    """查公司_更多筛选_02"""

    a = Read_Ex()
    ELEMENT = a.read_excel("test_search_company_sift")
    account = Account()
    phone_vip = account.get_account("vip")

    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        cls.sift_opera = SiftOperation(cls.driver, cls.ELEMENT)

    @classmethod
    def tearDownClass(cls):
        cls.account.release_account(cls.phone_vip, 'vip')
        super().tearDownClass()

    def get_company_zblx(self, selectTarget, index=None):
        """
        获取公司:资本类型并断言
        :param selectTarget: 选中条件
        :param index: 选中项索引
        """
        result = None
        money = ["美", "新台币", "港", "澳", "日", "铢", "盾", "卢", "尼", " 镑", "尔"]
        selectText = self.new_find_element(By.ID, self.ELEMENT["tv_title"]).text
        if self.isElementExist(By.ID, self.ELEMENT["more_empty_view"]):
            pass
        else:  # 查公司-「机构类型」筛选
            items = self.sift_opera.random_list()
            log.info("资本类型:「{}」,搜索结果页-公司列表长度:{}".format(selectText, str(items)))
            if items > 2:  # 防止item超出页面,无法获取元素
                items = items - 2
            company_xpath = "{}[{}]{}".format(self.ELEMENT["company_list"], str(items),
                                              self.ELEMENT["company_name_path"])
            assert_company = self.new_find_element(By.XPATH, company_xpath).text
            Layout_text = '//*[@resource-id="com.tianyancha.skyeye:id/base_info_ll"]/android.widget.LinearLayout[2]/android.widget.TextView[2]'
            text_xpath = "{}[{}]{}".format(self.ELEMENT["company_list"], str(items), Layout_text)
            zblx_text = self.new_find_element(By.XPATH, text_xpath).text
            log.info("断言公司名称:{},注册资本:{}".format(assert_company, zblx_text))
            if index == 1:
                if "人民" not in zblx_text:
                    # 若资本类型无币种,则默认归入人民币中,断言无其他币种即通过
                    tag = True
                    for i in money:
                        if i in zblx_text:
                            tag = False
                    result = tag
                else:
                    result = "人民" in zblx_text
            elif index == 2:
                result = "美" in zblx_text
            else:
                tag1 = "人民" not in zblx_text
                tag2 = "美" not in zblx_text
                result = tag1 and tag2
        self.sift_opera.reset(selectTarget)
        return result

    def get_company_qylx(self, selectTarget, index=None):
        """
        获取公司:企业类型并断言
        :param selectTarget: 选中条件
        :param index: 选中项索引
        """
        selectText = self.new_find_element(By.ID, self.ELEMENT["tv_title"]).text
        if self.isElementExist(By.ID, self.ELEMENT["more_empty_view"]):
            result = "企业类型:{},筛选无结果".format(selectText)
        else:  # 查公司-「机构类型」筛选
            items = self.sift_opera.random_list()
            log.info("企业类型:「{}」,搜索结果页-公司列表长度:{}".format(selectText, str(items)))
            if items > 2:  # 防止item超出页面,无法获取元素
                items = items - 2
            company_xpath = "{}[{}]{}".format(self.ELEMENT["company_list"], str(items),
                                              self.ELEMENT["company_name_path"])
            company_name = self.new_find_element(By.XPATH, company_xpath)
            log.info("断言公司名称:{}".format(company_name.text))
            company_name.click()
            result = self.sift_opera.company_type(selectText, index)
        self.sift_opera.back2company_search()
        self.sift_opera.reset(selectTarget)
        return result

    def get_company_cbrs(self, selectTarget, index=None):
        """
        获取公司:参保人数并断言
        :param selectTarget: 选中条件
        :param index: 选中项索引
        """
        result = None
        selectText = self.new_find_element(By.ID, self.ELEMENT["tv_title"]).text
        if self.isElementExist(By.ID, self.ELEMENT["more_empty_view"]):
            log.info("参保人数:{},筛选无结果".format(selectText))
            self.sift_opera.reset(selectTarget)
        else:  # 查公司-「机构类型」筛选
            items = self.sift_opera.random_list()
            log.info("参保人数:「{}」,搜索结果页-公司列表长度:{}".format(selectText, str(items)))
            if items > 2:  # 防止item超出页面,无法获取元素
                items = items - 2
            company_xpath = "{}[{}]{}".format(self.ELEMENT["company_list"], str(items),
                                              self.ELEMENT["company_name_path"])
            company_name_ele = self.new_find_element(By.XPATH, company_xpath)
            company_name = company_name_ele.text
            log.info("断言公司名称:{}".format(company_name))
            company_name_ele.click()
            for i in range(20):
                if self.isElementExist(By.XPATH, self.ELEMENT["more_gsxx_dimension"]):
                    self.new_find_element(By.XPATH, self.ELEMENT["more_gsxx_dimension"]).click()
                    # 工商信息维度,查找参保人数字段
                    for j in range(20):
                        if self.isElementExist(By.ID, self.ELEMENT["tv_social_staff_num"]):
                            cbrsStr = self.new_find_element(By.ID, self.ELEMENT["tv_social_staff_num"]).text
                            cbrsNum = re.findall(r"\d+\.?\d*", cbrsStr)
                            log.info("{}-参保人数:{}".format(company_name, cbrsNum[0]))
                            _dict = {
                                1: 0 <= int(cbrsNum[0]),
                                2: 50 <= int(cbrsNum[0]) <= 99,
                                3: 100 <= int(cbrsNum[0]) <= 499,
                                4: 500 <= int(cbrsNum[0]) <= 999,
                                5: 1000 <= int(cbrsNum[0]) <= 4999,
                                6: 5000 <= int(cbrsNum[0]) <= 9999,
                                7: 10000 <= int(cbrsNum[0]),
                            }
                            for k in _dict.keys():
                                if k == index:
                                    result = _dict[index]
                            break
                        else:
                            self.swipeUp(0.5, 0.7, 0.3, 2000)
                            if j == 19:
                                log.info("参保人数断言失败-工商信息详情页,参保人数未找到")
                    break
                else:
                    self.swipeUp(0.5, 0.7, 0.3, 2000)
                    if self.isElementExist(By.XPATH,
                                           '//*[@class="android.widget.TextView" and @text="登记信息"]') and index == 1:
                        log.info("{},展示「登记信息」无参保人数".format(company_name))
                        result = True
                        break
                    if i == 19:
                        log.info("参保人数断言失败-公司详情页未找到「工商信息」")
        self.sift_opera.back2company_search()
        self.sift_opera.reset(selectTarget)
        return result

    @getimage
    def test_001_cgs_ptsx_zblx_p0(self):
        """查公司-搜索中间页,普通筛选:资本类型"""
        log.info(self.test_001_cgs_ptsx_zblx_p0.__doc__)
        try:
            self.sift_opera.login_vip(self.phone_vip, self.account.get_pwd())
            self.sift_opera.search_key(1)
            num_zblx = random.randint(1, 3)
            selectTarget, selectText = self.sift_opera.get_key("more_zblx_title", "more_zblx", num_zblx)
            result = self.get_company_zblx(selectTarget, num_zblx)
            if result is None:
                log.info("资本类型:{},筛选无结果".format(selectText))
            else:
                self.assertTrue(result, "===失败-更多筛选:资本类型:{}===".format(selectText))
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception

    @getimage
    def test_002_cgs_ptsx_qylx_p0(self):
        """查公司-搜索中间页,普通筛选:企业类型"""
        log.info(self.test_002_cgs_ptsx_qylx_p0.__doc__)
        try:
            self.sift_opera.search_key(1)
            num_qylx = random.randint(1, 11)
            selectTarget, selectText = self.sift_opera.get_key("more_qylx_title", "more_qylx", num_qylx)
            result = self.get_company_qylx(selectTarget, num_qylx)
            if isinstance(result, type("返回值类型为str")):
                log.info(result)
            else:
                self.assertTrue(result, "===失败-工商信息详情页中,企业类型断言错误===")
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception

    @getimage
    def test_003_cgs_ptsx_cbrs_p0(self):
        """查公司-搜索中间页,普通筛选:参保人数"""
        log.info(self.test_003_cgs_ptsx_cbrs_p0.__doc__)
        try:
            self.sift_opera.search_key(1)
            num_cbrs = random.randint(1, 7)
            selectTarget, selectText = self.sift_opera.get_key("more_cbrs_title", "more_cbrs", num_cbrs)
            result = self.get_company_cbrs(selectTarget, num_cbrs)
            if result is None:
                pass
            else:
                self.assertTrue(result, "===失败-工商信息详情页中,参保人数断言错误===")
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception
Exemple #17
0
class Search_relationTest(MyTest, Operation):
    """查关系_02"""

    a = Read_Ex()
    ELEMENT = a.read_excel("Search_relation")
    account = Account()
    phone_vip = account.get_account("vip")
    phone_normal = account.get_account()

    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        cls.sift_opera = SiftOperation(cls.driver, cls.ELEMENT)

    @classmethod
    def tearDownClass(cls):
        cls.account.release_account(cls.phone_vip, "vip")
        cls.account.release_account(cls.phone_normal)
        super().tearDownClass()

    def check_vip_normal(self, index=None):
        """
        校验非vip态、登陆态
        :param index: 1:未登陆态; 2:非VIP
        :return:
        """
        Key = ["passwd_login", "tv_top_title"]
        Value = ["passwd_login_text", "tv_top_title_text"]
        self.sift_opera.search_key(2)
        self.new_find_element(By.ID, self.ELEMENT["select_more"]).click()
        result1 = self.ELEMENT["open_vip_ll_text"] == self.new_find_element(
            By.ID, self.ELEMENT["open_vip_ll"]).text
        self.new_find_element(By.ID, self.ELEMENT["open_vip_ll"]).click()
        if index == 1:
            log.info("校验-未登陆态")
            result2 = self.ELEMENT[Value[index - 1]] == self.new_find_element(
                By.XPATH, self.ELEMENT[Key[index - 1]]).text
        else:
            log.info("校验-非VIP")
            result2 = self.ELEMENT[Value[index - 1]] == self.new_find_element(
                By.ID, self.ELEMENT[Key[index - 1]]).text
        self.driver.keyevent(4)
        selectTarget, selectText = self.sift_opera.get_key(
            "more_ssfw_title", "more_ssfw", 1)
        if index == 1:
            result3 = self.isElementExist(By.XPATH,
                                          self.ELEMENT[Key[index - 1]])
        else:
            result3 = self.isElementExist(By.XPATH,
                                          self.ELEMENT[Key[index - 1]])
        self.sift_opera.reset(selectTarget)
        self.sift_opera.get_key("more_lxfs_title", "more_lxfs", 1)
        if index == 1:
            passwd_login = self.new_find_element(
                By.XPATH, self.ELEMENT["passwd_login"]).text
            result4 = self.ELEMENT["passwd_login_text"] == passwd_login
            self.new_find_element(By.ID, self.ELEMENT["title_back"]).click()
        else:
            middle_title = self.new_find_element(
                By.ID, self.ELEMENT["tv_middle_title"]).text
            result4 = self.ELEMENT["tv_middle_title_text"] == middle_title
            self.driver.keyevent(4)
        back_max = 30
        back_cnt = 0
        while not self.isElementExist(By.ID, self.ELEMENT["search_relation"]):
            self.driver.keyevent(4)
            back_cnt += 1
            if back_cnt > back_max:
                break
        return result1, result2, result3, result4

    def rel_detail(self):
        self.sift_opera.search_key(2)
        result1 = self.isElementExist(By.ID, self.ELEMENT["select_more"])
        self.new_find_element(By.ID, self.ELEMENT["select_more"]).click()
        result2 = self.isElementExist(By.ID, self.ELEMENT["open_vip_ll"])
        result3 = self.isElementExist(By.ID, self.ELEMENT["bt_reset"])
        self.new_find_element(By.ID, self.ELEMENT["select_more"]).click()
        t_xpath = "{}/android.widget.RelativeLayout/android.widget.TextView".format(
            self.ELEMENT["from_target_item"])
        company_name = self.new_find_element(By.XPATH, t_xpath).text
        self.new_find_element(By.XPATH,
                              self.ELEMENT["from_target_item"]).click()
        title_tag = self.new_find_element(By.ID,
                                          self.ELEMENT["app_title_name"]).text
        result4 = title_tag == "企业详情"
        d_xpath = "{}/android.widget.TextView".format(
            self.ELEMENT["lv_firm_detail"])
        tarName = self.new_find_element(By.XPATH, d_xpath).text
        result5 = tarName == company_name
        f_xpath = "{}/android.widget.ImageView".format(
            self.ELEMENT["lv_firm_detail"])
        self.new_find_element(By.XPATH, f_xpath).click()
        s_xpath = "{}/android.widget.RelativeLayout/android.widget.TextView".format(
            self.ELEMENT["sky_canvas"])
        comName = self.new_find_element(By.XPATH, s_xpath).text
        result6 = comName == company_name
        back_max = 30
        back_cnt = 0
        while not self.isElementExist(By.ID, self.ELEMENT["search_relation"]):
            self.driver.keyevent(4)
            back_cnt += 1
            if back_cnt > back_max:
                break
        return result1, result2, result3, result4, result5, result6

    @getimage
    def test_001_cgx_vip_p0(self):
        """未登陆、非VIP校验"""
        log.info(self.test_001_cgx_vip_p0.__doc__)
        try:
            result1, result2, result3, result4 = self.check_vip_normal(1)
            # 断言 - 更多筛选下拉框,展示vip入口
            self.assertTrue(result1, "===失败-获取更多筛选下拉框vip入口失败===")
            # 断言 - 更多筛选下拉框,点击vip入口
            self.assertTrue(result2, "===失败-未登陆态,更多筛选下拉框vip入口,拉起登陆页失败===")
            # 断言 - 更多筛选下拉框,点击普通筛选项
            self.assertFalse(result3, "===失败-未登陆态,更多筛选下拉框非vip筛选项错误拉起登陆===")
            # 断言 - 更多筛选下拉框,点击高级筛选项
            self.assertTrue(result4, "===失败-拉起登陆页失败===")
            # 判断非vip
            self.sift_opera.login_normal(self.phone_normal,
                                         self.account.get_pwd())
            result1, result2, result3, result4 = self.check_vip_normal(2)
            # 断言 - 更多筛选下拉框,点击vip入口
            self.assertTrue(result2, "===失败-非vip,更多筛选下拉框vip入口,拉起登陆页失败===")
            # 断言 - 更多筛选下拉框,点击普通筛选项
            self.assertFalse(result3, "===失败-非vip,更多筛选下拉框非vip筛选项,错误限制===")
            # 断言 - 更多筛选下拉框,点击高级筛选项
            self.assertTrue(result4, "===失败-弹出vip弹窗失败===")
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception

    @getimage
    def test_002_cgx_xqy_p0(self):
        """查关系-搜索结果页,公司详情"""
        log.info(self.test_002_cgx_xqy_p0.__doc__)
        try:
            self.sift_opera.login_vip(self.phone_vip, self.account.get_pwd())
            result1, result2, result3, result4, result5, result6 = self.rel_detail(
            )
            # 断言-输入关键词,展示更多筛选按钮
            self.assertTrue(result1, "===失败-更多筛选按钮未展示===")
            # 断言-更多筛选下拉展示
            self.assertFalse(result2, "===失败-vip用户,高级筛选下拉框未隐藏vip入口===")
            self.assertTrue(result3, "===失败-更多筛选下拉展示失败===")
            # 断言-查关系搜索列表,进入企业详情
            self.assertTrue(result4, "===失败-进入查关系-企业详情选取节点页错误===")
            self.assertTrue(result5, "===失败-查关系公司详情页,公司名错误===")
            # # 断言-通过查关系企业详情页,获取关系图节点
            self.assertTrue(result6, "===失败-通过查关系公司详情页,获取节点失败===")
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception
 def test_003_qbfw_zdh_p0(self):
     """
     找电话功能正常使用
     1、热门搜索
     2、输入搜索—有结果(点击公司/打电话)
     3、输入搜搜索无结果
     4、筛选 ---未做校验
     5、最近搜索(最多展示10)
     6、一键清除
     7、公司详情页跳转
     8、拨打电话
     """
     log.info(self.test_003_qbfw_zdh_p0.__doc__)
     try:
         self.in_allserver('zdh')
         # 随机点击热搜公司
         hot_search = self.hot_search()
         log.info('点击热搜公司:{}'.format(hot_search))
         legal_person = self.new_find_elements(
             By.ID, self.ELEMENT['legal_person_name'])[0].text
         log.info('法人:{}'.format(legal_person))
         phone = self.new_find_elements(By.ID,
                                        self.ELEMENT['phone_num'])[0].text
         log.info('电话:{}'.format(phone))
         address = self.new_find_elements(
             By.ID, self.ELEMENT['address_ph'])[0].text
         log.info('电话:{}'.format(address))
         cname = self.new_find_elements(By.ID,
                                        self.ELEMENT['company'])[0].text
         legal_name = self.new_find_elements(
             By.ID, self.ELEMENT['legal_person_name'])[0].text
         # 公司详情页跳转
         self.new_find_elements(By.ID, self.ELEMENT['company'])[0].click()
         self.jump_bounced('first_btn')
         time.sleep(2)
         cname1 = self.new_find_element(By.ID,
                                        self.ELEMENT['company1']).text
         legal_name1 = self.new_find_element(
             By.ID, self.ELEMENT['legal_person_name1']).text
         self.assertEqual(cname1, cname, msg='结果页-详情页 公司名称不一致')
         self.assertEqual(legal_name1, legal_name, msg='结果页-详情页 法人名称不一致')
         self.driver.keyevent(4)
         # 导出数据
         self.new_find_element(By.ID, self.ELEMENT['export_data']).click()
         # 获取使用账号
         account = Account()
         acc_vip_name = account.get_account('vip')
         acc_pwd = account.get_pwd()
         log.info("登录VIP账号:".format(acc_vip_name))
         self.hit_login(account=acc_vip_name, password=acc_pwd)
         count = self.count_num(By.ID, self.ELEMENT['search_title'])
         log.info("搜索结果列表页count:{}".format(count))
         # 再次点击导出数据
         self.new_find_element(By.ID, self.ELEMENT['export_data']).click()
         if count > 5000:
             # 选择非增值导出
             self.new_find_element(By.XPATH,
                                   self.ELEMENT['free_export']).click()
             self.new_find_element(By.XPATH,
                                   self.ELEMENT['email_export']).send_keys(
                                       '*****@*****.**')
         else:
             self.new_find_element(By.XPATH,
                                   self.ELEMENT['free_export']).click()
             # self.new_find_element(By.XPATH, self.ELEMENT['email_export']).click()
             self.new_find_element(By.XPATH,
                                   self.ELEMENT['email_export1']).send_keys(
                                       '*****@*****.**')
         self.new_find_element(By.XPATH,
                               self.ELEMENT['export_click']).click()
         # 成功页回到搜索结果页
         self.new_find_element(By.ID, self.ELEMENT['success_back']).click()
         # 拨打电话
         phone_num = self.new_find_elements(
             By.ID, self.ELEMENT['phone_num'])[0].text
         log.info('点击电话:{}'.format(phone_num))
         if phone_num == '暂无信息':
             self.new_find_elements(By.ID,
                                    self.ELEMENT['phone_num'])[1].click()
         else:
             self.new_find_elements(By.ID,
                                    self.ELEMENT['phone_num'])[0].click()
         a = self.isElementExist(By.ID, self.ELEMENT['num_input'])
         self.assertTrue(a, msg='未找到手机拨号页面')
         self.driver.keyevent(4)
         self.driver.keyevent(4)
         # 输入搜搜索无结果-@@
         self.search_clean()
         self.search_input('@@')
         c = self.isElementExist(By.ID, self.ELEMENT['search_title'])
         self.assertFalse(c, msg='标识存在的话是有结果')
         # 输入搜索—有结果 天眼查/85587728
         self.search_clean()
         d = self.search_input('85587728')
         d1 = self.new_find_elements(By.ID,
                                     self.ELEMENT['phone_num'])[0].text
         self.assertIn(d, d1, msg='电话号码in')
         e = self.isElementExist(By.ID, self.ELEMENT['search_title'])
         self.assertTrue(e, msg='标识不存在的话是无结果')
         self.search_clean()
         # 一键清除
         self.search_recent_clear(2)
         f = self.isElementExist(By.ID, self.ELEMENT['search_recent_clear'])
         self.assertTrue(f, msg='一键清除-取消,最近搜索按钮还存在')
         self.search_recent_clear()
         g = self.isElementExist(By.ID, self.ELEMENT['search_recent_clear'])
         self.assertFalse(g, msg='一键清除-确认,最近搜索按钮不存在')
         h = self.isElementExist(By.XPATH, self.ELEMENT['hotsearch_bs'])
         self.assertTrue(h, msg='一键清除不存在,「热门搜素」存在')
         # 最近搜索记录
         name_list = [
             '马云', '孙凯', '王四会', '马丁', '韩磊', '李明', '向小叶', '蓝小凯', '李晓凯',
             '朱小凯', '赵小凯', '陈小凯'
         ]
         for name in name_list:
             log.info('输入搜索词:{}'.format(name))
             self.search_input(name)
             self.search_clean()
         history_words = self.new_find_elements(By.XPATH,
                                                self.ELEMENT['hot_search'])
         for i in range(10):
             log.info("历史:{} vs 输入:{}".format(history_words[i].text,
                                              name_list[11 - i]))
             self.assertEqual(history_words[i].text, name_list[11 - i],
                              '名字顺序不一致')
         # 使用完了要还回去
         account.release_account(acc_vip_name, "vip")
     except AssertionError:
         raise self.failureException()
     except Exception as e:
         print(e)
         raise Exception
Exemple #19
0
    def test_005_taiwan_dwtz_p0(self):
        """
        台湾企业-企业背景-对外投资
        """
        log.info(self.test_005_taiwan_dwtz_p0.__doc__)
        try:
            self.enter_official_information('怡安医疗器材股份有限公司')
            # 获取对外投资 公司详情页count
            foreign_investment_count = self.new_find_element(By.XPATH, self.ELEMENT['foreign_investment_count']).text
            foreign_investment_count = int(foreign_investment_count)
            log.info("对外投资count:{}".format(foreign_investment_count))
            # 进入对外投资模块
            self.new_find_element(By.XPATH, self.ELEMENT["foreign_investment"]).click()
            title_name = self.get_elemengt_text(self.ELEMENT['title_name'])
            log.info("页面title:{}".format(title_name))
            self.assertEqual("对外投资", title_name, msg="页面title不对应")
            # 对外投资 公司/公司跳转
            comp = self.new_find_elements(By.ID, self.ELEMENT['outinvest_company_name_tv'])
            comp_name = comp[0].text # 公司名称
            log.info('对外投资公司:{}'.format(comp_name))
            comp[0].click() # 进入公司详情页
            self.driver.keyevent(4) # 公司详情页回退到对外投资页
            # 法定代表人/人详情跳转
            outinvest_legal_tv = self.new_find_elements(By.ID, self.ELEMENT['outinvest_company_name_tv'])
            outinvest_legal_tv1 = outinvest_legal_tv[0].text
            log.info("法定代表人:{}".format(outinvest_legal_tv1))
            outinvest_legal_tv[0].click() # 进入人详情
            self.driver.keyevent(4)  # 人详情页回退到对外投资页
            # 经营状态
            outinvest_reg_capital_tv = self.new_find_elements(By.ID, self.ELEMENT['outinvest_reg_capital_tv'])
            outinvest_reg_capital_tv1 = outinvest_reg_capital_tv[0].text
            log.info("经营状态:{}".format(outinvest_reg_capital_tv1))
            self.assertTrue(operating_check(1, outinvest_reg_capital_tv1))
            # 投资数额
            tv_outinvest_amount = self.new_find_elements(By.ID, self.ELEMENT['tv_outinvest_amount'])
            tv_outinvest_amount1 = tv_outinvest_amount[0].text
            log.info("投资数额:{}".format(tv_outinvest_amount1))
            self.assertTrue(is_bill_available(tv_outinvest_amount1))
            # 投资比例
            tv_outinvest_ratio = self.new_find_elements(By.ID, self.ELEMENT['tv_outinvest_ratio'])
            tv_outinvest_ratio1 = tv_outinvest_ratio[0].text
            log.info("注册比例:{}".format(tv_outinvest_ratio1))
            self.assertTrue(is_percentage_available(tv_outinvest_ratio1))
            # 成立日期
            tv_outinverst_date = self.new_find_elements(By.ID, self.ELEMENT['tv_outinverst_date'])
            tv_outinverst_date1 = tv_outinverst_date[0].text
            log.info("成立日期:{}".format(tv_outinverst_date1))
            # 股权结构
            tv_outinvest_title_right = self.new_find_elements(By.ID, self.ELEMENT['tv_outinvest_title_right'])
            tv_outinvest_title_right[0].click()

            account = Account()
            acc_vip_name = account.get_account('vip')
            acc_pwd = account.get_pwd()
            log.info("登录VIP账号:{},密码为:{}".format(acc_vip_name, acc_pwd))
            self.login(acc_vip_name, acc_pwd)
            title_name = self.get_elemengt_text(self.ELEMENT['title_name'])
            log.info("页面title:{}".format(title_name))
            self.assertEqual("股权结构", title_name, msg="页面title不对应")
            self.driver.keyevent(4)
            # 对外投资列表页count统计
            foreign_investment_count1 = self.all_count_compute_v1(By.ID, self.ELEMENT['outinvest_company_name_tv'])
            self.assertEqual(foreign_investment_count1, foreign_investment_count)
            account.release_account(acc_vip_name, "vip")
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception
Exemple #20
0
class Search_relationTest(MyTest, Operation):
    """查关系_03"""

    a = Read_Ex()
    ELEMENT = a.read_excel("Search_relation")
    account = Account()
    phone_vip = account.get_account("vip")

    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        cls.sift_opera = SiftOperation(cls.driver, cls.ELEMENT)

    @classmethod
    def tearDownClass(cls):
        cls.account.release_account(cls.phone_vip, account_type='vip')
        super().tearDownClass()

    @getimage
    def into_middle_page(self):
        """
        进入查关系页
        """
        self.new_find_element(By.ID, self.ELEMENT["search_relation"]).click()
        self.new_find_element(By.ID, self.ELEMENT["search_box"]).click()

    @getimage
    def capital(self):
        """注册资本校验"""
        if self.isElementExist(By.ID, self.ELEMENT["more_zczb_title_num"]):
            zczbStr = self.new_find_element(
                By.ID, self.ELEMENT["more_zczb_title_num"]).text
            if zczbStr == "-":
                result = float(0)
            else:
                result = float(re.findall(r"\d+\.?\d*", zczbStr)[0])
        else:
            result = float(0)
        return result

    @getimage
    def years(self):
        """注册年限校验"""
        zcnxStr = self.new_find_element(
            By.ID, self.ELEMENT["more_zcnx_title_num"]).text
        if zcnxStr == '-':
            result = datetime.datetime(1900, 1, 1)
        else:
            zcnxStrList = zcnxStr.split(".")
            result = datetime.datetime(int(zcnxStrList[0]),
                                       int(zcnxStrList[1]),
                                       int(zcnxStrList[2]))
        return result

    @getimage
    def select_image(self, sort, index, tag, inputTarget):
        """
        筛选后,选择公司
        :param sort: 排序
        :param index: 索引
        :param tag: 1:第一家公司;2:第二家公司
        :param inputTarget: 选中项
        :return:
        """
        self.new_find_element(By.ID,
                              self.ELEMENT["search_sort_or_cancel"]).click()
        self.new_find_element(
            By.XPATH,
            '//*[@class="android.widget.TextView" and @text="{}"]'.format(
                sort)).click()
        img_xpath = '//*[@resource-id="android:id/list"]/android.widget.LinearLayout[{}]/android.widget.RelativeLayout/android.widget.ImageView'.format(
            str(tag))
        self.new_find_element(By.XPATH, img_xpath).click()
        self.new_find_element(By.XPATH, self.ELEMENT["sky_canvas"]).click()
        company_name = self.new_find_element(
            By.ID, self.ELEMENT["firm_detail_name_tv"]).text
        log.info("{},断言公司名称「{}」:{}".format(sort, str(tag), company_name))
        if index == 0 or index == 1:
            result = self.capital()
        else:
            result = self.years()
        self.sift_opera.back2relation_search(inputTarget)
        return result

    @getimage
    def test_001_cgx_sszjy_p0(self):
        """查关系-搜索中间页热搜"""
        log.info(self.test_001_cgx_sszjy_p0.__doc__)
        sortKey = ["按注册资本从高到低", "按注册资本从低到高", "按成立日期从早到晚", "按成立日期从晚到早"]
        try:
            self.sift_opera.login_vip(self.phone_vip, self.account.get_pwd())
            self.into_middle_page()
            self.new_find_element(By.ID,
                                  self.ELEMENT["from_input_textview"]).click()

            # 删除历史记录
            if self.isElementExist(By.ID,
                                   self.ELEMENT["middlepage_search_history"]):
                self.new_find_element(
                    By.ID,
                    self.ELEMENT["middlepage_search_history_delete"]).click()
                self.new_find_element(By.ID,
                                      self.ELEMENT["delete_confirm"]).click()

            # 断言-点击热搜词,输入框中带入对应关键词
            tarHotWord = self.new_find_element(
                By.XPATH, self.ELEMENT["middlepage_hot_search_target"])
            hotWordText = tarHotWord.text
            tarHotWord.click()
            tarWordText = self.new_find_element(
                By.ID, self.ELEMENT["search_input_edit"]).text
            self.assertEqual(tarWordText, hotWordText,
                             "===失败-搜索关键词与热搜关键词不一致===")

            # 断言-搜索输入框一键删除按钮
            btn = self.isElementExist(By.ID, self.ELEMENT["search_clean_iv"])
            self.assertTrue(btn, "===失败-搜索输入框,一键删除按钮展示错误===")

            # 断言-搜索匹配结果包含关键词
            result_text = self.new_find_element(
                By.XPATH, self.ELEMENT["search_result"]).text
            brand_text = self.new_find_element(
                By.XPATH, self.ELEMENT["search_result_brand"]).text
            tag = hotWordText in result_text or hotWordText in brand_text
            self.assertTrue(tag, "===失败-搜索结果不包含关键字===")

            # 断言-搜索结果页排序
            self.new_find_element(By.ID,
                                  self.ELEMENT["search_clean_iv"]).click()
            self.new_find_element(
                By.ID, self.ELEMENT["search_input_edit"]).send_keys("佳洋")
            keyNum = random.randint(0, 3)
            result1 = self.select_image(sortKey[keyNum], keyNum, 1, "佳洋")
            result2 = self.select_image(sortKey[keyNum], keyNum, 2, "佳洋")
            if keyNum == 0 or keyNum == 3:
                # 断言-按注册资本从高到低;按成立日期从晚到早
                self.assertTrue(result1 >= result2,
                                "===失败-{}排序错误===".format(sortKey[keyNum]))
            else:
                # 断言-按注册资本从低到高;按成立日期从早到晚
                self.assertTrue(result1 <= result2,
                                "===失败-{}排序错误===".format(sortKey[keyNum]))

            # 断言-点击搜索输入框一键删除按钮,清空搜索关键词
            self.new_find_element(By.ID,
                                  self.ELEMENT["search_clean_iv"]).click()
            cancel = self.new_find_element(
                By.ID, self.ELEMENT["search_sort_or_cancel"]).text
            self.assertEqual("取消", cancel, "===失败-点击输入框关键字一键删除按钮,清空失败===")

        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception

    @getimage
    def test_002_cgx_gdcz_p0(self):
        """查关系-关系图,更多操作校验"""
        log.info(self.test_002_cgx_gdcz_p0.__doc__)
        try:
            self.into_middle_page()
            # 断言-展示默认关系占位图(马云-赵薇)
            self.assertTrue(
                self.isElementExist(By.ID, self.ELEMENT["relation_empty"]),
                "===失败-未展示查关系占位图===",
            )
            # 断言-进入搜索中间页
            self.new_find_element(By.ID,
                                  self.ELEMENT["from_input_textview"]).click()
            self.assertTrue(
                self.isElementExist(By.ID, self.ELEMENT["search_contacts"]),
                "===失败-未显示身边老板入口===",
            )
            # 断言-输入起始节点
            self.new_find_element(
                By.ID,
                self.ELEMENT["search_input_edit"]).send_keys("北京金堤科技有限公司")
            cancel = self.new_find_element(
                By.ID, self.ELEMENT["search_sort_or_cancel"]).text
            self.assertEqual(cancel, "排序", "===失败-输入起始节点失败===")
            # 断言-回填起始节点
            self.new_find_element(By.XPATH,
                                  self.ELEMENT["from_target_item_1"]).click()
            self.assertEqual(
                self.new_find_element(
                    By.ID, self.ELEMENT["from_input_textview"]).text,
                "北京金堤科技有限公司",
                "===失败-回填起始节点错误===",
            )
            # 断言-输入一个关键词,查关系按钮不可点
            attr = self.new_find_element(
                By.ID, self.ELEMENT["discover_btn"]).get_attribute("enabled")
            self.assertEqual(attr, "false", "===失败-查关系按钮未置灰===")
            # 断言-输入两个关键词,查关系按钮可点
            self.new_find_element(By.ID,
                                  self.ELEMENT["to_input_textview"]).click()
            self.new_find_element(
                By.ID,
                self.ELEMENT["search_input_edit"]).send_keys("盐城金堤科技有限公司")
            self.new_find_element(By.XPATH,
                                  self.ELEMENT["from_target_item_1"]).click()
            attr = self.new_find_element(
                By.ID, self.ELEMENT["discover_btn"]).get_attribute("enabled")
            self.assertEqual(attr, "true", "===失败-查关系按钮置灰===")
            self.assertTrue(
                self.isElementExist(By.ID, self.ELEMENT["more_operation_btn"]),
                "===失败-未展示更多操作按钮===",
            )
            self.assertTrue(
                self.isElementExist(By.ID, self.ELEMENT["clear_all"]),
                "===失败-未展示一键清空按钮===",
            )
            # 断言-输入完关键词后,点开查关系
            self.new_find_element(By.ID, self.ELEMENT["discover_btn"]).click()
            # 断言-关系图,更多操作-分享按钮
            self.new_find_element(By.ID,
                                  self.ELEMENT["more_operation_btn"]).click()
            self.new_find_element(By.ID,
                                  self.ELEMENT["map_more_share"]).click()
            self.assertTrue(
                self.isElementExist(By.ID, self.ELEMENT["btn_wechat_friends"]),
                "===失败-关系图-更多操作-分享弹框-微信好友===",
            )
            self.assertTrue(
                self.isElementExist(By.ID,
                                    self.ELEMENT["btn_wechat_pengyouquan"]),
                "===失败-关系图-更多操作-分享弹框-微信朋友圈===",
            )
            self.new_find_element(By.ID, self.ELEMENT["share_cancel"]).click()
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception

        try:
            # 断言-关系图,更多操作-保存按钮
            self.new_find_element(By.ID,
                                  self.ELEMENT["more_operation_btn"]).click()
            self.assertTrue(
                self.isElementExist(By.ID, self.ELEMENT["map_more_save"]),
                "===失败-关系图-更多操作-保存按钮===",
            )
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception

        try:
            # 断言-关系图,更多操作-扫一扫按钮
            self.assertTrue(
                self.isElementExist(By.ID, self.ELEMENT["map_more_scan"]),
                "===失败-关系图-更多操作-扫一扫按钮===",
            )
            self.new_find_element(By.ID, self.ELEMENT["map_more_scan"]).click()
            self.assertEqual(
                self.ELEMENT["scan_page_title_text"],
                self.new_find_element(By.XPATH,
                                      self.ELEMENT["scan_page_title"]).text,
                "===失败-关系图-更多操作扫一扫页title===",
            )
            self.assertTrue(
                self.isElementExist(By.ID, self.ELEMENT["bt_scan"]),
                "===失败-关系图-更多操作-扫一扫页,扫一扫按钮===",
            )
            self.new_find_element(By.ID, self.ELEMENT["bt_scan"]).click()
            if self.isElementExist(By.XPATH, self.ELEMENT["permission_btn"]):
                self.new_find_element(By.XPATH,
                                      self.ELEMENT["permission_btn"]).click()
            self.assertTrue(
                self.isElementExist(By.ID, self.ELEMENT["viewfinder_view"]),
                "===失败-进入扫描页失败===",
            )
            self.driver.keyevent(4)
            self.driver.keyevent(4)
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception

        try:
            # 断言-关系图,更多操作-删减按钮
            self.new_find_element(By.ID,
                                  self.ELEMENT["more_operation_btn"]).click()
            # 断言-关系图更多操作,展示删减按钮
            self.assertTrue(True, "===失败-关系图-更多操作-删减按钮===")
            self.new_find_element(By.ID, self.ELEMENT["map_more_edit"]).click()
            # 断言-关系图更多操作,点击删减按钮,展示取消、确认、撤销按钮
            self.assertTrue(
                self.isElementExist(By.ID, self.ELEMENT["btn_cancle"]),
                "===失败-关系图-更多操作-删减操作取消按钮===",
            )
            self.assertTrue(
                self.isElementExist(By.ID, self.ELEMENT["btn_save"]),
                "===失败-关系图-更多操作-删减操作确定按钮===",
            )
            # 断言-未删减节点,插销按钮不可点
            self.assertEqual(
                self.new_find_element(
                    By.ID,
                    self.ELEMENT["btn_restore_node"]).get_attribute("enabled"),
                "false",
                "===失败-查关系更多操作-撤销删减操作===",
            )
            self.new_find_element(By.XPATH,
                                  self.ELEMENT["relation_point_text"]).click()
            # 断言-删减节点,撤销按钮可点
            self.assertEqual(
                self.new_find_element(
                    By.ID,
                    self.ELEMENT["btn_restore_node"]).get_attribute("enabled"),
                "true",
                "===失败-查关系更多操作-撤销删减操作===",
            )
            # 断言-被删减节点消失
            self.assertFalse(
                self.isElementExist(By.XPATH,
                                    self.ELEMENT["relation_point_text"]),
                "===失败-删减节点失败===",
            )
            self.new_find_element(By.ID,
                                  self.ELEMENT["btn_restore_node"]).click()
            # 断言-点击撤销按钮,被删减节点恢复
            self.assertTrue(
                self.isElementExist(By.XPATH,
                                    self.ELEMENT["relation_point_text"]),
                "===失败-撤销删减查关系节点===",
            )
            # 断言-取消删减按钮,回到关系图页,节点仍存在
            self.new_find_element(By.XPATH,
                                  self.ELEMENT["relation_point_text"]).click()
            self.new_find_element(By.ID, self.ELEMENT["btn_cancle"]).click()
            self.assertTrue(
                self.isElementExist(By.XPATH,
                                    self.ELEMENT["relation_point_text"]),
                "===失败-撤销删减查关系节点===",
            )
            # 断言-确定删减按钮,回到关系图,节点消失
            self.new_find_element(By.ID,
                                  self.ELEMENT["more_operation_btn"]).click()
            self.new_find_element(By.ID, self.ELEMENT["map_more_edit"]).click()
            self.new_find_element(By.XPATH,
                                  self.ELEMENT["relation_point_text"]).click()
            self.new_find_element(By.ID, self.ELEMENT["btn_save"]).click()
            self.assertFalse(
                self.isElementExist(By.XPATH,
                                    self.ELEMENT["relation_point_text"]),
                "===失败-删减节点失败===",
            )
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception

    @getimage
    def test_003_cgx_sszjy_p0(self):
        """查关系-搜索中间页,历史搜索"""
        log.info(self.test_003_cgx_sszjy_p0.__doc__)
        keyWord = None
        keyList = [
            "测试1",
            "测试2",
            "测试3",
            "测试4",
            "测试5",
            "测试6",
            "测试7",
            "测试8",
            "测试9",
            "测试10",
            "测试11",
        ]
        try:
            self.into_middle_page()
            self.new_find_element(By.ID,
                                  self.ELEMENT["from_input_textview"]).click()
            for i in range(len(keyList)):
                keyNum = random.randint(1, len(keyList))
                keyWord = keyList[keyNum - 1]
                self.new_find_element(
                    By.ID,
                    self.ELEMENT["search_input_edit"]).send_keys(keyWord)
                self.adb_send_input(By.ID, self.ELEMENT["search_input_edit"],
                                    keyWord, self.device)
                self.new_find_element(By.ID,
                                      self.ELEMENT["search_clean_iv"]).click()
            # 断言-点击热搜词后,生成搜索历史
            self.assertTrue(
                self.isElementExist(By.ID,
                                    self.ELEMENT["middlepage_search_history"]),
                "===失败-无最近搜索===",
            )
            self.assertFalse(
                self.isElementExist(By.XPATH,
                                    self.ELEMENT["middlepage_hot_search"]),
                "===失败-未展示一键清除按钮===",
            )
            self.assertEqual(
                self.new_find_element(
                    By.XPATH, self.ELEMENT["first_search_history"]).text,
                keyWord,
                "===失败-最近搜索词未展示在搜索历史第一位===",
            )
            # 断言-一键清空历史记录-取消清空
            self.new_find_element(
                By.ID,
                self.ELEMENT["middlepage_search_history_delete"]).click()
            self.assertTrue(
                self.isElementExist(By.ID, self.ELEMENT["delte_cancel"]),
                "===失败-二次确认弹窗未弹出===",
            )
            self.new_find_element(By.ID, self.ELEMENT["delte_cancel"]).click()
            self.assertFalse(
                self.isElementExist(By.ID, self.ELEMENT["delete_confirm"]),
                "===失败-二次确认弹窗未关闭===",
            )
            self.assertTrue(
                self.isElementExist(By.ID,
                                    self.ELEMENT["middlepage_search_history"]),
                "===失败-取消后,搜索历史未展示===",
            )
            # 断言-一键清空历史记录-确定清空
            self.new_find_element(
                By.ID,
                self.ELEMENT["middlepage_search_history_delete"]).click()
            self.new_find_element(By.ID,
                                  self.ELEMENT["delete_confirm"]).click()
            self.assertTrue(
                self.isElementExist(By.XPATH,
                                    self.ELEMENT["middlepage_hot_search"]),
                "===失败-搜索记录未清空===",
            )
            self.assertFalse(
                self.isElementExist(
                    By.ID, self.ELEMENT["middlepage_search_history_delete"]),
                "===失败-一键删除按钮未隐藏===",
            )
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception
class Search_company_sift_vip(MyTest, Operation):
    """查公司_高级筛选_02"""

    a = Read_Ex()
    ELEMENT = a.read_excel("test_search_company_sift")
    account = Account()
    phone_vip = account.get_account("vip")

    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        cls.sift_opera = SiftOperation(cls.driver, cls.ELEMENT)
        cls.sift_opera.login_vip(cls.phone_vip, cls.account.get_pwd())

    @classmethod
    def tearDownClass(cls):
        cls.account.release_account(cls.phone_vip, 'vip')
        super().tearDownClass()

    def get_company_sjhm(self, selectText, selectTarget, index=None):
        """
        获取公司:手机号码并断言
        :param selectText: 更多筛选-筛选项
        :param selectTarget: 选中条件
        :param index: 选中项索引
        """

        phone_list = []
        tempNum = 0
        result = None
        company_name = self.sift_opera.click2company(selectText, selectTarget)
        if not self.isElementExist(By.ID, self.ELEMENT['tv_base_info_phone']):
            # 无手机号码/无联系电话,不展示基本信息「电话按钮」
            # tag = str(index) is "2"
            # self.assertTrue(tag, "===「无手机/联系号码」断言失败-公司基本信息「有」手机/联系号码===")
            result = index == 2
        else:
            phone_tag = self.driver.find_element_by_id(self.ELEMENT["tv_base_info_phone"]).get_attribute("enabled")
            if "true" == phone_tag:
                self.driver.find_element_by_id(self.ELEMENT["tv_base_info_phone"]).click()
                phones = self.new_find_elements(By.XPATH, self.ELEMENT["ll_msg"])
                for i in range(len(phones)):
                    phone_xpath = "{}[{}]{}".format(self.ELEMENT["ll_msg"], str(i + 1),
                                                    '//*[@resource-id="com.tianyancha.skyeye:id/tv_phn"]')
                    phone_list.append(self.new_find_element(By.XPATH, phone_xpath).text)
                log.info(phone_list)
                for i in range(len(phone_list)):
                    if not re.match(r"^1[35678]\d{9}$", phone_list[i]):
                        tempNum += 1
                if index == 1:
                    phone_tag = len(phone_list) != tempNum
                    # self.assertTrue(phone_tag, "===「有手机号码」断言失败-号码列表中「无」手机号码===")
                    result = phone_tag
                else:
                    if self.isElementExist(By.ID, "com.tianyancha.skyeye:id/tv_score_tip"):
                        tag = self.new_find_element(By.ID, "com.tianyancha.skyeye:id/tv_score_tip").text
                        if "认证" in tag:
                            phone_tag = len(phone_list) == tempNum
                            # self.assertTrue(phone_tag, "===「无手机号码」断言失败-号码列表中「有」手机号码===")
                            result = phone_tag
                        elif "年审" in tag:
                            if len(phone_list) == tempNum:
                                # log.info("===该企业处在「认证待年审状态」,【无】手机/联系电话===")
                                result = "===该企业:「{}」处在「认证待年审状态」,【无】手机/联系电话===".format(company_name)
                            else:
                                # log.info("===该企业处在「认证待年审状态」,【有】手机/联系电话===")
                                result = "===该企业:「{}」处在「认证待年审状态」,【有】手机/联系电话===".format(company_name)
                        else:
                            result = "非「认证」「年审」企业:{}".format(company_name)
                    else:
                        if len(phone_list) == tempNum:
                            # log.info("===该企业处在「已认证状态」,【无】手机/联系电话===")
                            result = "===该企业:「{}」处在「已认证状态」,【无】手机/联系电话===".format(company_name)
                        else:
                            # log.info("===该企业处在「已认证状态」,【有】手机/联系电话===")
                            result = "===该企业:「{}」处在「已认证状态」,【有】手机/联系电话===".format(company_name)
                self.new_find_element(By.ID, "com.tianyancha.skyeye:id/iv_close").click()
            else:
                if index == 1:
                    # self.assertTrue(False, "===「有手机号码」断言失败-公司基本信息「无」手机号码===")
                    result = False
                else:
                    result = True
        self.sift_opera.back2company_search()
        self.sift_opera.reset(selectTarget)
        return result

    @getimage
    def test_001_cgs_gjsx_sjhm_p0(self):
        """查公司-搜索中间页,高级筛选:手机号码"""
        log.info(self.test_001_cgs_gjsx_sjhm_p0.__doc__)
        try:
            self.sift_opera.search_key(1)
            num_sjhm = random.randint(1, 2)
            selectTarget, selectText = self.sift_opera.get_key("more_sjhm_title", "more_sjhm", num_sjhm)
            result = self.get_company_sjhm(selectText, selectTarget, num_sjhm)
            log.info("===result===")
            if isinstance(result, type("返回值类型为str")):
                log.info(result)
            else:
                self.assertTrue(result, "===「有手机号码」断言失败-公司基本信息「无」手机号码===")
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception

    @getimage
    def test_002_cgs_gjsx_zlxx_p0(self):
        """查公司-搜索中间页,高级筛选:专利信息"""
        log.info(self.test_002_cgs_gjsx_zlxx_p0.__doc__)
        try:
            self.sift_opera.search_key(1)
            num_zlxx = random.randint(1, 2)
            selectTarget, selectText = self.sift_opera.get_key("more_zlxx_title", "more_zlxx", num_zlxx)
            result = self.sift_opera.detail4company(selectText, "专利信息", selectTarget, num_zlxx)
            if num_zlxx == 1:
                # 断言-有专利信息
                self.assertTrue(result, "===失败-高级筛选:「{}」错误===".format(selectText))
            else:
                # 断言-无专利信息
                self.assertFalse(result, "===失败-高级筛选:「{}」错误===".format(selectText))
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception
class Search_relation_sift_vip(MyTest, Operation):
    """查关系_高级筛选_04"""

    a = Read_Ex()
    ELEMENT = a.read_excel("Search_relation")
    account = Account()
    phone_vip = account.get_account("vip")

    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        cls.sift_opera = SiftOperation(cls.driver, cls.ELEMENT)
        cls.sift_opera.login_vip(cls.phone_vip, cls.account.get_pwd())

    @classmethod
    def tearDownClass(cls):
        cls.account.release_account(cls.phone_vip, 'vip')
        super().tearDownClass()

    def get_company_sszt(self, selectTarget, inputTarget, index=None):
        """
        获取公司:上市状态并断言
        :param selectTarget: 选中条件
        :param inputTarget: 输入内容
        :param index: 选中项索引
        """
        result = None
        selectText = self.sift_opera.point2company(selectTarget)
        firm_name = self.new_find_element(By.ID, self.ELEMENT["firm_detail_name_tv"]).text
        log.info("高级筛选:{},断言公司名称:{}".format(selectText, firm_name))
        if index == 1:
            for i in range(10):
                if self.isElementExist(By.ID, self.ELEMENT["stock_title_tv"]):
                    stock_info = self.new_find_element(By.ID, self.ELEMENT["stock_title_tv"]).text
                    log.info("股票信息:{}".format(stock_info))
                    stock_title = self.isElementExist(By.ID, self.ELEMENT["stock_title_tv"])
                    result = stock_title
                    break
                else:
                    self.swipeUp(x1=0.5, y1=0.7, y2=0.3, t=2000)
                    if i == 29:
                        stock_title = self.isElementExist(By.ID, self.ELEMENT["stock_title_tv"])
                        result = stock_title
        else:
            for i in range(10):
                if self.isElementExist(By.XPATH, self.ELEMENT["company_background"]):
                    atlas = self.new_find_element(By.XPATH, self.ELEMENT["background_to_atlas"]).text
                    result = "天眼图谱" is atlas
                    break
                else:
                    self.swipeUp(x1=0.5, y1=0.7, y2=0.3, t=2000)
                    if i == 29:
                        company_backgrand = self.isElementExist(By.ID, self.ELEMENT["company_background"])
                        result = company_backgrand
        self.sift_opera.back2relation_search(inputTarget)
        return result

    def get_company_500(self, selectTarget, inputTarget, index=None):
        """
        获取公司:500强企业断言
        :param selectTarget: 选中条件
        :param inputTarget: 输入内容
        :param index: 选中项索引
        """
        selectText = self.sift_opera.point2company(selectTarget)
        company_name = self.new_find_element(By.ID, self.ELEMENT["firm_detail_name_tv"]).text
        log.info("高级筛选:{},断言公司名称:{}".format(selectText, company_name))
        current_dir = os.path.abspath(os.path.dirname(__file__))
        json_dir = os.path.dirname(current_dir) + "/../Data/500.json"
        with open(json_dir, "r") as json_file:
            data = json.load(json_file)
        self.sift_opera.back2relation_search(inputTarget)
        return company_name, data[str(index)]

    @getimage
    def test_001_cgx_gjsx_sszt_p0(self):
        """查关系-搜索中间页,高级筛选:上市状态"""
        log.info(self.test_001_cgx_gjsx_sszt_p0.__doc__)
        try:
            inputTarget = self.sift_opera.search_key(2)
            num_sszt = random.randint(1, 2)
            selectTarget, selectText = self.sift_opera.get_key("more_sszt_title", "more_sszt", num_sszt)
            result = self.get_company_sszt(selectTarget, inputTarget, num_sszt)
            self.assertTrue(result)
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception

    @getimage
    def test_002_cgx_gjsx_500_p0(self):
        """查关系-搜索中间页,高级筛选:500强"""
        log.info(self.test_002_cgx_gjsx_500_p0.__doc__)
        try:
            inputTarget = self.sift_opera.search_key(2)
            num_500 = random.randint(1, 2)
            selectTarget, selectText = self.sift_opera.get_key("more_500_title", "more_500", num_500)
            company, data = self.get_company_500(selectTarget, inputTarget, num_500)
            self.assertIn(company, data, "===失败-「{}」,断言失败===".format(selectText))
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception
Exemple #23
0
class Company_detail_baseinfo(MyTest, Operation):
    """公司详情页_股东/高管"""

    a = Read_Ex()
    ELEMENT = a.read_excel("company_detail_xu")
    account = Account()
    phone_vip = account.get_account("vip")

    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        cls.sift_opera = SiftOperation(cls.driver, cls.ELEMENT)

    @classmethod
    def tearDownClass(cls):
        cls.account.release_account(cls.phone_vip, 'vip')
        super().tearDownClass()

    def detail_opera(self, *opera, num=1, tag=1):
        self.new_find_element(*opera).click()
        if tag == 1:
            result = self.isElementExist(By.ID, self.ELEMENT["btv_title"])
        else:
            result = self.new_find_element(By.ID,
                                           self.ELEMENT["app_title_name"]).text
        if num == 0:
            result = self.isElementExist(By.ID,
                                         self.ELEMENT["radio_person_detail"])
        elif num == 2:
            result = self.isElementExist(By.ID,
                                         self.ELEMENT["radio_firm_detail"])
        self.driver.keyevent(4)
        if num == 0:
            self.new_find_element(By.ID, self.ELEMENT["iv_score"]).click()
        return result

    def test_001_gsxx_jcxx_p0(self):
        """公司基本信息,未登录态校验"""
        log.info(self.test_001_gsxx_jcxx_p0.__doc__)
        try:
            self.sift_opera.into_company(company="万科企业股份有限公司")
            self.new_find_element(By.ID, self.ELEMENT["tv_des"]).click()
            self.new_find_element(By.ID, self.ELEMENT["tv_des"]).click()

            result = self.detail_opera(By.ID,
                                       self.ELEMENT["tv_des_sub_value_1"])
            self.assertTrue(result, "===法定代表人,未登录限制失败===")

            result = self.detail_opera(By.XPATH,
                                       self.ELEMENT["rv_riskinfo_item1"])
            self.assertTrue(result, "===天眼风险-自身风险,未登录限制失败===")

            result = self.detail_opera(By.XPATH,
                                       self.ELEMENT["rv_riskinfo_item2"])
            self.assertTrue(result, "===天眼风险-周边风险,未登录限制失败===")

            result = self.detail_opera(By.XPATH,
                                       self.ELEMENT["rv_riskinfo_item3"])
            self.assertTrue(result, "===天眼风险-预警信息,未登录限制失败===")

            result = self.detail_opera(By.ID,
                                       self.ELEMENT["tv_base_info_phone"])
            self.assertTrue(result, "===电话,未登录限制失败===")

            result = self.detail_opera(By.ID,
                                       self.ELEMENT["tv_base_info_address"],
                                       tag=0)
            self.assertEqual("公司地图", result, "===点击「地址」,跳转地图页失败===")

            self.driver.keyevent(4)
            self.new_find_element(
                By.ID,
                self.ELEMENT["search_input_edit"]).send_keys("上海彩亿信息技术有限公司")
            self.new_find_element(
                By.XPATH,
                '//*[@class="android.widget.TextView" and @text="上海彩亿信息技术有限公司"]'
            ).click()

            result = self.detail_opera(By.XPATH,
                                       self.ELEMENT["tv_shareholder_1"])
            self.assertTrue(result, "===自然人股东,未登录限制失败===")

            result = self.detail_opera(By.XPATH, self.ELEMENT["tv_staff_1"])
            self.assertTrue(result, "===自然人股东,未登录限制失败===")

            result = self.detail_opera(By.ID,
                                       self.ELEMENT["tv_shareholder_count"],
                                       tag=0)
            self.assertEqual("股东信息", result, "===失败-非上市公司,点击「股东」未进入「股东信息页」===")

            result = self.detail_opera(By.ID,
                                       self.ELEMENT["tv_staff_count"],
                                       tag=0)
            self.assertEqual("主要人员", result, "===失败-非上市公司,点击「高管」未进入「主要人员页」===")

        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))

    def test_002_gsxx_jcxx_p0(self):
        """公司详情页,登陆vip账号"""
        log.info(self.test_002_gsxx_jcxx_p0.__doc__)
        try:
            self.sift_opera.login_vip(self.phone_vip, self.account.get_pwd())
            self.sift_opera.into_company(company="万科企业股份有限公司")

            result = self.detail_opera(By.ID,
                                       self.ELEMENT["tv_des_sub_value_1"],
                                       num=0)
            self.assertTrue(result, "===登陆态,跳转「法定代表人」详情页失败===")

            result = self.detail_opera(By.ID, self.ELEMENT["tv_claim"], tag=0)
            self.assertEqual("选择认证套餐", result, "===评分弹出,认证入口,跳转失败===")

            self.new_find_element(By.ID,
                                  self.ELEMENT["tv_base_info_phone"]).click()
            delte_cancel = self.new_find_element(
                By.ID, self.ELEMENT["delte_cancel"]).text
            self.assertEqual("修改电话", delte_cancel, "===电话弹窗,弹出失败===")

            result = self.detail_opera(By.ID,
                                       self.ELEMENT["delte_cancel"],
                                       tag=0)
            self.assertEqual("选择认证套餐", result, "===电话弹窗,修改电话,跳转失败===")

            result = self.detail_opera(By.ID,
                                       self.ELEMENT["iv_claim_label"],
                                       tag=0)
            self.assertEqual("选择认证套餐", result, "===登录态点击「我要认证」标签,跳转失败===")
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))

    def test_003_gsxx_gd_p0(self):
        """公司详情页,股东/高管"""
        log.info(self.test_003_gsxx_gd_p0.__doc__)
        try:
            self.sift_opera.into_company(company="万科企业股份有限公司")
            # 股东
            holder = self.isElementExist(By.ID, self.ELEMENT["holder_type_iv"])
            self.assertTrue(holder, "===大股东标签缺失===")

            result = self.detail_opera(By.ID,
                                       self.ELEMENT["tv_shareholder_count"],
                                       tag=0)
            self.assertEqual("十大股东", result, "===失败-上市公司,点击「股东」未进入「十大股东页」===")

            result = self.detail_opera(By.XPATH,
                                       self.ELEMENT["tv_shareholder_1"],
                                       num=2)
            self.assertTrue(result, "===非自然人股东,跳转详情页错误===")

            # 高管
            result = self.detail_opera(By.ID,
                                       self.ELEMENT["tv_staff_count"],
                                       tag=0)
            self.assertEqual("高管信息", result, "===失败-上市公司,点击「高管」未进入「高管信息页」===")

        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
class Company_detail_baseinfo(MyTest, Operation):
    """公司详情页_基本信息"""

    a = Read_Ex()
    ELEMENT = a.read_excel("company_detail_xu")
    account = Account()
    phone_vip = account.get_account("vip")

    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        cls.sift_opera = SiftOperation(cls.driver, cls.ELEMENT)

    @classmethod
    def tearDownClass(cls):
        cls.account.release_account(cls.phone_vip, 'vip')
        super().tearDownClass()

    @getimage
    def test_gsxx_jcxx_001_p0(self):
        """企业状态标签"""
        log.info(self.test_gsxx_jcxx_001_p0.__doc__)
        company_name = self.sift_opera.into_company()
        tag = self.new_find_element(By.XPATH, self.ELEMENT["tag_firm_1"])
        tag_text = tag.text
        log.info("===企业状态:「{}」===".format(tag_text))
        tag.click()
        txt_msg = self.new_find_element(By.ID, self.ELEMENT["txt_msg"]).text
        self.assertIn(msg[tag_text], txt_msg,
                      "==={},标签错误「{}」===".format(company_name, tag_text))
        self.new_find_element(By.ID, self.ELEMENT["delete_confirm"]).click()

    @getimage
    def test_gsxx_jcxx_002_p0(self):
        """发票抬头标签"""
        log.info(self.test_gsxx_jcxx_002_p0.__doc__)
        company_name = self.sift_opera.into_company()
        self.new_find_element(By.XPATH, self.ELEMENT["bill_title"]).click()
        title = self.new_find_element(By.ID, self.ELEMENT["txt_title"]).text
        self.assertEqual("发票抬头", title, "===失败-「发票抬头」弹窗===")
        name = self.new_find_element(By.ID, self.ELEMENT["txt_name"]).text
        tax = self.new_find_element(By.ID, self.ELEMENT["txt_tax"]).text
        tax_check = UnifiedSocialCreditIdentifier()
        if tax != "-":
            tax_check.check_tax_code(tax)
        phone = self.new_find_element(By.ID, self.ELEMENT["txt_phone"]).text
        address = self.new_find_element(By.ID,
                                        self.ELEMENT["txt_address"]).text
        log.info("发票抬头信息:「名称:{}」「税号:{}」「电话:{}」「地址:{}」".format(
            name, tax, phone, address))
        self.new_find_element(By.ID, self.ELEMENT["delte_cancel"]).click()
        self.assertFalse(self.isElementExist(By.ID, self.ELEMENT["txt_title"]))
        self.new_find_element(By.XPATH, self.ELEMENT["bill_title"]).click()
        self.new_find_element(By.ID, self.ELEMENT["delete_confirm"]).click()
        bottom2 = self.isElementExist(By.ID, self.ELEMENT["login_bottom2"])
        self.assertTrue(bottom2, "===保存发票,登陆校验失败===")
        self.new_find_element(By.XPATH, self.ELEMENT["passwd_login"]).click()
        self.new_find_element(By.ID, self.ELEMENT["et_phone"]).send_keys(
            self.phone_vip)
        self.new_find_element(By.ID, self.ELEMENT["input_password"]).send_keys(
            self.account.get_pwd())
        # 判断隐私弹窗是否勾选
        a = self.new_find_element(
            By.ID, self.ELEMENT["cb_login_check"]).get_attribute("checked")
        if a != "true":
            self.new_find_element(By.ID,
                                  self.ELEMENT["cb_login_check"]).click()
        self.new_find_element(By.ID, self.ELEMENT["tv_login"]).click()
        # 判断日报弹窗
        if self.new_find_element(By.XPATH, self.ELEMENT["monitor_pop"]):
            self.new_find_element(By.ID, self.ELEMENT["btn_finish"]).click()
        self.new_find_element(By.XPATH, self.ELEMENT["bill_title"]).click()
        self.new_find_element(By.ID, self.ELEMENT["delete_confirm"]).click()
        for i in range(10):
            if self.isElementExist(By.ID, self.ELEMENT["tab_iv_5"]):
                self.new_find_element(By.ID, self.ELEMENT["tab_iv_5"]).click()
                break
            else:
                self.driver.keyevent(4)
        self.new_find_element(By.XPATH, self.ELEMENT["bill_title"]).click()
        bill_title = self.new_find_element(
            By.XPATH, self.ELEMENT["bill_title_list_1"]).text
        self.assertEqual(company_name, bill_title)

    @getimage
    def test_gsxx_jcxx_003_p0(self):
        """融资轮次标签"""
        log.info(self.test_gsxx_jcxx_003_p0.__doc__)
        self.sift_opera.login_vip(self.phone_vip, self.account.get_pwd())
        self.new_find_element(By.ID, self.ELEMENT["search_company"]).click()
        self.new_find_element(By.ID, self.ELEMENT["search_box"]).click()
        self.new_find_element(
            By.ID, self.ELEMENT["search_input_edit"]).send_keys("北京百度网讯科技有限公司")
        self.new_find_element(By.XPATH, self.ELEMENT['company_rzlc']).click()
        if self.new_find_element(By.XPATH,
                                 self.ELEMENT["tag_firm_2"]).text == "发票抬头":
            round_tag = self.new_find_element(By.XPATH,
                                              self.ELEMENT["tag_firm_3"]).text
            self.new_find_element(By.XPATH, self.ELEMENT["tag_firm_3"]).click()
            round_name = self.new_find_element(By.ID,
                                               self.ELEMENT["txt_round"]).text
            round_date = self.new_find_element(By.ID,
                                               self.ELEMENT["txt_date"]).text
            round_money = self.new_find_element(By.ID,
                                                self.ELEMENT["txt_money"]).text
            round_valuation = self.new_find_element(
                By.ID, self.ELEMENT["txt_valuation"]).text
            self.assertEqual(round_tag, round_name, "===当前融资轮次错误===")
            self.new_find_element(By.ID,
                                  self.ELEMENT["delete_confirm"]).click()

            for i in range(20):
                if self.isElementExist(
                        By.XPATH,
                        '//*[@class="android.widget.TextView" and @text="融资历程"]'
                ):
                    self.new_find_element(
                        By.XPATH,
                        '//*[@class="android.widget.TextView" and @text="融资历程"]'
                    ).click()
                    round_ = self.new_find_element(
                        By.XPATH, self.ELEMENT["detail_txt_round"]).text
                    date_ = self.new_find_element(
                        By.XPATH, self.ELEMENT["detail_txt_date"]).text
                    money_ = self.new_find_element(
                        By.XPATH, self.ELEMENT["detail_txt_money"]).text
                    valuation_ = self.new_find_element(
                        By.XPATH, self.ELEMENT["detail_txt_valuation"]).text
                    self.assertEqual(round_name, round_)
                    self.assertEqual(round_date, date_)
                    self.assertIn(round_money, money_)
                    self.assertIn(round_valuation, valuation_)
                    break
                else:
                    self.swipeUp(0.5, 0.85, 0.15, 2500)

    @getimage
    def test_gsxx_jcxx_004_p0(self):
        """高新技术企业标签"""
        log.info(self.test_gsxx_jcxx_004_p0.__doc__)
        try:
            self.sift_opera.into_company(company="北京金堤科技有限公司")
            # 对logo进行校验
            portrait = self.isElementExist(By.XPATH,
                                           self.ELEMENT["iv_portrait_img"])
            self.assertTrue(portrait, "===公司logo未展示===")
            self.new_find_element(By.XPATH,
                                  self.ELEMENT["iv_portrait_img"]).click()
            logo = self.isElementExist(By.ID,
                                       self.ELEMENT["preview_photo_root"])
            self.assertTrue(logo, "===点击logo,放大查看失败===")
            if logo:
                self.driver.keyevent(4)
            self.new_find_element(By.XPATH, self.ELEMENT["tag_firm_4"]).click()
            txt_msg = self.new_find_element(By.ID,
                                            self.ELEMENT["txt_msg"]).text
            self.assertIn("高新技术企业", txt_msg, "===「高新技术企业」标签,弹窗文案错误==")
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception

    @getimage
    def test_gsxx_jcxx_005_p0(self):
        """小微企业标签"""
        log.info(self.test_gsxx_jcxx_005_p0.__doc__)
        try:
            self.sift_opera.into_company(company="盐城金堤科技有限公司")
            self.new_find_element(By.XPATH, self.ELEMENT["tag_firm_3"]).click()
            txt_msg = self.new_find_element(By.ID,
                                            self.ELEMENT["txt_msg"]).text
            self.assertIn("小型微型企业", txt_msg, "===「小微企业」标签,弹窗文案错误==")
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception

    @getimage
    def test_gsxx_jcxx_006_p0(self):
        """公司logo"""
        log.info(self.test_gsxx_jcxx_006_p0.__doc__)
        try:
            self.sift_opera.into_company(company="阜新高新技术建设开发有限责任公司")
            portrait = self.new_find_element(
                By.XPATH, self.ELEMENT["iv_portrait_text"]).text
            self.assertEqual("高新\n技术", portrait, "===无公司logo,展示4个字文案失败===")
            while True:
                if self.isElementExist(By.ID,
                                       self.ELEMENT["search_input_edit"]):
                    self.new_find_element(
                        By.ID, self.ELEMENT["search_input_edit"]).send_keys(
                            "贵安新区东旗高新技术有限公司")
                    self.new_find_element(
                        By.XPATH,
                        '//*[@class="android.widget.TextView" and @text="贵安新区东旗高新技术有限公司"]'
                    ).click()
                    iv_portrait = self.new_find_element(
                        By.XPATH, self.ELEMENT["iv_portrait_text"]).text
                    self.assertEqual("东旗", iv_portrait,
                                     "===无公司logo,展示2个字文案失败===")
                    break
                else:
                    self.driver.keyevent(4)
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception
Exemple #25
0
class Company_detail_baseinfo(MyTest, Operation):
    """公司详情页_天眼风险"""

    a = Read_Ex()
    ELEMENT = a.read_excel("company_detail_xu")
    account = Account()
    account.init_account()
    phone_vip = account.get_account("vip")
    contents = []

    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        cls.sift_opera = SiftOperation(cls.driver, cls.ELEMENT)

    @classmethod
    def tearDownClass(cls):
        cls.account.release_account(cls.phone_vip, 'vip')
        super().tearDownClass()

    def get_content(self, risk_detail_list, number):
        self.contents = []
        if risk_detail_list == 1:
            risk_detail_list = 2
        for i in range(number):
            content = self.new_find_element(
                By.XPATH, self.ELEMENT['riskinfo_item_detail_list'] + '[' +
                str(risk_detail_list - 1) +
                ']//*[@resource-id="com.tianyancha.skyeye:id/tv_item_content' +
                str(i + 1) + '"]').text
            self.contents.append(content)

    def riskinfo_detail_list(self, dimension, tag=None, swip=None):
        ele_risk_item1 = '//*[@class="android.widget.TextView" and @text="' + \
            dimension + '"]/../../following-sibling::android.widget.LinearLayout[1]'
        while True:
            if self.isElementExist(By.XPATH, ele_risk_item1):
                self.new_find_element(By.XPATH, ele_risk_item1).click()
                if tag == 1:
                    for i in range(random.randint(1, 3)):
                        self.swipeUp()
                    risk_detail_list = len(
                        self.new_find_elements(
                            By.XPATH,
                            self.ELEMENT['riskinfo_item_detail_list']))
                    return risk_detail_list
                break
            else:
                if swip == "down":
                    self.swipeDown(0.5, 0.3, 0.7, t=2000)
                else:
                    self.swipeUp(0.5, 0.7, 0.3, t=2000)

    @getimage
    def test_001_gsxx_tyfx_p0(self):
        """公司基本信息-天眼风险,登录态校验"""
        log.info(self.test_001_gsxx_tyfx_p0.__doc__)
        try:
            self.sift_opera.login_vip(self.phone_vip, self.account.get_pwd())
            self.sift_opera.into_company(company="乐视控股(北京)有限公司")
            self.new_find_element(By.XPATH,
                                  self.ELEMENT['rv_riskinfo_item1']).click()
            self.assertEqual(
                "乐视控股(北京)有限公司",
                self.new_find_element(By.ID,
                                      self.ELEMENT['tv_companyname']).text,
                "===天眼风险详情页,关联公司名称错误===")

            log.info("天眼风险-失信被执行人")
            risk_detail_list = self.riskinfo_detail_list("失信被执行人", 1)
            self.get_content(risk_detail_list, 5)
            self.new_find_element(
                By.XPATH, self.ELEMENT['riskinfo_item_detail_list'] + '[' +
                str(risk_detail_list - 1) +
                ']/android.widget.ImageView').click()
            self.swipeUp(0.5, 0.55, 0.45, t=500)
            detail_gistid = self.new_find_element(
                By.ID, self.ELEMENT['dishonest_detail_gistid_tv']).text
            detail_courtname = self.new_find_element(
                By.ID, self.ELEMENT['dishonest_detail_courtname_tv']).text
            detail_performance = self.new_find_element(
                By.ID, self.ELEMENT['dishonest_detail_performance_tv']).text
            detail_regdate = self.new_find_element(
                By.ID, self.ELEMENT['dishonest_detail_regdate_tv']).text
            detail_publishdate = self.new_find_element(
                By.ID, self.ELEMENT['dishonest_detail_publishdate_tv']).text
            self.assertEqual(self.contents[0], detail_gistid,
                             "===天眼风险,失信被执行人,详情页「案号」错误===")
            self.assertEqual(self.contents[1], detail_courtname,
                             "===天眼风险,失信被执行人,详情页「执行法院」错误===")
            self.assertEqual(self.contents[2], detail_performance,
                             "===天眼风险,失信被执行人,详情页「履行情况」错误===")
            self.assertEqual(self.contents[3], detail_regdate,
                             "===天眼风险,失信被执行人,详情页「立案日期」错误===")
            self.assertEqual(self.contents[4], detail_publishdate,
                             "===天眼风险,失信被执行人,详情页「发布日期」错误===")
            while not self.isElementExist(By.ID,
                                          self.ELEMENT['tv_companyname']):
                self.driver.keyevent(4)

            log.info("天眼风险-限制消费令")
            risk_detail_list = self.riskinfo_detail_list("限制消费令", 1)
            self.new_find_element(
                By.XPATH, self.ELEMENT['riskinfo_item_detail_list'] + '[' +
                str(risk_detail_list - 1) +
                ']/android.widget.ImageView').click()
            # todo pdf页校验
            while not self.isElementExist(By.ID,
                                          self.ELEMENT['tv_companyname']):
                self.driver.keyevent(4)

            log.info("天眼风险-被执行人")
            risk_detail_list = self.riskinfo_detail_list("被执行人", 1)
            self.get_content(risk_detail_list, 4)
            self.new_find_element(
                By.XPATH, self.ELEMENT['riskinfo_item_detail_list'] + '[' +
                str(risk_detail_list - 1) +
                ']/android.widget.ImageView').click()
            casecode = self.new_find_element(
                By.ID, self.ELEMENT['tv_executed_person_detial_casecode']).text
            court_name = self.new_find_element(
                By.ID,
                self.ELEMENT['tv_executed_person_detial_exec_court_name']).text
            money = self.new_find_element(
                By.ID,
                self.ELEMENT['tv_executed_person_detial_exec_money']).text
            create_time = self.new_find_element(
                By.ID,
                self.ELEMENT['executed_person_detial_case_create_time']).text
            self.assertEqual(self.contents[0], casecode,
                             "===天眼风险,被执行人,详情页「案号」错误===")
            self.assertEqual(self.contents[1], court_name,
                             "===天眼风险,被执行人,详情页「执行法院」错误===")
            self.assertEqual(self.contents[2], money,
                             "===天眼风险,被执行人,详情页「执行标的」错误===")
            self.assertEqual(self.contents[3], create_time,
                             "===天眼风险,被执行人,详情页「立案日期」错误===")
            while not self.isElementExist(By.ID,
                                          self.ELEMENT['tv_companyname']):
                self.driver.keyevent(4)

            log.info("天眼风险-终本案件")
            risk_detail_list = self.riskinfo_detail_list("终本案件", 1)
            self.get_content(risk_detail_list, 3)
            self.new_find_element(
                By.XPATH, self.ELEMENT['riskinfo_item_detail_list'] + '[' +
                str(risk_detail_list - 1) +
                ']/android.widget.ImageView').click()
            tv_name = self.new_find_element(By.ID,
                                            self.ELEMENT['tv_name']).text
            tv_case_code = self.new_find_element(
                By.ID, self.ELEMENT['tv_case_code']).text
            tv_create_date = self.new_find_element(
                By.ID, self.ELEMENT['tv_create_date']).text
            self.assertEqual(self.contents[0], tv_name,
                             "===天眼风险,终本案件,详情页「姓名」错误===")
            self.assertEqual(self.contents[1], tv_case_code,
                             "===天眼风险,终本案件,详情页「案号」错误===")
            self.assertEqual(self.contents[2], tv_create_date,
                             "===天眼风险,终本案件,详情页「立案时间」错误===")
            # todo 终本案件,「关联失信被执行人」「关联被执行人」校验
            while not self.isElementExist(By.ID,
                                          self.ELEMENT['tv_companyname']):
                self.driver.keyevent(4)

            log.info("天眼风险-经营异常")
            self.riskinfo_detail_list("经营异常")
            self.assertEqual(
                "乐视控股(北京)有限公司",
                self.new_find_element(By.ID,
                                      self.ELEMENT['company_name_tv']).text)
            # todo 字段校验
            while not self.isElementExist(By.ID,
                                          self.ELEMENT['tv_companyname']):
                self.driver.keyevent(4)

            log.info("天眼风险-司法协助")
            risk_detail_list = self.riskinfo_detail_list("司法协助", 1)
            self.get_content(risk_detail_list, 4)
            self.new_find_element(
                By.XPATH, self.ELEMENT['riskinfo_item_detail_list'] + '[' +
                str(risk_detail_list - 1) +
                ']/android.widget.ImageView').click()
            if self.contents[3] == "股权冻结|失效":
                sfxz_detail_tv1 = self.new_find_element(
                    By.ID, self.ELEMENT['sfxz_detail_tv1']).text
                sfxz_detail_tv2 = self.new_find_element(
                    By.ID, self.ELEMENT['sfxz_detail_tv2']).text
                sfxz_detail_tv3 = self.new_find_element(
                    By.ID, self.ELEMENT['sfxz_detail_tv3']).text
                sfxz_detail_tv4 = self.new_find_element(
                    By.ID, self.ELEMENT['sfxz_detail_tv4']).text
                self.assertEqual(self.contents[0], sfxz_detail_tv2,
                                 "===天眼风险,司法协助,详情页「被执行人」错误===")
                self.assertEqual(self.contents[1], sfxz_detail_tv3,
                                 "===天眼风险,司法协助,详情页「股权数额」错误===")
                self.assertEqual(self.contents[2], sfxz_detail_tv1,
                                 "===天眼风险,司法协助,详情页「执行通知书文号」错误===")
                self.assertEqual(self.contents[3], sfxz_detail_tv4,
                                 "===天眼风险,司法协助,详情页「类型|状态」错误===")
            else:
                sfxz_detail_tv3 = self.new_find_element(
                    By.ID, self.ELEMENT['sfxz_detail_tv3']).text
                sfxz_detail_tv6 = self.new_find_element(
                    By.ID, self.ELEMENT['sfxz_detail_tv6']).text
                sfxz_detail_tv8 = self.new_find_element(
                    By.ID, self.ELEMENT['sfxz_detail_tv8']).text
                self.assertEqual(self.contents[0], sfxz_detail_tv6,
                                 "===天眼风险,司法协助,详情页「被执行人」错误===")
                self.assertEqual(self.contents[1], sfxz_detail_tv8,
                                 "===天眼风险,司法协助,详情页「股权数额」错误===")
                self.assertEqual(self.contents[2], sfxz_detail_tv3,
                                 "===天眼风险,司法协助,详情页「执行通知书文号」错误===")
            while not self.isElementExist(By.ID,
                                          self.ELEMENT['tv_companyname']):
                self.driver.keyevent(4)

            log.info("天眼风险-开庭公告")
            risk_detail_list = self.riskinfo_detail_list("开庭公告", 1)
            self.get_content(risk_detail_list, 4)
            ktgg_header = self.new_find_element(
                By.XPATH, self.ELEMENT['riskinfo_item_detail_list'] + '[' +
                str(risk_detail_list - 1) + ']' +
                self.ELEMENT['ktgg_list_header']).text
            self.new_find_element(
                By.XPATH, self.ELEMENT['riskinfo_item_detail_list'] + '[' +
                str(risk_detail_list - 1) +
                ']/android.widget.ImageView').click()
            ann_case_reason = self.new_find_element(
                By.ID, self.ELEMENT['ann_case_reason']).text
            ann_case_num = self.new_find_element(
                By.ID, self.ELEMENT['ann_case_num']).text
            ann_law_date = self.new_find_element(
                By.ID, self.ELEMENT['ann_law_date']).text
            self.assertEqual(ktgg_header, ann_case_reason,
                             "===天眼风险,开庭公告,详情页「案由」错误===")
            self.assertEqual(self.contents[0], ann_case_num,
                             "===天眼风险,开庭公告,详情页「案号」错误===")
            self.assertEqual(self.contents[3], ann_law_date,
                             "===天眼风险,开庭公告,详情页「开庭时间」错误===")
            while not self.isElementExist(By.ID,
                                          self.ELEMENT['tv_companyname']):
                self.driver.keyevent(4)

            log.info("天眼服务-法律诉讼")
            risk_detail_list = self.riskinfo_detail_list("法律诉讼", 1)
            self.get_content(risk_detail_list, 4)
            flss_header = self.new_find_element(
                By.XPATH, self.ELEMENT['riskinfo_item_detail_list'] + '[' +
                str(risk_detail_list - 1) + ']' +
                self.ELEMENT['ktgg_list_header']).text
            self.new_find_element(
                By.XPATH, self.ELEMENT['riskinfo_item_detail_list'] + '[' +
                str(risk_detail_list - 1) +
                ']/android.widget.ImageView').click()
            flss_detail = self.new_find_element(
                By.XPATH, self.ELEMENT['flss_detail']).text
            self.assertIn(flss_header, flss_detail,
                          "===天眼风险,法律诉讼,详情页「案件名称」错误===")
            while not self.isElementExist(By.ID,
                                          self.ELEMENT['tv_companyname']):
                self.driver.keyevent(4)

            log.info("天眼风险-司法拍卖")
            self.new_find_element(By.ID,
                                  self.ELEMENT['riskinfo_title_2']).click()
            risk_detail_list = self.riskinfo_detail_list("司法拍卖",
                                                         1,
                                                         swip="down")
            self.new_find_element(
                By.XPATH, self.ELEMENT['riskinfo_item_detail_list'] + '[' +
                str(risk_detail_list - 1) +
                ']/android.widget.ImageView').click()
            self.assertTrue(
                self.isElementExist(By.XPATH, self.ELEMENT['bid_sale_wv']),
                "===司法拍卖-Webview展示失败===")
            while not self.isElementExist(By.ID,
                                          self.ELEMENT['tv_companyname']):
                self.driver.keyevent(4)

            log.info("天眼风险-立案信息")
            risk_detail_list = self.riskinfo_detail_list("立案信息",
                                                         1,
                                                         swip="down")
            self.get_content(risk_detail_list, 2)
            self.new_find_element(
                By.XPATH, self.ELEMENT['riskinfo_item_detail_list'] + '[' +
                str(risk_detail_list - 1) +
                ']/android.widget.ImageView').click()
            tv_court_num = self.new_find_element(
                By.ID, self.ELEMENT['tv_court_num']).text
            tv_filing_date = self.new_find_element(
                By.ID, self.ELEMENT['tv_filing_date']).text
            self.assertEqual(self.contents[0], tv_court_num,
                             "===天眼风险,立案信息,详情页「案号」错误===")
            self.assertEqual(self.contents[1], tv_filing_date,
                             "===天眼风险,立案信息,详情页「立案日期」错误===")
            while not self.isElementExist(By.ID,
                                          self.ELEMENT['tv_companyname']):
                self.driver.keyevent(4)

            log.info("天眼风险-法院公告")
            risk_detail_list = self.riskinfo_detail_list("法院公告",
                                                         1,
                                                         swip="down")
            self.get_content(risk_detail_list, 4)
            self.new_find_element(
                By.XPATH, self.ELEMENT['riskinfo_item_detail_list'] + '[' +
                str(risk_detail_list - 1) +
                ']/android.widget.ImageView').click()
            tv_court_item_court = self.new_find_element(
                By.ID, self.ELEMENT['tv_court_item_court']).text
            tv_court_item_st = self.new_find_element(
                By.ID, self.ELEMENT['tv_court_item_st']).text
            tv_court_item_tm = self.new_find_element(
                By.ID, self.ELEMENT['tv_court_item_tm']).text
            self.assertEqual(self.contents[1], tv_court_item_court,
                             "===天眼风险,法院公告,详情页「公告人」错误===")
            self.assertEqual(self.contents[2], tv_court_item_st,
                             "===天眼风险,法院公告,详情页「公告类型」错误===")
            self.assertEqual(self.contents[3], tv_court_item_tm,
                             "===天眼风险,法院公告,详情页「刊登日期」错误===")
            court_sued_len = len(
                self.new_find_elements(By.XPATH,
                                       self.ELEMENT['ll_court_sued']))
            for i in range(court_sued_len):
                item = self.new_find_element(
                    By.XPATH, self.ELEMENT['ll_court_sued'] + '[' +
                    str(i + 1) + ']/android.widget.TextView').text
                self.assertIn(item, self.contents[0],
                              "===天眼风险,法院公告,详情页「当事人」错误===")

        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
class Search_company_sift_vip(MyTest, Operation):
    """查公司_高级筛选_05"""

    a = Read_Ex()
    ELEMENT = a.read_excel("test_search_company_sift")
    account = Account()
    phone_vip = account.get_account("vip")

    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        cls.sift_opera = SiftOperation(cls.driver, cls.ELEMENT)
        cls.sift_opera.login_vip(cls.phone_vip, cls.account.get_pwd())

    @classmethod
    def tearDownClass(cls):
        cls.account.release_account(cls.phone_vip, 'vip')
        super().tearDownClass()

    def get_company_sszt(self, selectTarget, index=None):
        """
        获取公司:上市状态并断言
        :param selectTarget: 选中条件
        :param index: 选中项索引
        """

        selectText = self.new_find_element(By.ID,
                                           self.ELEMENT["tv_title"]).text
        self.sift_opera.click2company(selectText, selectTarget)
        if index == 1:
            for i in range(10):
                stock_tag = self.isElementExist(By.ID,
                                                self.ELEMENT["stock_title_tv"])
                if stock_tag:
                    stock_info = self.new_find_element(
                        By.ID, self.ELEMENT["stock_title_tv"]).text
                    log.info("股票信息:{}".format(stock_info))
                    return stock_tag
                else:
                    self.swipeUp(x1=0.5, y1=0.7, y2=0.3, t=2000)
                    if i == 9:
                        log.error("===上市公司-股票信息获取失败===")
                        return stock_tag
        else:
            for i in range(10):
                company_bak = self.isElementExist(
                    By.XPATH, self.ELEMENT["company_background"])
                if company_bak:
                    atlas = self.new_find_element(
                        By.ID, self.ELEMENT["background_to_atlas"]).text
                    return atlas
                else:
                    self.swipeUp(x1=0.5, y1=0.7, y2=0.3, t=2000)
                    if i == 9:
                        log.error("===非上市公司「企业背景」上方「天眼风险」模块获取失败===")
                        return company_bak
        self.sift_opera.back2company_search()
        self.sift_opera.reset(selectTarget)

    def get_company_500(self, selectTarget):
        """
        获取公司:500强企业断言
        :param selectTarget: 选中条件
        """

        selectText = self.new_find_element(By.ID,
                                           self.ELEMENT["tv_title"]).text
        company_name = self.sift_opera.click2company(selectText, selectTarget)
        current_dir = os.path.abspath(
            os.path.dirname(os.path.dirname(__file__)))
        json_dir = os.path.dirname(current_dir) + "/Data/500.json"
        with open(json_dir, "r") as json_file:
            data = json.load(json_file)
        self.sift_opera.back2company_search()
        self.sift_opera.reset(selectTarget)
        return company_name, data, selectText

    @getimage
    def test_001_cgs_gjsx_sszt_p0(self):
        """查公司-搜索中间页,高级筛选:上市状态"""
        log.info(self.test_001_cgs_gjsx_sszt_p0.__doc__)
        try:
            self.sift_opera.search_key(1)
            num_sszt = random.randint(1, 2)
            selectTarget, selectText = self.sift_opera.get_key(
                "more_sszt_title", "more_sszt", num_sszt)
            result = self.get_company_sszt(selectTarget, num_sszt)

            if num_sszt == 1:
                self.assertTrue(
                    result,
                    "===失败-上市公司-股票信息获取失败===",
                )
            else:
                self.assertEqual("天眼图谱", str(result), "===失败-非上市公司-获取失败===")
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception

    @getimage
    def test_002_cgs_gjsx_500_p0(self):
        """查公司-搜索中间页,高级筛选:500强"""
        log.info(self.test_002_cgs_gjsx_500_p0.__doc__)
        try:
            self.sift_opera.search_key(1)
            num_500 = random.randint(1, 2)
            selectTarget, selectText = self.sift_opera.get_key(
                "more_500_title", "more_500", num_500)
            company_name, data, selectText = self.get_company_500(selectTarget)
            # 断言-世界/中国500强
            self.assertIn(company_name, data[str(num_500)],
                          "===失败-「{}」,断言失败===".format(selectText))
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception
class Search_company_sift_vip(MyTest, Operation):
    """查公司_高级筛选_04"""

    a = Read_Ex()
    ELEMENT = a.read_excel("test_search_company_sift")
    account = Account()
    phone_vip = account.get_account("vip")

    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        cls.sift_opera = SiftOperation(cls.driver, cls.ELEMENT)
        cls.sift_opera.login_vip(cls.phone_vip, cls.account.get_pwd())

    @classmethod
    def tearDownClass(cls):
        cls.account.release_account(cls.phone_vip, 'vip')
        super().tearDownClass()

    @getimage
    def test_001_cgs_gjsx_rjzzq_p0(self):
        """查公司-搜索中间页,高级筛选:软件著作权"""
        log.info(self.test_001_cgs_gjsx_rjzzq_p0.__doc__)
        try:
            self.sift_opera.search_key(1)
            num_rjzzq = random.randint(1, 2)
            selectTarget, selectText = self.sift_opera.get_key(
                "more_rjzzq_title", "more_rjzzq", num_rjzzq)
            result = self.sift_opera.detail4company(selectText, "著作权",
                                                    selectTarget, num_rjzzq)
            if num_rjzzq == 2 and not result:
                # 断言-详情页「著作权」维度无数据时
                self.assertFalse(result, "===失败-高级筛选:「无软件著作权」错误===")
            else:
                if num_rjzzq == 1:
                    # 断言-「有软件著作权」
                    self.assertNotIn("0", result, "===失败-高级筛选:「有软件著作权」错误===")
                else:
                    # 断言-详情页「有作品著作权」,「无软件著作权」
                    self.assertIn("0", result, "===失败-高级筛选:「无软件著作权」错误===")
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception

    @getimage
    def test_002_cgs_gjsx_rzxx_p0(self):
        """查公司-搜索中间页,高级筛选:融资信息"""
        log.info(self.test_002_cgs_gjsx_rzxx_p0.__doc__)
        try:
            self.sift_opera.search_key(1)
            num_rzxx = random.randint(1, 2)
            selectTarget, selectText = self.sift_opera.get_key(
                "more_rzxx_title", "more_rzxx", num_rzxx)
            result = self.sift_opera.detail4company(selectText, "融资历程",
                                                    selectTarget, num_rzxx)
            if num_rzxx == 1:
                # 断言-有融资历程
                self.assertTrue(result,
                                "===失败-高级筛选:「{}」错误===".format(selectText))
            else:
                # 断言-无融资历程
                self.assertFalse(result,
                                 "===失败-高级筛选:「{}」错误===".format(selectText))
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception
class TestOutMoneyAndFinalHuman(MyTest, Operation):
    account = Account()
    username = account.get_account('vip')
    password = account.get_pwd()

    def into_company_detail(self, company):
        """
        通过搜索进入公司详情页,搜索结果选择第一条
        :param company: 搜索公司名称
        :return: None
        """
        self.new_find_element(By.ID, elements["index_search_input"]).click()
        self.new_find_element(
            By.ID, elements["search_result_input"]).send_keys(company)
        self.new_find_elements(By.ID,
                               elements["search_result_item"])[0].click()

    @getimage
    def test_1_out_money(self):
        """企业背景-对外投资-count"""
        login_status = self.is_login()
        if not login_status:
            self.login(self.username, self.password)
        self.into_company_detail("红杉资本顾问咨询(北京)有限公司")
        out_money = self.swipe_up_while_ele_located(By.XPATH,
                                                    elements["out_money"],
                                                    check_cover=True)
        out_money_count = self.new_find_element(
            By.XPATH, elements["out_money_count"]).text
        print(out_money_count)
        out_money.click()
        real_num = self.data_list_count(By.ID, elements["out_money_item"])
        self.assertEqual(
            int(out_money_count),
            real_num,
            "对外投资实际数量{}与外侧count数量{}不相等".format(out_money_count, real_num),
        )

    @getimage
    def test_2_out_money_company_and_pic_jump(self):
        """企业背景-对外投资-公司和股权结构法定代表人跳转"""
        login_status = self.is_login()
        if not login_status:
            self.login(self.username, self.password)
        self.into_company_detail("红杉资本顾问咨询(北京)有限公司")
        self.swipe_up_while_ele_located(By.XPATH,
                                        elements["out_money"],
                                        click=True,
                                        check_cover=True)
        click_company = self.new_find_elements(
            By.ID, elements["out_money_company"])[0]
        click_name = click_company.text
        click_company.click()
        jump_name = self.new_find_element(By.ID,
                                          elements["detail_company_name"]).text
        self.assertEqual(
            click_name,
            jump_name,
            "对外投资公司展示名称{}和跳转详情页名称{}不一致".format(click_name, jump_name),
        )
        self.driver.keyevent(4)
        self.new_find_elements(By.ID, elements["out_money_pic"])[0].click()
        title = self.new_find_element(By.ID, elements["app_page_title"]).text
        self.assertEqual(title, "股权结构", "对外投资股权结构跳转失败")
        self.driver.keyevent(4)
        law_person = self.new_find_elements(
            By.ID, elements["out_money_law_person"])[0]
        law_name = law_person.text
        law_person.click()
        jump_law_name = self.new_find_element(
            By.ID, elements["detail_human_name"]).text
        self.assertEqual(
            law_name,
            jump_law_name,
            "对外投资法定代表人外侧名称{}和详情页名称{}不一致".format(law_name, jump_law_name),
        )

    @getimage
    def test_3_out_money_field_check(self):
        """对外投资字段合法校验"""
        login_status = self.is_login()
        if not login_status:
            self.login(self.username, self.password)
        self.into_company_detail("红杉资本顾问咨询(北京)有限公司")
        self.swipe_up_while_ele_located(By.XPATH,
                                        elements["out_money"],
                                        click=True,
                                        check_cover=True)
        # 经营状态
        operates = self.new_find_elements(By.ID, elements["out_money_operate"])
        for n in operates:
            self.assertTrue(operating_check(1, n.text), "对外投资中经营状态字段不合法")
        # 投资数额
        out_num = self.new_find_elements(By.ID, elements["out_money_num"])
        for t in out_num:
            self.assertTrue(is_bill_available(t.text), "对外投资中投资数额字段不合法")
        # 投资比例
        percentage = self.new_find_elements(By.ID,
                                            elements["out_money_percentage"])
        for p in percentage:
            self.assertTrue(is_percentage_available(p.text), "对外投资中投资比例字段不合法")
        # 成立日期
        create_time = self.new_find_elements(By.ID,
                                             elements["out_money_create_time"])
        for c in create_time:
            self.assertTrue(check_time(c.text, is_compare=True),
                            "对外投资中成立日期字段不合法")

    @getimage
    def test_4_final_human_count(self):
        """企业背景-最终受益人-count校验"""
        login_status = self.is_login()
        if not login_status:
            self.login(self.username, self.password)
        self.into_company_detail("北京蚂蜂窝网络科技有限公司")
        final = self.swipe_up_while_ele_located(By.XPATH,
                                                elements["final_human"])
        final_count = self.new_find_element(By.XPATH,
                                            elements["final_human_count"]).text
        final.click()
        real_num = self.all_count_compute_v1(By.XPATH,
                                             elements["final_human_item"])
        self.assertEqual(
            int(final_count),
            real_num,
            "最终受益人外侧count{}和实际数量{}不一致".format(final_count, real_num),
        )

    def test_5_final_human_jump(self):
        """最终受益人跳转"""
        login_status = self.is_login()
        if not login_status:
            self.login(self.username, self.password)
        self.into_company_detail("北京米未传媒有限公司")
        self.swipe_up_while_ele_located(By.XPATH,
                                        elements["final_human"],
                                        click=True)
        jump_boss = self.new_find_elements(By.ID,
                                           elements["final_human_boss"])[0]
        jump_name = jump_boss.text
        jump_boss.click()
        detail_name = self.new_find_element(By.ID,
                                            elements["detail_human_name"]).text
        self.assertEqual(
            jump_name,
            detail_name,
            "最终受益人老板名称{}和跳转详情页名称{}不一致".format(jump_name, detail_name),
        )
        self.driver.keyevent(4)
        self.new_find_element(
            By.ID, elements["final_human_boss_has_company"]).click()
        title = self.new_find_element(By.ID,
                                      elements["person_detail_title"]).text
        self.assertEqual(title, "人员详情", "最终受益人他有xx家公司跳转错误")

    def test_6_actual_control_count(self):
        """实际控制权count校验"""
        login_status = self.is_login()
        if not login_status:
            self.login(self.username, self.password)
        self.into_company_detail("杭州网易云音乐科技有限公司")
        actual_control = self.swipe_up_while_ele_located(
            By.XPATH, elements["actual_control"], check_cover=True)
        actual_control_count = self.new_find_element(
            By.XPATH, elements["actual_control_count"]).text
        actual_control.click()
        real_num = self.all_count_compute_v1(By.XPATH,
                                             elements["actual_control_item"])
        self.assertEqual(
            int(actual_control_count),
            real_num,
            "最终受益人外侧count{}和实际数量{}不一致".format(actual_control_count, real_num),
        )

    def test_7_actual_control_jump(self):
        """实际控制权公司跳转"""
        login_status = self.is_login()
        if not login_status:
            self.login(self.username, self.password)
        self.into_company_detail("杭州网易云音乐科技有限公司")
        self.swipe_up_while_ele_located(By.XPATH,
                                        elements["actual_control"],
                                        click=True,
                                        check_cover=True)
        names = self.new_find_elements(By.ID, elements["actual_control_name"])
        for n in names:
            jump_name = n.text
            n.click()
            act = self.new_find_element(By.ID,
                                        elements["detail_company_name"]).text
            self.assertEqual(
                jump_name, act,
                "实际控制权中控股企业名称{}和跳转详情页名称{}不一致".format(jump_name, act))
            self.driver.keyevent(4)

    def test_8_release_account(self):
        self.account.release_account(self.username, 'vip')
 def test_004_qbfu_fjgs_p0(self):
     """
     附近公司
     1、筛选
     2、导出数据---目前只做了正常的流程
     3、导航
     4、点击「附近公司」item
     """
     log.info(self.test_004_qbfu_fjgs_p0.__doc__)
     try:
         self.in_allserver('fjgs')
         self.jump_bounced('allow_address')
         a = self.new_find_element(By.ID, self.ELEMENT['page_title']).text
         self.assertEqual(a, '附近公司', msg='页面title不匹配')
         b = self.isElementExist(By.ID, self.ELEMENT['export_data'])
         self.assertTrue(b, msg='「导出数据没有找到」')
         # 公司详情页
         cname = self.new_find_elements(By.ID,
                                        self.ELEMENT['company3'])[0].text
         # cname_status = self.new_find_elements(By.ID, self.ELEMENT['search_reg_status'])[0].text
         self.new_find_elements(By.ID, self.ELEMENT['company3'])[0].click()
         self.jump_bounced('first_btn')
         cname1 = self.new_find_element(By.ID,
                                        self.ELEMENT['company1']).text
         # cname_status_all = self.new_find_elements(By.ID, self.ELEMENT['search_reg_status']).text
         self.assertEqual(cname1,
                          cname,
                          msg='详情页{}-结果页{}不一致'.format(cname1, cname))
         # TODO 标签断言
         # self.assertIn(cname_status, cname_status_all,msg='展示标签应该在公司详情页标签中')
         self.driver.keyevent(4)
         # 导出数据
         self.new_find_element(By.ID, self.ELEMENT['export_data']).click()
         # 获取使用账号
         account = Account()
         acc_vip_name = account.get_account('vip')
         acc_pwd = account.get_pwd()
         log.info("登录VIP账号:".format(acc_vip_name))
         # 使用获取到的账号登录
         self.hit_login(account=acc_vip_name, password=acc_pwd)
         # 选择非增值导出
         self.new_find_element(By.XPATH,
                               self.ELEMENT['free_export']).click()
         self.new_find_element(By.XPATH,
                               self.ELEMENT['email_export']).click()
         self.new_find_element(By.XPATH,
                               self.ELEMENT['email_export']).send_keys(
                                   '*****@*****.**')
         self.new_find_element(By.XPATH,
                               self.ELEMENT['export_click']).click()
         # 成功页回到搜索结果页
         self.new_find_element(By.ID, self.ELEMENT['success_back']).click()
         # 导航
         self.new_find_elements(By.ID,
                                self.ELEMENT['navigation'])[0].click()
         c = self.new_find_element(By.ID, self.ELEMENT['page_title']).text
         self.assertEqual(c, '地图', msg='公司地图导航页')
         # 使用完了要还回去
         account.release_account(acc_vip_name, "vip")
     except AssertionError:
         raise self.failureException()
     except Exception as e:
         print(e)
         raise Exception
class Search_company_sift_vip(MyTest, Operation):
    """查公司_高级筛选_03"""

    a = Read_Ex()
    ELEMENT = a.read_excel("test_search_company_sift")
    account = Account()
    phone_vip = account.get_account("vip")

    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        cls.sift_opera = SiftOperation(cls.driver, cls.ELEMENT)
        cls.sift_opera.login_vip(cls.phone_vip, cls.account.get_pwd())

    @classmethod
    def tearDownClass(cls):
        cls.account.release_account(cls.phone_vip, 'vip')
        super().tearDownClass()

    @getimage
    def test_001_cgs_gjsx_lxyx_p0(self):
        """查公司-搜索中间页,高级筛选:联系邮箱"""
        log.info(self.test_001_cgs_gjsx_lxyx_p0.__doc__)
        try:
            self.sift_opera.search_key(1)
            num_lxyx = random.randint(1, 2)
            selectTarget, selectText = self.sift_opera.get_key(
                "more_lxyx_title", "more_lxyx", num_lxyx)
            result = self.sift_opera.basic4company(selectText, selectTarget)

            if num_lxyx == 1:  # 有邮箱
                self.assertEqual("true", result, "===失败-「有邮箱」,断言失败===")
            else:  # 无邮箱
                self.assertEqual("false", result, "===失败-「无邮箱」,断言失败===")
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception

    @getimage
    def test_002_cgs_gjsx_sbxx_p0(self):
        """查公司-搜索中间页,高级筛选:商标信息"""
        log.info(self.test_002_cgs_gjsx_sbxx_p0.__doc__)
        try:
            self.sift_opera.search_key(1)
            num_sbxx = random.randint(1, 2)
            selectTarget, selectText = self.sift_opera.get_key(
                "more_sbxx_title", "more_sbxx", num_sbxx)
            result = self.sift_opera.detail4company(selectText, "商标信息",
                                                    selectTarget, num_sbxx)
            if num_sbxx == 1:
                # 断言-有商标信息
                self.assertTrue(result,
                                "===失败-高级筛选:「{}」错误===".format(selectText))
            else:
                # 断言-无商标信息
                self.assertFalse(result,
                                 "===失败-高级筛选:「{}」错误===".format(selectText))
        except AssertionError:
            raise self.failureException()
        except Exception as e:
            log.error(error_format(e))
            raise Exception